You are here

VESC packet fram-size

1 post / 0 new
Yosh101
Offline
Last seen: 2 years 2 weeks ago
Joined: 2022-09-02 13:04
Posts: 1
VESC packet fram-size

Hello everyone, 

Does anyone know the frame-size of VESC 4.12 on the firmware version of 5? I am trying to read the response of the motor, which send back to VESC through this method. But, it returns NONE. It might be the wrong frame-size. Has anyone ideas on this? Or any better solution?

import pyvesc
import serial
import time
import datetime
from pyvesc import GetValues, SetRPM, SetCurrent, SetRotorPositionMode, GetRotorPosition

port_object = serial.Serial("/dev/ttyACM0",115200, timeout=0.1)


message = pyvesc.SetRPM(10000)
cumessage = pyvesc.SetCurrent(10000)
packet = pyvesc.encode(message)
cupacket = pyvesc.encode(cumessage)


while True:
    data = ''
    port_object.write(packet)
    port_object.write(cupacket)
    print("data; ", port_object.in_waiting)
    #data = port_object.read(5)
    #print(data)
    port_object.write(pyvesc.encode_request(GetValues))
    #print(port_object.in_waiting)
                # Check if there is enough data back for a measurement
    if port_object.in_waiting > 78:
        (response, consumed) = pyvesc.decode(78)

        #packets = []
        #now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")
        print("response: ",response)
        print("consumed: ", consumed)
        """for sensor, value in response.__dict__.items():
            data = {}
            data['measurement'] = sensor
            data['tags'] = {}
            data['tags']['source'] = 'vesc'
            data['time'] = now
            data['fields'] = {}
            data['fields']['value'] = value
            packets.append(data)"""
            #print(data)

      
#port_object.flush()
#VESCMessage = pyvesc.GetVaĺues()
#packet = pyvesc.decode(VESCMessage)
#print(pa)

this is the result:

data;  2681
response:  None
consumed:  0
data;  2620
response:  None
consumed:  18
data;  2559
response:  None
consumed:  36
data;  2498
response:  None
consumed:  40
data;  2437
response:  None
consumed:  47
data;  2376
response:  None
consumed:  23