Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UART only or CAN BUS compatible? #24

Open
akrv opened this issue Jan 13, 2022 · 4 comments
Open

UART only or CAN BUS compatible? #24

akrv opened this issue Jan 13, 2022 · 4 comments

Comments

@akrv
Copy link

akrv commented Jan 13, 2022

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?

@Vincentvlb
Copy link

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.

@MaxenceVanstaen
Copy link

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.

@robogrow
Copy link

robogrow commented Aug 1, 2022

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.

@joshuasrcho
Copy link

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)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants