Skip to content

Commit

Permalink
Add max 32 bit int as max packet counter (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
aywaldron committed Oct 14, 2019
1 parent bd27f7e commit 75c22a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ait/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,9 @@ def get_packet_delta(pkt_defn, packet):

# previous packets of this type received
else:
counters[pkt_defn.name] += 1
count = counters[pkt_defn.name]
count = count + 1 if count < 2**31 - 1 else 0
counters[pkt_defn.name] = count
delta, dntoeus = {}, {}
for field, new_value in json_pkt.items():
last_value = packet_states[pkt_defn.name][field]
Expand Down Expand Up @@ -773,6 +775,7 @@ def handle():
delta, dntoeus, counter = get_packet_delta(pkt_defn, data)
delta = replace_datetimes(delta)
log.info(delta)
log.info('Packet #{}'.format(counter))

wsock.send(json.dumps({
'packet': pkt_defn.name,
Expand Down
6 changes: 4 additions & 2 deletions ait/gui/static/js/ait/tlm.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ class TelemetryStream
checkCounter (packetName, counter) {
// returns true if counter is as expected, false if not
let lastCounter = this._counters[packetName]
if ( counter == lastCounter + 1 ) {
if ( counter == lastCounter + 1) {
return true
}
} else if ( lastCounter == 2147483647 && counter == 0 ) {
return true
}
console.log('counter mismatch: had ' + lastCounter + ' , got ' + counter)
return false
}
Expand Down

0 comments on commit 75c22a2

Please sign in to comment.