Jul-23-2018, 12:18 AM
Hi,
I have a project to log raw binary GPS data (from a ublox GPS reciever) to a file for later post processing. The receiver puts out raw GPS data message packets (not the NMEA sentences - these have been disabled). The problem i am having is that when i read and log the data to a file the resulting binary file is not the same as the data that i read from. For example if read and log using a terminal program like "cutecom" it works fine so there is obviously something wrong with my code.
The following code simply reads a byte into an array and then logs it to a file as a test:
Any help is much appreciated.
Cheers.
I have a project to log raw binary GPS data (from a ublox GPS reciever) to a file for later post processing. The receiver puts out raw GPS data message packets (not the NMEA sentences - these have been disabled). The problem i am having is that when i read and log the data to a file the resulting binary file is not the same as the data that i read from. For example if read and log using a terminal program like "cutecom" it works fine so there is obviously something wrong with my code.
The following code simply reads a byte into an array and then logs it to a file as a test:
import serial import time import pickle def setupSerial(GPSPort): ser = serial.Serial(port=GPSPort,baudrate=115200,bytesize=8,parity='N',stopbits=1,xonxoff=0,rtscts=0) print(ser) #testing return ser GPSPort="/dev/ttyUSB0" ser = setupSerial(GPSPort) newFileBytes=[] for x in range(1000): y = ser.inWaiting() print(y) if y > 0: z=ser.read() print(z) newFileBytes.append(z) with open("~/GPSBinTest.ubx","wb") as mypicklefile: pickle.dump(newFileBytes, mypicklefile)Can anybody see what i am doing wrong here.
Any help is much appreciated.
Cheers.