PyVESC icon indicating copy to clipboard operation
PyVESC copied to clipboard

UART only or CAN BUS compatible?

Open akrv opened this issue 3 years ago • 4 comments

hi, using the vesc tool and looking for a python CAN-BUS lib. I didn't see anywhere the CAN Communication. Do you know if this works with CAN as well, if so, have you tried it?

akrv avatar Jan 13 '22 16:01 akrv

Hi, I managed to get the can to work like this: pyvesc.encode(pyvesc.SetRPM(0,can_id=can_id)) Can id is the id of the vesc connected in can. Do not hesitate to ask me for more details.

Vincent LAMBERT.

Vincentvlb avatar Jan 19 '22 15:01 Vincentvlb

Hi, I managed to get the can to work like this: pyvesc.encode(pyvesc.SetRPM(0,can_id=can_id)) Can id is the id of the vesc connected in can. Do not hesitate to ask me for more details.

Vincent LAMBERT.

Hi Vincent

Could you elaborate a little more about how you got it to work through CAN? How I'd like it to work, is that I can setup a motorCAN instance VESC(serialport=canId) as motorCAN for example, and then work with that.

MaxenceVanstaen avatar May 11 '22 09:05 MaxenceVanstaen

I am trying to eget canbus comms working.

    message = pyvesc.SetRPM(value, can_id=77)
    packet = pyvesc.encode(message)
    print('can packet = ',packet)

returns: b'\x02\x07!M\x08\x00\x00\x04\x1a\x8fV\x03'

while vesc tool wprking can bus command sends b'\x02\x07\x22\x4d\x05\x00\x00\x27\x10\x84\x51\x03'

It seems pyvesc.encode is not properly encoing a can messgae ie. 9 bytes(2 grabled) vs 12 bytes for good packet.

in setters.py SetRPM is setting can_id to None.

It is unclear is the canbus id displayed in Vesc Tool is decimal or hex.

class SetRPM(metaclass=VESCMessage): """ Set the RPM. :ivar rpm: Value to set the RPM to. """ id = 8 # COMM_SET_RPM can_id = None fields = [ ('rpm', 'i', 1) ]

I download PyVESC-FW3.33 version and python3 setup.py installed it. with python 3.6.9.

Any help on this would be much appreciated.

robogrow avatar Aug 01 '22 18:08 robogrow

I'm not sure about older versions of vesc firmware, but on firmware version 6.02 it looks like the value of _comm_forward_can node is outdated. After changing its hard-coded value from 33 to 34 in line 17 of base.py, I was able to get set_rpm to work with pyvesc.encode(pyvesc.SetRPM(0,can_id=can_id)).

joshuasrcho avatar Sep 01 '23 05:09 joshuasrcho