From 675e84bfac666b714ceeb7b5475a0bce0c314ca8 Mon Sep 17 00:00:00 2001 From: Paul Guenette Date: Sun, 9 May 2021 17:19:16 -0400 Subject: [PATCH] Create can send example --- tools/can_example.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tools/can_example.py diff --git a/tools/can_example.py b/tools/can_example.py new file mode 100644 index 00000000..c2836d68 --- /dev/null +++ b/tools/can_example.py @@ -0,0 +1,14 @@ +import can + +bus = can.interface.Bus('can0', bustype='socketcan') +axisID = 0x1 << 5 +msgID = axisID | 0x7 + +msg = can.Message(arbitration_id=msgID, data=[0, 0, 0, 0, 3, 0, 0, 0], dlc=8) +print(msg) + +try: + bus.send(msg) + print("Message sent on {}".format(bus.channel_info)) +except can.CanError: + print("Message NOT sent!") \ No newline at end of file