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 29df085
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cflib/crtp/pcap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import struct
from datetime import datetime
from datetime import timedelta
from enum import IntEnum


Expand Down Expand Up @@ -139,6 +140,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 29df085

Please sign in to comment.