LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-21-2010, 01:56 PM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Question /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.
 
Old 08-21-2010, 02:03 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 08-21-2010 at 02:05 PM.
 
1 members found this post helpful.
Old 08-21-2010, 02:04 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
 
1 members found this post helpful.
Old 08-21-2010, 02:21 PM   #4
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
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.
 
Old 08-21-2010, 03:38 PM   #5
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
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!
 
Old 08-21-2010, 03:44 PM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
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.

Last edited by Completely Clueless; 08-21-2010 at 03:45 PM.
 
Old 08-21-2010, 03:57 PM   #7
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
Actually you can do this from command line with grep instead of cat.

grep GPRMC /dev/rfcomm0
 
1 members found this post helpful.
Old 08-21-2010, 04:28 PM   #8
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by joec@home View Post
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.

Last edited by Completely Clueless; 08-21-2010 at 04:31 PM.
 
Old 08-21-2010, 05:37 PM   #9
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
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.
 
Old 08-21-2010, 06:30 PM   #10
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Red face

Quote:
Originally Posted by joec@home View Post
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.
 
Old 08-22-2010, 05:52 AM   #11
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Catch all data being written to Hard Drives vzxen Linux - Newbie 20 07-27-2010 08:43 AM
The postgresql data directory content in the pgsql directory is lost (empty data dir) kisembo Linux - Software 1 02-13-2006 01:11 PM
Linux partition over written with Fat32 data! hi-clier Linux - Newbie 2 11-21-2004 07:35 PM
Possible to make filesystem on disk with data written to it? redhatman Linux - Newbie 3 08-28-2004 10:49 AM
How to get last file written to directory kd5giv Linux - Networking 4 03-29-2004 02:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration