forked from canopen-python/canopen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sync.py
More file actions
29 lines (24 loc) · 917 Bytes
/
Copy pathtest_sync.py
File metadata and controls
29 lines (24 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
import canopen
class TestSync(unittest.TestCase):
def test_sync_producer(self):
network = canopen.Network()
network.connect(bustype="virtual", receive_own_messages=True)
producer = canopen.sync.SyncProducer(network)
producer.transmit()
msg = network.bus.recv(1)
network.disconnect()
self.assertEqual(msg.arbitration_id, 0x80)
self.assertEqual(msg.dlc, 0)
def test_sync_producer_counter(self):
network = canopen.Network()
network.connect(bustype="virtual", receive_own_messages=True)
producer = canopen.sync.SyncProducer(network)
producer.transmit(2)
msg = network.bus.recv(1)
network.disconnect()
self.assertEqual(msg.arbitration_id, 0x80)
self.assertEqual(msg.dlc, 1)
self.assertEqual(msg.data, b"\x02")
if __name__ == "__main__":
unittest.main()