Skip to content

Commit c1b07e3

Browse files
committed
Further Edge Case Improvements
Further improving against edge cases of messages with number of bytes that aren't specified in the manual
1 parent 466a26a commit c1b07e3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lib/inputs/serial_g3x.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def closeInput(self, aircraft):
7979
def readMessage(self, aircraft):
8080
def mean(nums):
8181
return float(sum(nums)) / max(len(nums), 1)
82-
8382
if aircraft.errorFoundNeedToExit:
8483
return aircraft
8584
try:
@@ -269,6 +268,21 @@ def mean(nums):
269268
return aircraft
270269
else:
271270
aircraft.msg_bad += 1
271+
elif len(msg) == 28:
272+
if(isinstance(msg,str)): msg = msg.encode() # if read from file then convert to bytes
273+
SentVer, UTCHour, UTCMin, UTCSec, UTCSecFrac, TAS, unknownvalue, Checksum, CRLF = struct.unpack(
274+
"c2s2s2s2s4s11s2s2s", msg
275+
)
276+
if int(SentVer) == 1 and CRLF[0] == self.EOL:
277+
while suppress(ValueError):
278+
aircraft.tas = int(TAS) * 0.115078 # convert knots to mph * 0.1
279+
aircraft.msg_count += 1
280+
if (self.isPlaybackMode): # if playback mode then add a delay. Else reading a file is way to fast.
281+
time.sleep(0.08)
282+
if self.output_logFile != None:
283+
Input.addToLog(self,self.output_logFile,bytes([61,ord(SentID)]))
284+
Input.addToLog(self,self.output_logFile,msg)
285+
return aircraft
272286
else:
273287
aircraft.msg_bad += 1
274288
elif SentID == "7": # GPS AGL data message

0 commit comments

Comments
 (0)