Git Product home page Git Product logo

pybldc's Introduction

pybldc

Developed by Kristian Sloth Lauszus, 2024

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


PyPI CI

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:

pip3 install -U pybldc

CLI

A handy CLI tool is included:

$ pybldc -h
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

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

Ping

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

Reset

pybldc can reset -id 1
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

pybldc's People

Contributors

lauszus avatar

Stargazers

Floatyboy avatar  avatar Sven Wikström avatar

Watchers

 avatar

pybldc's Issues

Figure out how to block until the message is sent or determine if the buffer is full

Currently I have just put in a small sleep

pybldc/pybldc/pybldc.py

Lines 474 to 476 in e02ac6d

# Just sleep a minimal time, so the CAN buffer does not get full
# TODO: Figure out how to block until the message is sent or determine if the buffer is full
time.sleep(0.0001)

Instead it should just block if the queue is full.

Related issue: hardbyte/python-can#1416

There are also more related issues: https://github.com/hardbyte/python-can/issues?q=is%3Aissue+is%3Aopen+buffer

Might be possible to use this: https://github.com/hardbyte/python-can/blob/451ce48eacd529453c14ec59fe6bc5d142f2e65a/can/interfaces/socketcan/socketcan.py#L51-L481

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.