Skip to content

Commit

Permalink
pcap logging; Timestamps wrapping after 59 seconds.
Browse files Browse the repository at this point in the history
The datetime object does not hold total seconds since Epoch time.The seconds variable is only seconds since last full minute. We need
a deltatime since Epoch start to get total seconds since then
  • Loading branch information
ToveRumar committed May 7, 2024
1 parent c2408ef commit 599be51
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cflib/crtp/pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def _assemble_record(self, link_type, receive, address, channel, devid, crtp_pac
)

def _pcap_header(self, len):
ts = datetime.now()

return struct.pack('<LLLL', ts.second, ts.microsecond, len, len)
now = datetime.now()
delta = now - datetime(1900, 1, 1)
seconds = int(delta.total_seconds())
return struct.pack('<LLLL', seconds, delta.microseconds, len, len)

0 comments on commit 599be51

Please sign in to comment.