Why “sudo cat /dev/ttyACM0” run only 1 time? (GPS)

  • #1
126
3
hi group,

I am working on the GPS data collection, I Need help. If anyone who has been working on the u-blox GNSS Evaluation Kit Time EVK-M8T before and have seen it, please help.
I do not know why sudo cat /dev/ttyACM0 only 1 time.

I have the U-blox EVK-M8T which can read the NMEA messages through the Ubuntu terminal window. When I have good set up, and type the command `sudo cat /dev/ttyACM0, it show me the NMEA meassages, such as:

$GLGSV,3,3,09,87,06,340,*52
$GNGLL,,,,,140236.00,V,N*56
$GNZDA,140236.00,10,03,2017,00,00*7C
$GNRMC,140236.85,V,,,,,,,100317,,,N*68
$GNVTG,,,,,,,,,N*2E
$GNGGA,140236.85,,,,,0,00,99.99,,,,,,*77
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E
$GPGSV,3,1,12,10,76,330,52,11,03,322,44,12,23,100,47,14,32,270,44*7E
$GPGSV,3,2,12,15,10,077,,18,70,123,46,20,02,130,47,21,22,189,47*73
$GPGSV,3,3,12,24,40,050,49,25,16,142,39,31,13,211,48,32,52,288,50*72
$GLGSV,3,1,09,69,26,096,28,70,62,024,37,71,30,315,29,73,37,171,36*6A
$GLGSV,3,2,09,79,20,030,,80,64,095,31,85,09,235,27,86,20,287,33*62
$GNGLL,,,,,140236.85,V,N*5B
$GNZDA,140236.85,10,03,2017,00,00*71

but suddenly, it stopped running without touching anything, I did not know why, and I tried to run again but it did not run. Until, mechanically unplug USB cable and connect a gain, it worked.

it happend again again and again...

Does anyone know what is going on?

Thank you.
 

Answers and Replies

  • #2
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
I do not know why sudo cat /dev/ttyACM0 only 1 time.
I know nothing about your GPS data stuff. But if you are cat'ing a file the process will run until it encounters EOF. If your tty device does not send an EOF character then the cat process will just wait patiently for more data from that tty. So I think you are seeing the process run and not terminate, but you don't realize it. It is not terminating until you unplug things and ungraciously cause it to be killed.

Does that sound to be what's happening?
 
  • #3
126
3
ungraciously
maybe it is true, because when it stops running on the Ubuntu terminal window, but the LED light of the device is still blinking every 1 second.

If you know something about it, can you tell me how to save those data into text file or dat file.....

Thank you.
 
  • #4
anorlunda
Staff Emeritus
Insights Author
9,025
5,936
So I think you are seeing the process run and not terminate, but you don't realize it. It is not terminating until you unplug things and ungraciously cause it to be killed.
Kudos. That is exactly the kind of hypothesis that is the essence of effective software troubleshooting Think of a scenario that matches the evidence.
 
  • #5
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
How quickly does it take for that complete data read, just a second or two?

You could start an asynchronous process that waits for sufficient time for cat to complete, then kills your cat.

In place of cat, consider dd as a utility to copy the device data to a file. dd has unusual syntax, so man dd
 
  • #6
126
3
How quickly does it take for that complete data read, just a second or two?

You could start an asynchronous process that waits for sufficient time for cat to complete, then kills your cat.

In place of cat, consider dd as a utility to copy the device data to a file. dd has unusual syntax, so man dd
I think 1 second gives me info. of the list which I posted above, and every second gives update of value of the list.

And I do not understand how to kill cat, and man dd.

Could you please give me in a little detail, so i can understand.

Thank you very much.
 
  • #7
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
'man' is the linux online manual, it returns documentation on linux commnds
man kill
man dd

Then google and look for examples in shell scripts where these are used.
 
  • #8
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
$GLGSV,
$GNGLL,,,,,
$GNZDA
I know nothing about GPS data. Does one of these 'words' indicate the end of your block of useful data? If so, it might be sufficient for your shell script to loop through reading and writing each line to a file until it finds that end word, then exiting the shell script. This approach would be simpler, and you'd not need to use kill.

The shell command for reading one line is: read -r

Is this problem part of some exercise or homework in your studies?
 
  • #9
1,524
624
Wait, I'm confused, what do you expect cat to do? Cat doesn't stick around, it dumps the file and then closes.

Do you mean to use "tail -f"?
 
  • #10
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
I was a little surprised that cat did seem to be waiting. Poster can easily check if it is using: ps
 

Related Threads on Why “sudo cat /dev/ttyACM0” run only 1 time? (GPS)

Replies
1
Views
680
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
2
Views
4K
  • Last Post
Replies
14
Views
3K
  • Last Post
Replies
3
Views
642
Replies
1
Views
2K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
7
Views
704
  • Last Post
Replies
3
Views
2K
Top