LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   /dev/..... Where is the data in this directory being written to? (http://www.linuxquestions.org/questions/linux-general-1/dev-where-is-the-data-in-this-directory-being-written-to-827678/)

Completely Clueless 08-21-2010 01:56 PM

/dev/..... Where is the data in this directory being written to?
 
Hi gang,

I am getting GPS up and running and need to get a log of all the locations visited in a moving vehicle.

I am puzzled by this command, which tells the GPS device to pipe all the location information it receives to a file in the /dev directory branch:

# gpsd -N -n -D 3 /dev/rfcomm0

When I enter "cat /dev/rfcomm0" i can see all this satellite data accumulating in an open terminal in one second intervals. What I don't understand is why the programmer is sending this data to a file in the /dev subdirectory. Is the data actually being saved there in the file rfcomm0 or is it basically just like a /dev/null situation where all data sent there is simply junked?

Thanks, CC.

paulsm4 08-21-2010 02:03 PM

The files in "/dev" should all (or "mostly" ;)) be "pointers" to the actual kernel drivers for that particular device. They should NOT (for the most part ;)) be "files" like you find in the rest of the filesystem.

Read this link about Linux Devices and Device Nodes

catkin 08-21-2010 02:04 PM

Files in the /dev directory are gateways to device drivers. If you do ls -l on them you will see that they have two numbers after their group. The first number is the index number of the device driver and the second has a meaning specific to that driver; their permissions begin with c or b indicating that the smallest unit of data transfer that can be made to the device is a character or a block.

Thus when you read from /dev/rfcomm0 you are getting data from the GPS device.

bastl 08-21-2010 02:21 PM

I think that file is a char device so it is a datastream for programmers. For a user that file is a FIFO buffer. All data get deleted on reading out.
Everything in linux is represented as a file also a complete harddisk - that's why you can grep a harddisk for deleted files.

Completely Clueless 08-21-2010 03:38 PM

I see, thanks, guys. So the data coming from /dev/rfcomm0 isn't being stored anyplace. I have to pipe it to a file if I want to save it. Thanks!

Completely Clueless 08-21-2010 03:44 PM

Which begs another question. The device pumps out these lines of data at around 1 second intervals. Here's a typical line:

$GPRMC,193119.796,A,5228.7806,N,01319.2708,E,000.0,191.4,180810,,,A*6A

Now I am only interested in lines starting with $GPRMC like this one above. But these only get spat out around one in 8 times. The other seven lines I don't need nor want. Is there any way in the C language I could write a utility which would check for this prefix in real time and only write these wanted lines to the file to be saved? I don't have much disk space remaining on the 8Gb SSHD notebook I'll be using.

joec@home 08-21-2010 03:57 PM

Actually you can do this from command line with grep instead of cat.

grep GPRMC /dev/rfcomm0

Completely Clueless 08-21-2010 04:28 PM

Quote:

Originally Posted by joec@home (Post 4073571)
Actually you can do this from command line with grep instead of cat.

grep GPRMC /dev/rfcomm0

Hey, great idea! So basically to finish:

grep GPRMC /dev/rfcomm0 > /media/sdb1/gps_log.txt

Oh, but that won't save the whole line though. I'll man grep and see if there's a flag that might.

joec@home 08-21-2010 05:37 PM

Oh, but that won't save the whole line though. I'll man grep and see if there's a flag that might.[/QUOTE]

Actually it should print the entire line that has the matching string.

Completely Clueless 08-21-2010 06:30 PM

Quote:

Originally Posted by joec@home (Post 4073605)
Oh, but that won't save the whole line though. I'll man grep and see if there's a flag that might.

Actually it should print the entire line that has the matching string.[/QUOTE]

D'oh!! Of course you are right. Sorry and thanks.

Completely Clueless 08-22-2010 05:52 AM

Sorry for anyone trying the same steps as above as there was a slight error I just spotted. The command should read:

grep GPRMC /dev/rfcomm0 >> /media/sdb1/gps_log.txt


All times are GMT -5. The time now is 10:10 AM.