-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTKGPS.py
493 lines (445 loc) · 39.1 KB
/
RTKGPS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
#! /usr/bin/env python3
"""
Program to read in data from the BB3 wetlabs sensor.
"""
try:
import serial
except ImportError as message:
print("Failed to import serialReaderial, maybe it is not installed correctly? Error was: {}".format(message))
try:
import datetime
except ImportError as message:
print("Failed to import datetime, maybe it is not installed correctly? Error was: {}".format(message))
try:
import time
except ImportError as message:
print("Failed to import time, maybe it is not installed correctly? Error was: {}".format(message))
try:
from dummy_sensors import DummyEXAMPLESensor
except ImportError as message:
print("Failed to import DummyBB3Sensor from dummy_sensors, check your files. Error was: {}".format(message))
import struct
def generateFletcherChecksum(byteArray):
"""
Function to calculate the checksum from the received line of data.
Returns the checksum generated from the line.
"""
CK_A = 0
CK_B = 0
for I in range(len(byteArray)):
CK_A = CK_A + byteArray[I]
CK_A &= 0xFF
CK_B = CK_B + CK_A
CK_B &= 0xFF
return (CK_A, CK_B)
def UBX_NAV_PVT(payload):
a = payload[4:6]
print(a)
b = ""
for i in a:
b = b + i
b = int(b,16)
#print(b)
def sizeTester():
structValues = {
'c': 1,
'x':1,
'b': 1,
'B': 1,
'?': 1,
'h': 2,
'H': 2,
'i': 4,
'I': 4,
'l': 4,
'L': 4,
'q': 8,
'Q': 8,
'e': 2,
'f': 4,
'd': 8
}
for item in structValues:
print("character {} has byte buffer value {}".format(item,struct.calcsize(item)))
def payloadDecoder(decodeFormat, payload):
decodedData = struct.unpack_from(decodeFormat[0],payload)
decodedData = list(decodedData)
descriptiveData = []
for item in range(len(decodeFormat[1])):
descriptiveData.append(decodeFormat[1][item])
descriptiveData.append(decodedData[item])
print(descriptiveData)
print("\n")
def PayloadIdentifier(payload, ID, Class):
length = 0
for item in payload:
length += len(item.encode('utf-8'))
#length = len(payload.encode('utf-8'))
print("id {}, class {}, length {}".format(ID, Class, length))
CONST_UBX_ACK_ACK = "05012"
CONST_UBX_ACK_NAK = "05002"
CONST_UBX_AID_ALM = "0B301"
CONST_UBX_AID_ALM2 = "0B308"
CONST_UBX_AID_ALM3 = "0B3040"
CONST_UBX_AID_AOP = "0B331"
CONST_UBX_AID_AOP2 = "0b3368"
CONST_UBX_AID_EPH = "0B311"
CONST_UBX_AID_EPH2 = "0b318"
CONST_UBX_AID_EPH3 = "0b3140"
CONST_UBX_AID_HUI = "0B0272"
CONST_UBX_AID_INI = "0B0148"
CONST_UBX_CFG_ANT = "06134"
CONST_UBX_CFG_BATCH = "06938"
CONST_UBX_CFG_CFG = "060912"
CONST_UBX_CFG_CFG2 = "060913"
CONST_UBX_CFG_DAT = "060644"
CONST_UBX_CFG_DAT2 = "060652"
CONST_UBX_CFG_DGNSS = "06704"
CONST_UBX_CFG_HNR = "065C4"
CONST_UBX_CFG_INF = "06021"
CONST_UBX_CFG_ITFM = "06398"
CONST_UBX_CFG_LOGFILTER = "064712"
CONST_UBX_CFG_MSG = "06012"
CONST_UBX_CFG_MSG2 = "06018"
CONST_UBX_CFG_MSG3 = "06013"
CONST_UBX_CFG_NAV5 = "062436"
CONST_UBX_CFG_NAVX5 = "062340"
CONST_UBX_CFG_NAVX51 = "062344"
CONST_UBX_CFG_NMEA = "06174"
CONST_UBX_CFG_NMEA2 = "061720"
CONST_UBX_CFG_ODO = "061e20"
CONST_UBX_CFG_PM2 = "063b44"
CONST_UBX_CFG_PM22 = "063b48"
CONST_UBX_CFG_PMS = "06868"
CONST_UBX_CFG_PRT = "060020"
# page 213... same class id length but different payload combination
# AND AGAIN ON PAGE 215
# and again on page 218
CONST_UBX_CFG_PWR = "06578"
CONST_UBX_CFG_RATE = "06086"
CONST_UBX_CFG_RST = "06044"
CONST_UBX_CFG_RXM = "06112"
CONST_UBX_CFG_SBAS = "06168"
CONST_UBX_CFG_SBAS = "068d4"
CONST_UBX_CFG_SMGR = "066220"
CONST_UBX_CFG_TMODE2 = "063d28"
CONST_UBX_CFG_TMODE3 = "067140"
CONST_UBX_CFG_TP5 = "063132"
CONST_UBX_CFG_TXSLOT = "065316"
CONST_UBX_CFG_USB = "061b108"
CONST_UBX_ESF_INS = "101536"
CONST_UBX_HNR_INS = "280236"
CONST_UBX_HNR_PVT = "280072"
CONST_UBX_LOG_BATCH = "2111100"
CONST_UBX_LOG_CREATE = "21078"
CONST_UBX_LOG_FINDTIME = "210e12"
CONST_UBX_LOG_FINDTIME2 = "210e8"
CONST_UBX_LOG_INFO = "210848"
CONST_UBX_LOG_RETRIEVEBATCH = "21204"
CONST_UBX_LOG_RETRIEVEPOSEXTRA = "210f32"
CONST_UBX_LOG_RETRIEVEPOS = "210b40"
CONST_UBX_LOG_RETRIEVE = "210912"
CONST_UBX_MGA_ACK_DATA0 = "13608"
CONST_UBX_MGA_ANO ="132076"
CONST_UBX_MGA_BDS_EPH = "130388"
CONST_UBX_MGA_BDS_ALM = "130340"
CONST_UBX_MGA_DBS_HEALTH = "130368"
CONST_UBX_MGA_BDS_UTC = "130320"
CONST_UBX_MGA_BDS_IONO = "130316"
CONST_UBX_MGA_FLASH_STOP = "13212"
CONST_UBX_MGA_FLASH_ACK = "13216"
CONST_UBX_MGA_GAL_EPH = "130276"
CONST_UBX_MGA_GAL_ALM = "130232"
CONST_UBX_MGA_GAL_TIMEOFFSET = "130212"
CONST_UBX_MGA_GAL_UTC = "130220"
CONST_UBX_MGA_ELO_EPH = "130648"
CONST_UBX_MGA_GLO_ALM = "130636"
CONST_UBX_MGA_GLO_TIMEOFFSET = "130620"
CONST_UBX_MGA_GPS_EPH = "130068"
CONST_UBX_MGA_GPS_ALM = "130036"
CONST_UBX_MGA_GPS_HEALTH = "130040"
CONST_UBX_MGA_GPS_UTC = "130020"
CONST_UBX_MGA_GPS_IONO = "130016"
CONST_UBX_MGA_GPS_IONO = "134020"
CONST_UBX_MGA_INI_POS_LLH = "134020"
# THE TWO ABOVE HAVE THE SAME CLASS ID LENGTH
CONST_UBX_MGA_INI_TIME_UTC = "134024"
CONST_UBX_MGA_INI_TIME_GNSS = "134024"
# THE TWO ABOVE HAVE THE SAME CLASS ID LENGTH
CONST_UBX_MGA_INI_CLKD = "134012"
CONST_UBX_MGA_INI_FREQ = "134012"
# THE TWO ABOVE HAVE THE SAME CLASS ID LENGTH
CONST_UBX_MGA_INI_EOP = "134072"
CONST_UBX_MGA_QZSS_EPH = "130568"
CONST_UBX_MGA_QZSS_ALM = "130536"
CONST_UBX_MGA_QZSS_HEALTH = "130512"
CONST_UBX_MON_BATCH = "0A3212"
CONST_UBX_MON_GNSS = "0A288"
CONST_UBX_MON_HW2 = "0A0B28"
CONST_UBX_MON_HW = "0A0960"
CONST_UBX_MON_MSGPP = "0A06120"
CONST_UBX_MON_RXBUF = "0A0724"
CONST_UBX_MON_RXR = "0A211"
CONST_UBX_MON_SMGR = "0A2E16"
CONST_UBX_MON_TXBUF = "0A0828"
CONST_UBX_NAV_AOPSTATUS = "016016"
CONST_UBX_NAV_ATT = "010532"
CONST_UBX_NAV_CLOCK = "012220"
CONST_UBX_NAV_DOP = "010418"
CONST_UBX_NAV_EOE = "01614"
CONST_UBX_NAV_HPPOSECEF = "011328"
CONST_UBX_NAV_HPPOSLLH = "011436"
CONST_UBX_NAV_ODO = "010920"
CONST_UBX_NAV_POSECEF = "010120"
CONST_UBX_NAV_POSLLH = "010228"
CONST_UBX_NAV_PVT = "010792"
CONST_UBX_NAV_RELPOSNED = "013C40"
CONST_UBX_NAV_SOL = "010652"
CONST_UBX_NAV_STATUS = "010316"
CONST_UBX_NAV_SVIN = "013B40"
CONST_UBX_NAV_TIMEBDS = "012420"
CONST_UBX_NAV_TIMEGAL = "012520"
CONST_UBX_NAV_TIMEGLO = "012320"
CONST_UBX_NAV_TIMEGPS = "012016"
CONST_UBX_NAV_TIMELS = "012624"
CONST_UBX_NAV_TIMEUTC = "012120"
CONST_UBX_NAV_VELECEF = "011120"
CONST_UBX_NAV_VELNED = "011236"
CONST_UBX_RXM_PMREQ = "024116"
CONST_UBX_RXM_RLM = "025916"
CONST_UBX_RXM_RLM2 = "025928"
CONST_UBX_RXM_RTCM = "02328"
CONST_UBX_SEC_UNIQID = "27039"
CONST_UBX_TIM_DOSC = "0D0118"
CONST_UBX_TIM_FCHG = "0d1632"
CONST_UBX_TIM_HOC = "0d178"
CONST_UBX_TIM_SVIN = "0d0428"
CONST_UBX_TIM_TIM2 = "0d0328"
CONST_UBX_TIM_TOS = "0d1256"
CONST_UBX_TIM_TP = "0d0116"
CONST_UBX_TIM_VCOCAL = "0d151"
CONST_UBX_TIM_VCOCAL2 = "0d1512"
CONST_UBX_TIM_VCOCAL3 = "0d1512"
CONST_UBX_TIM_VRFY = "0d0620"
CONST_UBX_UPD_SOS = "09144"
CONST_UBX_UPD_SOS2 = "09148"
base16Data = [int(x, 16) for x in payload]
currentByteLine = bytearray(base16Data)
# b for 1, i for 4, h for 2
ClassIDs = {
CONST_UBX_NAV_RELPOSNED: ("bbhiiiibbbbiiii",["version","reserved1","refStationId","iTOW","relPosN","relPosE","relPosD","relPosHPN","relPosHPE","relPosHPD","reserved2","accN","accE","accD","flags"]),
CONST_UBX_NAV_PVT: ("ihbbbbbbiibbbbiiiiiiiiiiiiihbbbbbbbihh",["iTOW","year","month","day","hour","min","sec","valid","tAcc","nano","fixType","flags","flags2","numSV","lon","lat","height","hMSL","hAcc","vAcc","velN","velE","velD","gSpeed","headMot","sAcc","headAcc","pDOP","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","headVeh","magDec","magAcc"]),
CONST_UBX_ACK_ACK: ("bb",["clsID","msgID"]),
CONST_UBX_ACK_NAK: ("bb",["clsID","msgID"]),
CONST_UBX_AID_ALM: ("b",["svid","week","dwrd"]),
CONST_UBX_AID_ALM2: ("ii",["svid","week"]),
CONST_UBX_AID_ALM3: ("iiiiiiiiii",["svid","week","dwrd","dwrd","dwrd","dwrd","dwrd","dwrd","dwrd","dwrd"]),
CONST_UBX_AID_AOP: ("b",["svod"]),
CONST_UBX_AID_AOP2: ("68b",["gnssID","svId","reserved1","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data"]),
CONST_UBX_AID_EPH: ("b",["svid"]),
CONST_UBX_AID_EPH2: ("ii",["svid","how"]),
CONST_UBX_AID_EPH3: ("ii24i",["svid","how","sf1d","sf1d","sf1d","sf1d","sf1d","sf1d","sf1d","sf1d","sf2d","sf2d","sf2d","sf2d","sf2d","sf2d","sf2d","sf2d","sf3d","sf3d","sf3d","sf3d","sf3d","sf3d","sf3d","sf3d"]),
CONST_UBX_AID_HUI: ("illihhhhhhiiiiiiiii",["health","utcA0","utcA1","utcTOW","utcWNT","utcLS","utcWNF","utcDN","utcLSF","utcSpare","klobA0","klobA1","klobA2","klobA3","klobB0","klobB1","klobB2","klobB3","flags"]),
CONST_UBX_AID_INI: ("iiiihhiiiiiii",["ecefXOrLat","ecefYOrLon","ecefZOrAlt","posAcc","tmCfg","wnoOrDate","towOrTime","towNs","tAccMs","tAccNs","clkDOrFreq","clkDAccOrFreqAcc","flags"]),
CONST_UBX_CFG_ANT: ("hh",["flags","pins"]),
CONST_UBX_CFG_BATCH: ("bbhhbb",["version","flags","bufSize","notifThrs","pioId","reserved1"]),
CONST_UBX_CFG_CFG: ("iii",["clearMask","saveMask","loadMask"]),
CONST_UBX_CFG_CFG2: ("iiib",["clearMask","saveMask","loadMask","deviceMask"]),
CONST_UBX_CFG_DAT: ("hblliiiiiii",["datunNum","datumName","majA","flat","dX","dY","dZ","rotX","rotY","rotZ","scale"]),
CONST_UBX_CFG_DAT2: ("h6blliiiiiii",["datunNum","datumName","majA","flat","dX","dY","dZ","rotX","rotY","rotZ","scale"]),
CONST_UBX_CFG_DGNSS: ("bb",["dgnssMode","reserved1"]),
CONST_UBX_CFG_HNR: ("bbbb",["highNavRate","reserved1","reserved1","reserved1"]),
CONST_UBX_CFG_INF: ("bbb",["protocolID","reserved1","infMsgMask"]),
CONST_UBX_CFG_ITFM: ("ii",["config","config2"]),
CONST_UBX_CFG_LOGFILTER: ("bbhhhi",["version","flags","minInterval","timeThreshold","speedThreshold","positionThreshold"]),
CONST_UBX_CFG_MSG: ("bb",["msgClass","msgID"]),
CONST_UBX_CFG_MSG2: ("bbbbbbbb",["msgClass","msgID","rate","rate","rate","rate","rate","rate"]),
CONST_UBX_CFG_MSG3: ("bbbbbbbb",["msgClass","msgID","rate"]),
CONST_UBX_CFG_NAV5: ("hbbiibbhhhhbbbbbbhbbbbbb",["mask","dynModel","fixMode","fixedAlt","fixedAltVar","minElev","drLimit","pDop","tDop","pAcc","tAcc","staticHoldThresh","dgnssTimeout","cnoThreshNumSVs","cnoThresh","reserved1","reserved1","staticHoldMaxDist","utcStandard","reserved2","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_CFG_NAVX5: ("hhibbbbbbbbbbhbbbbbbbbbbhbbbbbbbb",["version","mask1","mask2","reserved1","reserved1","minSVs","maxSVs","minCNO","reserved2","iniFix3D","reserved3","reserved3","ackAiding","wknRollover","reserved4","reserved4","reserved4","reserved4","reserved4","reserved4","usePPP","aopCfg","reserved5","reserved5","aopOrbMaxErr","reserved6","reserved6","reserved6","reserved6","reserved7","reserved7","reserved7","useAdr"],["version","mask1","mask2","reserved1","reserved1","minSVs","maxSVs","minCNO","reserved2","iniFix3D","reserved3","reserved3","ackAiding","wknRollover","sigAttenCompMode","reserved4","reserved5","reserved5","reserved6","reserved6","usePPP","aopCfg","reserved7","reserved7","aopOrbMaxErr","reserved8","reserved8","reserved8","reserved8","reserved9","reserved9","reserved9","useAdr"]),
CONST_UBX_CFG_NAVX51:("hhibbbbbbbbbbhbbbbbbbbbbhbbbbbbbbbbbb",["version","mask1","mask2","reserved1","reserved1","minSVs","maxSVs","minCNO","reserved2","iniFix3D","reserved3","reserved3","ackAiding","wknRollover","sigAttenCompMode","reserved4","reserved5","reserved5","reserved6","reserved6","usePPP","aopCfg","reserved7","reserved7","aopOrbMaxErr","reserved8","reserved8","reserved8","reserved8","reserved9","reserved9","reserved9","useAdr","reserved10","reserved10","reserved1","reserved11"]),
CONST_UBX_CFG_NMEA: ("bbbb",["filter","nmeaVersion","numSV","flags"]),
CONST_UBX_CFG_NMEA2: ("bbbbibbbbbbbbbbbb",["filter","nmeaVersion","numSV","flags","gnssToFilter","svNumbering","mainTalkerId","gsvTalkerID","version","bdsTalkerId","reserved1"]),
CONST_UBX_CFG_ODO: ("bbbbbbbbbbbbbbbbbbbb",["version","reserved1","reserved1","reserved1","flags","odoCfg","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","cogMaxSpeed","cogMaxPosAcc","reserved3","reserved3","velLpGain","cogLpGain","reserved4","reserved4"]),
CONST_UBX_CFG_PM2: ("bbbbiiiihbbbbbbbbbbbbbbbbbbbb",["version","reserved1","maxStartupStateDur","reserved2","flags","updatePeriod","searchPeriod","gridOffset","onTime","minAcqTime","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3"]),
CONST_UBX_CFG_PM22: ("bbbbiiiihhbbbbbbbbbbbbbbbbbbbbi",["version","reserved1","maxStartupStateDur","reserved2","flags","updatePeriod","searchPeriod","gridOffset","onTime","minAcqTime","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","extintInactivityMs"]),
CONST_UBX_CFG_PMS: ("bbhhbb",["version","powerSetupValue","period","onTime","reserved1"]),
CONST_UBX_CFG_PRT: ("bbhiihhhbb",["portID","reserved1","txReady","mode","baudRate","inProtoMask","outProtoMask","flags","reserved2"]),
CONST_UBX_CFG_PWR: ("bbbbi",["version","reserved1","reserved1","reserved1","state"]),
CONST_UBX_CFG_RATE: ("hhh",["measRate","navRate","timeRef"]),
CONST_UBX_CFG_RST: ("hbb",["navBbrMask","resetMode","reserved1"]),
CONST_UBX_CFG_RXM: ("bb",["reserved1","lpMode"]),
CONST_UBX_CFG_SBAS: ("bbbbi",["mode","usage","maxSBAS","scanmode2","scanmode1"]),
CONST_UBX_CFG_SBAS: ("bbbb",["mode","reserved1"]),
CONST_UBX_CFG_SMGR: ("bbhhbbhhhhi",["version","minGNSSFix","masFreqChangeRate","maxPhaseCorrRate","reserved1","freqTolerance","timeTolerance","messageCfg","maxSlewRate","flags"]),
CONST_UBX_CFG_TMODE2: ("bbhiiiiii",["timeMode","reserved1","flags","ecefXOrLat","ecefYOrLon","ecefZOrAlt","fixedPosAcc","svinMinDur","svinAccLimit"]),
CONST_UBX_CFG_TMODE3: ("bbhiiibbbbiiibbbbbbbb",["version","reserved1","flags","ecefXOrLat","ecefYOrLon","ecefZOrAlt","ecefXOrLatHP","ecefYOrLonHP","ecefZOrAltHP","reserved2","fixedPosAcc","svinMinDur","svinAccLimit","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3"]),
CONST_UBX_CFG_TP5: ("bbbbhhiiiiii",["tpIdx","version","reserved1","reserved1","antCableDelay","rfGroupDelay","freqPeriod","freqPeriodLock","pulseLenRatio","pulseLenRatioLock","userConfigDelay","flags"]),
CONST_UBX_CFG_TXSLOT: ("bbbbi",["version","enable","refTp","reserved1","end"]),
CONST_UBX_CFG_USB: ("hhbbbbhh32b32b32b",["vendorID","productID","reserved1","reserved1","reserved2","reserved2","powerConsumption","flags","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","vendorString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","productString","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber","serialNumber"]),
CONST_UBX_ESF_INS: ("ibbbbiiiiii",["bitfield0","reserved1","iTOW","xAngRate","yAngRate","zAngRate","xAccel","yAccel","zAccel"]),
CONST_UBX_HNR_INS: ("ibbbbiiiiiii",["bitfield0","reserved1","reserved1","reserved1","reserved1","iTOW","xAngRate","yAngRate","zAngRate","xAccel","yAccel","zAccel"]),
CONST_UBX_HNR_PVT: ("ihbbbbbbibbbbiiiiiiiiiiiibbbb",["iTOW","year","month","day","hour","min","sec","valid","nano","gpsFix","flags","reserved1","reserved1","lon","lat","height","hMSL","gSpeed","speed","headMot","headVeh","hAcc","vAcc","sAcc","headAcc","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_LOG_BATCH: ("bbhihbbbbbbiibbbbiiiiiiiiiiiiihbbiiibbbb",["version","contentValid","msgCnt","iTOW","year","month","day","hour","min","sec","valid","tAcc","fracSec","fixType","flags","flags2","numSV","lon","lat","height","hMSL","hAcc","vAcc","velN","velE","velD","gSpeed","headMot","sAcc","headAcc","pDOP","reserved1","reserved1","distance","totalDistance","distanceStd","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_LOG_CREATE: ("bbbbi",["version","logCfg","reserved1","logSize","userDefinedSize"]),
CONST_UBX_LOG_FINDTIME: ("bbbbhbbbbbb",["version","type","reserved1","year","month","day","hour","minute","second","reserved2"]),
CONST_UBX_LOG_FINDTIME2: ("bbbbi",["version","type","reserved1","entryNumber"]),
CONST_UBX_LOG_INFO: ("bbbbibbbbbbbbiiihbbbbbbhbbbbbbbbbb",["version","reserved1","reserved1","reserved1","filestoreCapacity","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","currentMaxLogSize","currentLogSize","entryCount","oldestYear","oldestMonth","oldestDay","oldestHour","oldestMinutes","oldestSecond","reserved3","newestYear","newestMonth","newestDay","newestHour","newestMinute","newestSecond","reserved4","status","reserved5","reserved5","reserved5"]),
CONST_UBX_LOG_RETRIEVEBATCH: ("bbbb",["version","flags","reserved1","reserved1"]),
CONST_UBX_LOG_RETRIEVEPOSEXTRA: ("ibbhbbbbbbbbibbbbbbbbbbbb",["entryIndex","version","reserved1","year","month","day","hour","minute","second","reserved2","reserved2","reserved2","distance","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3","reserved3"]),
CONST_UBX_LOG_RETRIEVEPOS: ("iiiiiiibbhbbbbbbbb",["entryIndex","lon","lat","hMSL","hAcc","gSpeed","heading","version","fixType","year","month","day","hour","minute","second","reserved1","reserved2"]),
CONST_UBX_LOG_RETRIEVE: ("iibbbb",["startNumber","entryCount","version","reserved1","reserved1","reserved1"]),
CONST_UBX_MGA_ACK_DATA0: ("bbbbbbbb",["type","version","infoCode","msgId","msgPayloadStart"]),
CONST_UBX_MGA_ANO: ("bbbbbbbb64bbbbb",["type","version","svId","gnssId","year","month","day","reserved1","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","data","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_BDS_EPH: ("bbbbbbhiiihbbiiiihhiiiiiiiiiibbbb",["type","version","svId","reserved1","satH1","IODC","a2","a1","a0","toc","TGD1","URAI","IODE","toe","sqrtA","e","omega","Deltan","IDOT","M0","Omega0","OmegaDot","i0","Cuc","Cus","Crc","Cic","Cis","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_BDS_ALM: ("bbbbbbhiiiiiihhbbbb",["type","version","svId","reserved1","Wna","toa","deltaI","sqrtA","e","omega","M0","Omega0","omegaDot","a0","a1","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_DBS_HEALTH: ("bbbb30hbbbb",["type","version","reserved1","reserved1","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_BDS_UTC: ("bbbbiibbbbbbb",["type","version","reserved1","reserved1","a0UTC","a1UTC","dtLS","reserved2","wnLSF","dN","dtLSF","reserved3","reserved3"]),
CONST_UBX_MGA_BDS_IONO: ("bbbbbbbbbbbbbbb",["version","reserved1","reserved1","alpha0","alpha1","alpha2","alpha3","beta0","beta1","beta2","beta3","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_FLASH_STOP: ("bb",["type","version"]),
CONST_UBX_MGA_FLASH_ACK: ("bbbbh",["type","version","ack","reserved1","sequence"]),
CONST_UBX_MGA_GAL_EPH: ("bbbbhhiiiiiiihhhhhhhhiibbhhbbbbbbbbbb",["type","version","svId","reserved1","iodNav","deltaN","m0","e","sqrtA","omega0","i0","omega","omegaDot","iDot","cuc","cus","crc","crs","cic","cis","toe","af0","af1","af2","sisaIndexE1E5b","toc","bgdE1E5b","reserved2","reserved2","healthE1b","dataValidityE5b","reserved3","reserved3","reserved3","reserved3"]),
CONST_UBX_MGA_GAL_ALM: ("bbbbbbhhhhhhhhhhbbbbbb",["type","version","svId","reserved1","ioda","almWNa","toa","deltaSqrtA","e","deltaI","omega0","omegaDot","omega","m0","af0","af1","healthE1B","healthE5b","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_GAL_TIMEOFFSET: ("bbbbhhbbbb",["type","version","reserved1","reserved1","a0G","t0G","wn0G","reserved2","reserved2"]),
CONST_UBX_MGA_GAL_UTC: ("bbbbiibbbbbbbb",["type","version","reserved1","reserved1","a0","a1","dtLS","tot","wnt","wnLSF","dN","dTLSF","reserved2","reserved2"]),
CONST_UBX_MGA_ELO_EPH: ("bbbbbbbbiiiiiibbbbhbbibbbb",["type","version","svId","reserved1","FT","B","M","H","x","y","z","dx","dy","dz","ddx","ddy","ddz","tb","gamma","E","deltaTau","tau","reserved2"]),
CONST_UBX_MGA_GLO_ALM: ("bbbbhbbhhiiiibbhbbbb",["type","version","svId","reserved1","N","M","C","tau","epsilon","lambda","deltaI","tLambda","deltaT","deltaDT","H","omega","reserved2"]),
CONST_UBX_MGA_GLO_TIMEOFFSET: ("bbhiihhbbbb",["type","version","N","tauC","tauGps","B1","B2","reserved1","reserved1","reserved1","reserved1"]),
CONST_UBX_MGA_GPS_EPH: ("bbbbbbbbhhbbhihhihhiihhihhiiihbb",["type","version","svId","reserved1","fitInterval","uraIndex","svHealth","tgd","iodc","toc","reserved2","af2","af1","af0","crs","deltaN","m0","cuc","cus","e","sqrtA","toe","cic","omega0","cis","crc","i0","omega","omegaDot","idot","reserved3","reserved3","reserved3"]),
CONST_UBX_MGA_GPS_ALM: ("bbbbhbbhhiiiihhbbbb",["type","version","svId","svHealth","e","almWNa","toa","deltaI","omegaDot","sqrtA","omega0","omega","m0","af0","af1","reserved1","reserved1","reserved1","reserved1"]),
CONST_UBX_MGA_GPS_HEALTH: ("bbbb32bbbbb",["type","version","reserved1","reserved1","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","healthCode","reserved2","reserved2"]),
CONST_UBX_MGA_GPS_UTC: ("bbbbiibbbbbbbb",["type","version","reserved1","reserved1","utcA0","utcA1","utcDtLS","utcTot","utcWNt","utcWNlsf","utcDn","utcDtLSF","reserved2"]),
CONST_UBX_MGA_GPS_IONO: ("bbbbbbbbbbbbbbbb",["type","version","reserved1","reserved1","ionoAlpha0","ionoAlpha1","ionoAlpha3","ionoBeta0","ionoBeta1","ionoBeta2","ionoBeta3","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_GPS_IONO: ("bbbbiiii",["type","version","reserved1","ecefX","ecefY","ecefZ","posAcc"]),
CONST_UBX_MGA_INI_POS_LLH: ("bbbbiiii",["type","version","reserved1","reserved1","lat","lon","alt","posAcc"]),
CONST_UBX_MGA_INI_TIME_UTC: ("bbbbhbbbbbbihbbi",["version","ref","leapSecs","year","month","day","hour","minute","second","reserved1","ns","tAccs","reserved2","reserved2","tAccNs"]),
CONST_UBX_MGA_INI_TIME_GNSS: ("bbbbbbhiihbbi",["type","version","ref","gnssId","reserved1","week","tow","ns","tAccs","reserved2","reserved2","tAccNs"]),
CONST_UBX_MGA_INI_CLKD: ("bbbbii",["type","version","reserved1","reserved1","clkD","clkDAcc"]),
CONST_UBX_MGA_INI_FREQ: ("bbbbii",["type","version","reserve1","flags","freq","freqAcc"]),
CONST_UBX_MGA_INI_EOP: ("bbbbhhiiiiii40b",["type","version","reserved1","reserved1","d2kRef","d2kMax","xpP0","xpP1","ypP0","ypP1","dUT1","ddUT1","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2"]),
CONST_UBX_MGA_QZSS_EPH: ("bbbbbbbbhhbbhihhihhiihhihhiiihbb",["type","version","svId","reserved1","fitInterval","uraIndex","svHealth","tgd","iodc","toc","reserved2","af2","af1","af0","crs","deltaN","m0","cuc","cus","e","sqrtA","toe","cic","omega0","cis","crc","i0","omega","omegaDot","idot","reserved3","reserved3"]),
CONST_UBX_MGA_QZSS_ALM: ("bbbbhbbhhiiiihhbbbb",["type","version","svId","svHealth","e","almWNa","toa","deltaI","omegaDot","sqrtA","omega0","omega","m0","af0","af1","reserved1","reserved1","reserved1","reserved1"]),
CONST_UBX_MGA_QZSS_HEALTH: ("bbbbbbbbbbbb",["type","version","reserved1","reserved1","healthCode","healthCode","healthCode","healthCode","healthCode","reaserved2","reserved2","reserved2"]),
CONST_UBX_MON_BATCH: ("bbbbbhhhh",["version","reserved1","reserved1","reserved1","fillLevel","dropsAll","dropsSinceMon","nextMsgCnt"]),
CONST_UBX_MON_GNSS: ("bbbbbbbb",["version","supported","defaultGnss","enabled","simultaneous","reserved1","reserved1","reserved1"]),
CONST_UBX_MON_HW2: ("bbbbbbbbibbbbbbbbibbbb",["ofsI","magI","ofsQ","magQ","cfgSource","reserved1","reserved1","reserved1","lowLevCfg","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","reserved2","postStatus","reserved3","reserved3","reserved3","reserved3"]),
CONST_UBX_MON_HW: ("iiiihhbbbbi17bbbbiii",["pinSel","pinBank","pinDir","pinVal","noisePerMS","agcCnt","aStatus","aPower","flags","reserved1","usedMask","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","VP","jamInd","reserved2","reserved2","pinIrq","pullH","pullL"]),
CONST_UBX_MON_MSGPP: ("8h8h8h8h8h8hiiiiii",["msg1","msg1","msg1","msg1","msg1","msg1","msg1","msg1","msg2","msg2","msg2","msg2","msg2","msg2","msg2","msg2","msg3","msg3","msg3","msg3","msg3","msg3","msg3","msg3","msg4","msg4","msg4","msg4","msg4","msg4","msg4","msg4","msg5","msg5","msg5","msg5","msg5","msg5","msg5","msg5","msg6""msg6""msg6""msg6""msg6""msg6""msg6""msg6","skipped","skipped","skipped","skipped","skipped","skipped"]),
CONST_UBX_MON_RXBUF: ("6h6b6b",["pending","pending","pending","pending","pending","pending","usage","usage","usage","usage","usage","usage","peakUsage","peakUsage","peakUsage","peakUsage","peakUsage","peakUsage"]),
CONST_UBX_MON_RXR: ("b",["flags"]),
CONST_UBX_MON_SMGR: ("bbbbihhbbbb",["version","reserved1","reserved1","reserved1","reserved1","iTOW","intOsc","extOsc","discSrc","gnss","extInt0","extInt1"]),
CONST_UBX_MON_TXBUF: ("6h6b6bbbbb",["pending","pending","pending","pending","pending","pending","usage","usage","usage","usage","usage","usage","peakUsage","peakUsage","peakUsage","peakUsage","peakUsage","peakUsage","tUsage","tPeakusage","errors","reserved1"]),
CONST_UBX_NAV_AOPSTATUS: ("ibb10b",["iTOW","aopCfg","status","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1","reserved1"]),
CONST_UBX_NAV_ATT: ("ibbbbiiiiii",["iTOW","version","reserved1","reserved1","reserved1","roll","pitch","heading","accRoll","accPitch","accHeading"]),
CONST_UBX_NAV_CLOCK: ("iiiii",["iTOW","clkB","clkD","tAcc","fAcc"]),
CONST_UBX_NAV_DOP: ("ihhhhhhh",["iTOW","gDOP","pDOP","tDOP","vDOP","hDOP","nDOP","eDOP"]),
CONST_UBX_NAV_EOE: ("i",["iTOW"]),
CONST_UBX_NAV_HPPOSECEF: ("bbbbiiiibbbbi",["version","reserved1","reserved1","reserved1","iTOW","ecefX","ecefY","ecefZ","ecefXHp","ecefYHp","ecefZHp","reserved2","pAcc"]),
CONST_UBX_NAV_HPPOSLLH: ("bbbbiiiiibbbbii",["version","reserved1","reserved1","reserved1","iTOW","lon","lat","height","hMSL","lonHp","latHp","heightHp","hMSLHp","hAcc","vAcc"]),
CONST_UBX_NAV_ODO: ("bbbbiiii",["version","reserved1","reserved1","reserved1","iTOW","distance","totalDistance","distanceStd"]),
CONST_UBX_NAV_POSECEF: ("iiiii",["iTOW","ecefX","ecefY","ecefZ","pAcc"]),
CONST_UBX_NAV_POSLLH: ("iiiiiii",["iTOW","lon","lat","height","hMSL","hAcc","vAcc"]),
CONST_UBX_NAV_SOL: ("iihbbiiiiiiiihbbbbbb",["iTOW","fTOW","week","gpsFix","flags","ecefX","ecefY","ecefZ","pAcc","ecefVX","ecefVY","ecefVZ","sAcc","pDOP","reserved1","numSV","reserved","reserved","reserved","reserved"]),
CONST_UBX_NAV_STATUS: ("ibbbbii",["iTOW","gpsFix","flags","fixStat","flags2","ttff","msss"]),
CONST_UBX_NAV_SVIN: ("bbbbiiiiibbbbiibbbb",["version","reserved1","iTOW","dur","meanX","meanY","meanZ","meanXHP","meanYHP","meanZHP","reserved2","meanAcc","obs","valid","active","reserved3"]),
CONST_UBX_NAV_TIMEBDS: ("iiihbbi",["iTOW","SOW","FSOW","week","leapS","valid","tAcc"]),
CONST_UBX_NAV_TIMEGAL: ("iiihbbi",["iTOW","galTow","fGalTow","galWno","leapS","valid","tAcc"]),
CONST_UBX_NAV_TIMEGLO: ("iiihbbi",["iTOW","TOD","fTOD","Nt","N4","valid","tAcc"]),
CONST_UBX_NAV_TIMEGPS: ("iihbbi",["iTOW","fTOW","week","leapS","valid","tAcc"]),
CONST_UBX_NAV_TIMELS: ("ibbbbbbbbihhbbbb",["iTOW","version","reserved1","srcOfCurrLs","currLs","srcOfLsChange","lsChange","timeToLsEvent","dateOfLsGpsWn","dateOfLsGpsDn","reserved2","valid"]),
CONST_UBX_NAV_TIMEUTC: ("iiihbbbbbb",["iTOW","tAcc","nano","year","month","day","hour","min","sec","valid"]),
CONST_UBX_NAV_VELECEF: ("iiiii",["iTOW","ecefVX","ecefVY","ecefVZ","sAcc"]),
CONST_UBX_NAV_VELNED: ("iiiiiiiii",["iTOW","velN","velE","velD","speed","gSpeed","heading","sAcc","cAcc"]),
CONST_UBX_RXM_PMREQ: ("bbbbiii",["version","reserved1","duration","flag","wakeupSouces"]),
CONST_UBX_RXM_RLM: ("bbbb8bbbbb",["version","type","svId","reserved1","beacon","beacon","beacon","beacon","beacon","beacon","beacon","beacon","message","params","params","reserved2"]),
CONST_UBX_RXM_RLM2: ("bbbb8bb12bbbb",["version","type","svId","reserved1","beacon","beacon","beacon","beacon","beacon","beacon","beacon","beacon","message","params","params","params","params","params","params","params","params","params","params","params","params","reserved2","reserved2","reserved2"]),
CONST_UBX_RXM_RTCM: ("bbhhh",["version","flags","subType","refStation","msgType"]),
CONST_UBX_SEC_UNIQID: ("bbbbbbbbb",["version","reserved1","reserved1","reserved1","uniqueId","uniqueId","uniqueId","uniqueId","uniqueId"]),
CONST_UBX_TIM_DOSC: ("bbbbi",["version","reserved1","value"]),
CONST_UBX_TIM_FCHG: ("bbbbiiiiiii",["version","reserved1","reserved1","reserved1","iTOW","intDeltaFreq","intDeltaFreqUnc","intRaw","extDeltaFreq","extDeltaFreqUnc","extRaw"]),
CONST_UBX_TIM_HOC: ("bbbbi",["version","oscId","flags","reserved1","value"]),
CONST_UBX_TIM_SVIN: ("iiiiiibbbb",["dur","meanX","meanY","meanZ","meanV","obs","valid","active","reserved1","reserved1"]),
CONST_UBX_TIM_TIM2: ("bbhhhiiiii",["ch","flags","count","wnR","wnF","towMsR","towSubMsR","towMsF","towSubMsF","accEst"]),
CONST_UBX_TIM_TOS: ("bbbbihbbbbbbiiiiiiiiii",["version","gnssId","reserved1","flags","year","month","day","hour","minute","second","utcStandard","utcOffset","utcUncertainty","week","TOW","gnssOffset","gnssUncertainty","intOscOffset","intOscUncertainty","extOscOffset","extOscUncertainty"]),
CONST_UBX_TIM_TP: ("iiihbb",["towMS","towSubMS","qErr","week","flags","refInfo"]),
CONST_UBX_TIM_VCOCAL: ("b",["type"]),
CONST_UBX_TIM_VCOCAL2: ("bbbbbbhhh",["type","version","oscId","srcId","reserved1","reserved1","raw0","raw1","maxStepSize"]),
CONST_UBX_TIM_VCOCAL3: ("bbbbbbhi",["type","version","oscId","reserved1","reserved1","reserved1","gainUncertainty","gainVco"]),
CONST_UBX_TIM_VRFY: ("iiiihbb",["itow","frac","deltaMs","deltaNs","wno","flags","reserved1"]),
CONST_UBX_UPD_SOS: ("bbbbb",["cmd","reserved1","reserved1","reserved1"]),
CONST_UBX_UPD_SOS2: ("bbbbbbbb",["cmd","reserved1","reserved1","reserved1","response","reserved2","reserved2","reserved2"])
}
identifier = str(Class) + str(ID) + str(length)
if identifier in ClassIDs.keys():
payloadDecoder(ClassIDs[identifier],currentByteLine)
class ExampleSensor:
"""
The EXAMPLE sensor class to read in data live while in-situ.
Reads in a line of data, then after checking a certain number of times to see if there is data, adjust a waiting timer.
The waiting timer is adjusted to avoid unnecessary CPU usage on the Raspberry Pi.
"""
def Reading(self):
"""
Generator function to read in data from the sensor.
Uses a time taken per line read formula to adjust the time to wait between making checks.
Reads in all the data in the buffer, then splits it up into lines, and processs them individually.
"""
bitOfData = b''
try:
serialReader = serial.Serial('/dev/ttyACM0', 460800, timeout = None)
organisedHexData = []
loadsOfHexData = []
# Continously read in data from the GPS.
while True:
if serialReader.in_waiting != 0:
bitOfData = serialReader.read(serialReader.in_waiting)
loadsOfData = list(bitOfData.hex())
# Organise the hex data into the correct pairs.
for index in range(0, len(loadsOfData), 2):
val = loadsOfData[index] + loadsOfData[index+1]
if len(val) == 2:
loadsOfHexData.append(val)
organisedHexData = organisedHexData + loadsOfHexData
loadsOfHexData = []
listOfLines = []
startIndices = [ i for i in range(len(organisedHexData)-1) if (organisedHexData[i] == 'b5' and organisedHexData[i+1] == '62') ]
if(len(startIndices) >= 2):
for currentStartIndex in range(len(startIndices)-1):
# For all indexes for start points, check if each is a full line.
currentLine = organisedHexData[startIndices[currentStartIndex]:startIndices[currentStartIndex+1]]
base16Data = [int(x, 16) for x in currentLine]
currentByteLine = bytearray(base16Data)
checkSumA, checkSumB = generateFletcherChecksum(currentByteLine[2:-2])
assert (len(currentByteLine)>1),"{} shorter then 2".format(currentByteLine)
# If the line is complete and correct then append it to a list of lines.
if(checkSumA == currentByteLine[-2] and checkSumB == currentByteLine[-1]):
listOfLines.append(currentLine)
else:
# If the line is not complete, check if the "start index" was actually generated in the payload (middle of the message)
# If it was, check the following start indexes. If none are correct then discard the data.
for x in range(len(startIndices)-1):
currentLine = organisedHexData[startIndices[currentStartIndex]:startIndices[x+1]]
base16Data = [int(x, 16) for x in currentLine]
currentByteLine = bytearray(base16Data)
checkSumA, checkSumB = generateFletcherChecksum(currentByteLine[2:-2])
if(checkSumA == currentByteLine[-2] and checkSumB == currentByteLine[-1]):
listOfLines.append(currentLine)
break
# For all the lines collected, get the payload out and send it to get sorted... eventually... it's a work in progress..
for line in listOfLines:
#print("Payload: {}".format(line[6:-2]))
PayloadIdentifier(line[6:-2], line[3], line[2])
f = open("/local1/data/scratch/jkb/GPS2.txt", "a")
f.write(str(line))
f.write('\n')
f.close()
# Any data that was not a complete line, and is in fact a part of the next line to be read in
# is kept in the organised hex data list so the rest of the line can be appended.
organisedHexData = organisedHexData[startIndices[len(startIndices)-1]:]
except ValueError as message:
print("Did not manage to connect to sensor properly, check your settings. Error was: {}".format(message))
except ImportError as message:
print("Importing issue, error was {}".format(message))
ex = ExampleSensor()
while True:
ex.Reading()