Hey, im using socketcan on linux to talk with odrive. My program controls one odrive over canbus, specified by its serialnumber. I would like to run multiple instances of this program to control multiple odrives, but when i do i get: [CanAdapter] cannot open bulk stream. Same problem if i run
odrivetool --can can0 -s serialnumber in two terminals. Does odrivetool take ownership over all connected odrives even when i specify the serialnumber?
Hi!
Interesting.
With -s it only connects to that one ODrive, so running several instances on the same SocketCAN interface should be fine.
Generally the main issue is that the ODrivetool (specifically the backend libodrive) instances don’t communicate with each other. So in the discovery → autobaud → serial-number assignment scheme, the instances can fight: by default the ODrive is unaddressed (node_id 63), and odrivetool/libodrive assigns a node ID when it connects. Separate instances don’t coordinate on that, so they’ll both pick 0 and knock each other’s ODrive off its node ID. So first, each ODrive should be given a unique node ID (e.g. over a single odrivetool instance), and ideally have the baudrate explicitly assigned (to be the same as the USB-CAN adapter’s):
odrv0.axis0.config.can.node_id = 1 # 2, 3, ... for the others
odrv0.can.config.baud_rate = 250000 # Example, change to what yours is (e.g. 500k, 1Mbaud, etc)
odrv0.save_configuration()
Also, if you do have multiple instances, you should have only one instance per ODrive – a second connection takes over from the first, and the first drops out a few seconds later. So always pass the serial number.
You may continue to get the [CanAdapter] cannot open bulk stream message, but assuming it’s one instance per ODrive + each ODrive has a unique and explicitly-set baudrate and node ID, this should be harmless (it’s just the odrivetool / libodrive instances noticing each other on the CAN bus). But let me know if it specifically still doesn’t work after that.