Home › Forums › Forums › Technical Support for BerryGPS and BerryGPS-IMU › Writing Code to Record GPS data
- This topic has 6 replies, 2 voices, and was last updated 3 years, 7 months ago by PeterP.
- AuthorPosts
- April 23, 2020 at 9:27 am #15736MariusMoldovanParticipant
Hello
I’m working on a school project and attempting to build a GPS that is capable of recording data from the GSM, streamed through the usb, into a text file. When I test the code I’ve written, based on the code made available on this site, it seems that the gps isn’t sending any more data than the first lat lon line, and similar variations of that data line, into the delineated text file I’ve set up. My code is based on the code provided on this site. Can you take a look at it and let me know what you think is wrong with it?
April 23, 2020 at 1:15 pm #15739PeterPParticipantcan you please upload the file again, it looks like there was a security issue.. which I have now fixed
Peter --OzzMaker.com --
April 24, 2020 at 3:47 am #15768MariusMoldovanParticipantSure. To clarify, either the code is making the device only output that first line or there is an issue with the device logging data once it is used in something like a vehicle. My trials were all vehicle based and I made sure that the module had a fix before departure and maintained a fix. Since it was outputting latitude and longitude and not “0.0” for both fields, i assume the device had a fix.
Attachments:
April 24, 2020 at 8:46 pm #15771PeterPParticipantI tried your code, and it worked fine for me.
Below is the contents of the file;pi@raspberrypi:~ $ tail -f test.txt latitude , longitude , time , altitude , epv , ept , speed , climb, hour -33.779926333 , 151.111997333 , 98.5 , 42.78 , 0.005 , 0.037 , nan , 11:41 -33.7799275 , 151.112000167 , 98.4 , 43.01 , 0.005 , 0.175 , nan , 11:41 -33.779929167 , 151.112002167 , 98.2 , 40.94 , 0.005 , 0.102 , nan , 11:41 -33.779930833 , 151.112003667 , 98.0 , 43.01 , 0.005 , 0.093 , nan , 11:41 -33.779931167 , 151.112002333 , 97.9 , 43.01 , 0.005 , 0.078 , nan , 11:41
Update your code to print
report
to the terminal, just add it aftergpsd.next()
while True: report = gpsd.next() # print report if report['class'] == 'TPV':
See if your output is similar to mine below;
pi@raspberrypi:~ $ python problem.py <dictwrapper: {u'release': u'3.17', u'proto_major': 3, u'rev': u'3.17', u'class': u'VERSION', u'proto_minor': 12}> <dictwrapper: {u'class': u'DEVICES', u'devices': [{u'parity': u'N', u'activated': u'2020-04-24T10:42:17.251Z', u'driver': u'u-blox', u'subtype': u'SW ROM CORE 3.01 (107888),HW 00080000,FWVER=SPG 3.01,PROTVER=18', u'bps': 115200, u'flags': 1, u'stopbits': 1, u'path': u'/dev/ttyACM3', u'cycle': 1.0, u'class': u'DEVICE', u'mincycle': 0.25, u'native': 0}]}> <dictwrapper: {u'pps': False, u'enable': True, u'scaled': False, u'raw': 0, u'json': True, u'nmea': False, u'timing': False, u'class': u'WATCH', u'split24': False}> <dictwrapper: {u'status': 2, u'epx': 6.598, u'epy': 4.299, u'epv': 8.682, u'ept': 0.005, u'lon': 151.111978833, u'eps': 13.2, u'lat': -33.779932167, u'track': 0.0, u'mode': 3, u'time': u'2020-04-24T10:42:18.000Z', u'device': u'/dev/ttyACM3', u'alt': 91.5, u'speed': 0.103, u'class': u'TPV'}> <dictwrapper: {u'status': 2, u'epx': 6.598, u'epy': 4.299, u'epv': 8.682, u'ept': 0.005, u'lon': 151.1119795, u'eps': 13.2, u'lat': -33.779932167, u'track': 0.0, u'mode': 3, u'time': u'2020-04-24T10:42:19.000Z', u'device': u'/dev/ttyACM3', u'alt': 91.5, u'speed': 0.105, u'class': u'TPV'}>
Peter --OzzMaker.com --
April 24, 2020 at 8:48 pm #15772PeterPParticipantBTW:copy and paste the outputs above into a text file. Its hard to read here in the forum due to the word wrapping
Peter --OzzMaker.com --
April 26, 2020 at 4:47 am #15774MariusMoldovanParticipantI made the adjustment to the code. I attached a copy of it.
Attachments:
April 27, 2020 at 4:47 pm #15778PeterPParticipantyour output looks good. I cant workout why you are not getting all the data in your file.
1Can you upload the first 100 lines of your file so I can have a look.
Can you move the print statement to be in the loop after it finds TPV… like below. When you run it, does it keep printing out the TPV data or does it only do it once and stop?
while True: report = gpsd.next() # if report['class'] == 'TPV': print report lat = float(getattr(report,'lat',0.0))
Can you also show a few lines of the NMEA sentences when you run
gpsmon -n
Peter --OzzMaker.com --
- AuthorPosts
- You must be logged in to reply to this topic.