Skip to content

Commit f9df77e

Browse files
committed
Validate the encoding directly
1 parent 4531c9b commit f9df77e

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

test/test_time.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@ def test_time_producer(self):
3434
self.assertEqual(days, int(current_in_epoch) // canopen.timestamp.ONE_DAY)
3535
self.assertEqual(ms, int((current_in_epoch % canopen.timestamp.ONE_DAY) * 1000))
3636

37-
# Test providing a timestamp
38-
faketime = 1_927_999_438 # 2031-02-04 20:23:58
37+
# Provide a specific time to verify the proper encoding
38+
faketime = 1_927_999_438 # 2031-02-04 19:23:58
3939
producer.transmit(faketime)
4040
msg = network.bus.recv(1)
4141
self.assertEqual(msg.arbitration_id, 0x100)
4242
self.assertEqual(msg.dlc, 6)
43-
ms, days = canopen.timestamp.TIME_OF_DAY_STRUCT.unpack(msg.data)
44-
current_in_epoch = faketime - epoch
45-
self.assertEqual(days, int(current_in_epoch) // canopen.timestamp.ONE_DAY)
46-
self.assertEqual(ms, int((current_in_epoch % canopen.timestamp.ONE_DAY) * 1000))
43+
self.assertEqual(msg.data, b"\xb0\xa4\x29\x04\x31\x43")
4744

4845
network.disconnect()
4946

0 commit comments

Comments
 (0)