Hello,
I'm hoping someone can help diagnose a fault in my dual VESC controller. I have (pretty much) confirmed that the internal CAN bus forwarding is not working on my Flipsky FSESC6.7.
Here is what I have proven through extensive testing:
-
My host computer (a Raspberry Pi) and its UART port are fully functional (verified with a successful loopback test).
-
The VESC correctly receives and executes direct commands sent over UART to whichever side is physically connected.
-
However, when I send a valid
COMM_FORWARD_CAN
packet from the Pi to the master, the master executes the command on itself instead of forwarding it to the slave. This happens no matter which side is the master. -
I have tried every combination of
App to Use
,CAN_STATUS
, andCAN Mode
(COMM_BRIDGE
breaks the link entirely). The forwarding fails regardless of the configuration.Can anyone help with configuration for this case?
Thanks!!
-
This is the code i'm using:
import pyvesc
from pyvesc.VESC.messages import SetRPM
import serial
import time# --- Configuration ---
SERIAL_PORT = '/dev/serial0'
# IMPORTANT: The physically connected VESC is the MASTER
# In your case, you are plugged into the LEFT motor's side.
LEFT_MOTOR_ID = 59
RIGHT_MOTOR_ID = 45
MOTOR_SPEED = 4000
RUN_TIME_SECONDS = 3
# --------------------def send_rpm_command(ser, controller_id, rpm):
"""
Sends an RPM command to the specified motor controller by setting the can_id.
"""
# Create the SetRPM message object
message = SetRPM(rpm)
# Set the destination CAN ID on the message itself
message.can_id = controller_id
# The encode function should see the can_id and build the correct packet
ser.write(pyvesc.encode(message))# --- Main Program ---
if __name__ == "__main__":
# We use the correct IDs for the left and right motors now
left_motor_id = LEFT_MOTOR_ID
right_motor_id = RIGHT_MOTOR_IDtry:
# Use the master VESC (the one physically connected to the Pi) as the serial port
with serial.Serial(SERIAL_PORT, baudrate=115200, timeout=0.05) as ser:
print("Successfully connected to VESC. Starting sequence...")
# --- Left Motor Sequence ---
print(f"Running LEFT motor ({left_motor_id}) FORWARD for {RUN_TIME_SECONDS} seconds...")
send_rpm_command(ser, left_motor_id, MOTOR_SPEED)
time.sleep(RUN_TIME_SECONDS)
print(f"Running LEFT motor ({left_motor_id}) BACKWARD for {RUN_TIME_SECONDS} seconds...")
send_rpm_command(ser, left_motor_id, -MOTOR_SPEED)
time.sleep(RUN_TIME_SECONDS)
# --- Right Motor Sequence ---
print(f"Running RIGHT motor ({right_motor_id}) FORWARD for {RUN_TIME_SECONDS} seconds...")
send_rpm_command(ser, right_motor_id, MOTOR_SPEED)
time.sleep(RUN_TIME_SECONDS)print(f"Running RIGHT motor ({right_motor_id}) BACKWARD for {RUN_TIME_SECONDS} seconds...")
send_rpm_command(ser, right_motor_id, -MOTOR_SPEED)
time.sleep(RUN_TIME_SECONDS)print("\nSequence complete.")
except KeyboardInterrupt:
print("\nProgram stopped by user.")
except serial.SerialException as e:
print(f"\nSerial port error: {e}")finally:
print("Stopping all motors.")
with serial.Serial(SERIAL_PORT, baudrate=115200, timeout=0.05) as ser:
send_rpm_command(ser, left_motor_id, 0)
send_rpm_command(ser, right_motor_id, 0)
print("Motors stopped. Program finished.")