slave-testbench-23/Test.py

22 lines
505 B
Python
Raw Normal View History

2023-04-01 18:53:28 +02:00
import time
import can
2023-04-01 18:55:55 +02:00
bustype = "socketcan"
channel = "can0" # echten can nutzen
2023-04-01 18:53:28 +02:00
def producer(id):
""":param id: Spam the bus with messages including the data id."""
bus = can.Bus(channel=channel, interface=bustype)
for i in range(10):
2023-04-01 18:55:55 +02:00
msg = can.Message(
arbitration_id=0x002, data=[id, i, 0, 1, 3, 1, 4, 1], is_extended_id=False
)
2023-04-01 18:53:28 +02:00
bus.send(msg)
time.sleep(1)
2023-04-01 18:55:55 +02:00
producer(10) # rausfinden welche id der Slave hat
2023-04-01 18:53:28 +02:00
print("I am done with this shit")