質問

I have a gps hooked up to my raspberry pi and am trying to use it to geotag photos from an incoming camera. By issuing the command "gpsd -nND2 /dev/ttyUSB0," I can get bash echo outputs of continuous gps data that can later be parsed. I only need to average 10 data points or so (collected over 10 seconds), however, and want to close gpsd down after that.

My general timelapse program is written in python, so this is what I have so far:

(stdout, stderr) = Popen(["gpsd","-nND2,"/dev/ttyUSB0"], stdout=PIPE).communicate()

Unfortunately, this would output to variable stdout an unlimited number of data points that I can't parse. The output is much like a never-ending ping routine. How can I stop the data collection to make for a reasonable/parsable data dump?

Thank you for your help.

役に立ちましたか?

解決

According to the docs, you should not be looking at the console output, and instead using gpsd as a daemon, communicating to it via TCP:

Client applications will communicate with gpsd via a TCP/IP port, 2947 by default).

他のヒント

Does this work? I've not tested it.

proc = Popen(["gpsd","-nND2","/dev/ttyUSB0"], stdout=PIPE)

samples = []
for _ in range(10):
    samples.append(proc.stdout.readline())

proc.terminate()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top