LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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, 02:56 PM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 810

Rep: Reputation: 68
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, 03:03 PM   #2
paulsm4
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 03:05 PM.
 
1 members found this post helpful.
Old 08-21-2010, 03:04 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
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, 03:21 PM   #4
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 217

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

Original Poster
Rep: Reputation: 68
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, 04:44 PM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 810

Original Poster
Rep: Reputation: 68
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 04:45 PM.
 
Old 08-21-2010, 04:57 PM   #7
joec@home
Member
 
Registered: Sep 2009
Location: Houston Tx
Posts: 89

Rep: Reputation: 29
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, 05:28 PM   #8
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 810

Original Poster
Rep: Reputation: 68
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 05:31 PM.
 
Old 08-21-2010, 06:37 PM   #9
joec@home
Member
 
Registered: Sep 2009
Location: Houston Tx
Posts: 89

Rep: Reputation: 29
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, 07:30 PM   #10
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 810

Original Poster
Rep: Reputation: 68
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, 06:52 AM   #11
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 810

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 09:43 AM
The postgresql data directory content in the pgsql directory is lost (empty data dir) kisembo Linux - Software 1 02-13-2006 02:11 PM
Linux partition over written with Fat32 data! hi-clier Linux - Newbie 2 11-21-2004 08:35 PM
Possible to make filesystem on disk with data written to it? redhatman Linux - Newbie 3 08-28-2004 11:49 AM
How to get last file written to directory kd5giv Linux - Networking 4 03-29-2004 03:26 PM


All times are GMT -5. The time now is 07:57 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration