LiamBindle / PyVESC

PyVESC is an easy to use and robust Python implementation of the VESC - Open Source ESC communication protocol
https://pyvesc.readthedocs.io/en/latest/
Creative Commons Attribution 4.0 International
74 stars 54 forks source link

error: missing attribute 'can_id' #15

Closed Addy771 closed 4 years ago

Addy771 commented 4 years ago

Background:

When I try to encode a GetValues request, I get an exception:

type object 'GetValues' has no attribute 'can_id'
Traceback (most recent call last):
  File "logger.py", line 102, in log_vesc
    send_packet = pyvesc.encode_request(GetValues)
  File "./pyvesc\pyvesc\protocol\interface.py", line 51, in encode_request
    msg_payload = pyvesc.protocol.base.VESCMessage.pack(msg_cls, header_only=True)
  File "./pyvesc\pyvesc\protocol\base.py", line 104, in pack
    if instance.can_id is not None:
AttributeError: type object 'GetValues' has no attribute 'can_id'

I was able to avoid this error by modifying VESCMessage in protocol\base.py. I added this line to the VESCMessage constructor: cls.can_id = None

With that change, pyvesc is working and I get correct data with GetValues.

LiamBindle commented 4 years ago

@Addy771 Thanks for opening an issue. Could you make a PR with your fix? That way I can share it with other users.

Thanks! -Liam

Addy771 commented 4 years ago

I tried to, but I think I can't, due to the way that I pulled and merged pyvesc.

Here's the commit where I made this fix: https://github.com/Addy771/VESC-logger/commit/c103f6eb220ea13cee3a49bc7514d0afa06ecafc

Maybe you could just make the change and reference this issue.

LiamBindle commented 4 years ago

Sounds good, I can add this.