Skip to content

Commit 599be51

Browse files
committed
pcap logging; Timestamps wrapping after 59 seconds.
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
1 parent c2408ef commit 599be51

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cflib/crtp/pcap.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def _assemble_record(self, link_type, receive, address, channel, devid, crtp_pac
139139
)
140140

141141
def _pcap_header(self, len):
142-
ts = datetime.now()
143-
144-
return struct.pack('<LLLL', ts.second, ts.microsecond, len, len)
142+
now = datetime.now()
143+
delta = now - datetime(1900, 1, 1)
144+
seconds = int(delta.total_seconds())
145+
return struct.pack('<LLLL', seconds, delta.microseconds, len, len)

0 commit comments

Comments
 (0)