Skip to main content

Tool for flashing a VESC via CAN-bus or serial/USB using Python.

Project description

pybldc

Developed by Kristian Sloth Lauszus, 2024-2025

The code is released under the GNU General Public License v3.0.


PyPI CI Coverage badge

Purpose

This tool allows you to flash a VESC via CAN-bus or serial/USB using Python.

Installation and running

To install:

pip install .

Or install the latest release from PyPI:

pip install -U pybldc

CLI

A handy CLI tool is included.

I recommend using uvx to run the CLI tool:

uvx pybldc --help

Or you can install it in your path:

uv tool install pybldc
pybldc --help

Usage

usage: pybldc [-id CONTROLLER_ID] [-i INTERFACE] [-l CHANNEL] [-p PORT] [-h]
              [--version] [-B BINARY] [--bootloader] [-t TIMEOUT]
              [-r PING_REPEAT] [-b BAUDRATE] [--debug]
              {can,serial} {upload,ping,reset}

positional arguments:
  {can,serial}          Communicate with the target via either CAN or serial
  {upload,ping,reset}   upload: write BINARY
                        ping: send a ping command to the target and check for a response
                        reset: send a reset command to the target and check for a response

required CAN arguments:
  -id CONTROLLER_ID, --controller-id CONTROLLER_ID
                        The VESC ID used for communication

optional CAN arguments:
  -i INTERFACE, --interface INTERFACE
                        The CAN-Bus interface to use (default "socketcan")
  -l CHANNEL, --channel CHANNEL
                        The CAN-Bus channel to use (default "can0")

required serial arguments:
  -p PORT, --port PORT  The port to use for serial

optional arguments:
  -h, --help            Show this help message and exit
  --version             Show program's version number and exit
  -B BINARY, --binary BINARY
                        The binary to upload
  --bootloader          The binary to upload is a bootloader
  -t TIMEOUT, --timeout TIMEOUT
                        The time to wait in seconds for a response (default 5.0)
  -r PING_REPEAT, --ping-repeat PING_REPEAT
                        The number of times to try to establish a connection by pinging the VESC (default 3)
  -b BAUDRATE, --baudrate BAUDRATE, --bitrate BAUDRATE
                        The baudrate/bitrate to use for serial/can (defaults to 115200 for serial and 500000 for CAN)
  --debug               Turn on debug logs

Upload

uvx pybldc can upload -id 1 -B VESC.bin
uvx pybldc serial upload -p /dev/ttyACM0 -B VESC.bin

Ping

uvx pybldc can ping -id 1
uvx pybldc serial ping -p /dev/ttyACM0

Reset

uvx pybldc can reset -id 1
uvx pybldc serial reset -p /dev/ttyACM0

Increase TX buffer

On Linux you might need to increase the TX buffer size:

sudo ip link set can0 txqueuelen 1000

Credit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybldc-1.1.0.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybldc-1.1.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file pybldc-1.1.0.tar.gz.

File metadata

  • Download URL: pybldc-1.1.0.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pybldc-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1f44f07e00af25594dabe37e3c4c3a292cc147cc679125ba89957bd1f1c5cf29
MD5 bc5379d056f678a6d4328d719c58ee19
BLAKE2b-256 8c2a8a14e4937ff25ad8039e5bdf269aa9aa0f335616672c427720af3b262620

See more details on using hashes here.

File details

Details for the file pybldc-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pybldc-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pybldc-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6d3015c31fa09065baccf85610a3183d0badf7854956713c80e562d698f1e95
MD5 6b755c574b97294f1e602f735956838a
BLAKE2b-256 a737a371903c9b9c167764da1a478f5079b0b6233bb7a6cec94e7668bf03a561

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page