Skip to main content

canbus-stepper

Python client library for the thingsbyjosh.com CANBUS Stepper Motor Controller (ESP32-S3 + TMC2209 + MT6701). Talk to a node over USB serial or over WiFi (WebSocket) through the exact same high-level API -- only how you construct the CANBus differs.

Install

pip install canbus-stepper

Usage

from canbus_stepper import CANBus

# USB serial
with CANBus.serial("COM3") as bus:
    node1 = bus.node(1)
    node1.set_acceleration(720.0)
    node1.set_deceleration(720.0)
    node1.set_position_speed(360.0)
    node1.enable()
    node1.set_position(180.0)

# WiFi -- the node must already be joined to your network via the Web
# GUI's "Configure WiFi" dialog over USB first; WIFI_SET is USB-only.
with CANBus.websocket("canbus-stepper-1.local") as bus:
    node1 = bus.node(1)
    node1.set_position(180.0)

    angle = node1.get_angle()
    voltage = node1.get_voltage()

    # Broadcast to every node on the bus
    bus.broadcast.estop()

Connection failures (bad port/hostname, node offline, nothing listening, etc.) raise canbus_stepper.CANBusConnectionError with a plain-English message instead of a raw socket/serial traceback -- and no try/except is needed to get that clean behavior. CANBusConnectionError is a SystemExit subclass, so if you leave it uncaught, Python just prints its message and exits (the same as sys.exit(message)), not a traceback:

from canbus_stepper import CANBus

with CANBus.websocket("canbus-stepper-1.local") as bus:   # exits cleanly if this fails
    ...

Catch it yourself only if you want different behavior, e.g. a retry:

from canbus_stepper import CANBus, CANBusConnectionError

try:
    bus = CANBus.websocket("canbus-stepper-1.local")
except CANBusConnectionError as e:
    print(f"Could not connect: {e}")

See MsgType, StandstillMode, and AuxFunction in canbus_stepper for the full set of protocol constants, and the "Control Interface Examples" folder for complete runnable examples of both transports.

Protocol

  • 11-bit CAN Standard ID encodes NodeID (5 bits) and MsgType (6 bits): CAN_ID = (NodeID << 6) | MsgType
  • Line protocol: "<CAN_ID_hex> <RTR> <payload_16hex_chars>"
  • All multi-byte values are little-endian
  • NodeID 0 = broadcast to all nodes

See CAN Protocol.md in the project for the full protocol reference.

Publishing (maintainer notes)

pip install build twine
python -m build
twine upload dist/*

Metadata

Release files for canbus-stepper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for canbus-stepper 0.1.1
File Size Uploaded Provenance Actions
canbus_stepper-0.1.1.tar.gz 10.9 kB Without provenance Details for canbus_stepper-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for canbus-stepper 0.1.1
File Interpreter ABI Platform Actions
canbus_stepper-0.1.1-py3-none-any.whl Python 3 none any Details for canbus_stepper-0.1.1-py3-none-any.whl

Total release size: 24.4 kB

Release files / canbus_stepper-0.1.1.tar.gz

Download URL canbus_stepper-0.1.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
423037a8af765e29434f6fe9d06b5e1f0066357f648c0afb449a117883eba7ed
BLAKE2b-256 checksum
How to use checksums
09da5d0f8df5951ef597fd7abec50079674a469bbdc434bfa8bd0106a100ec6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / canbus_stepper-0.1.1-py3-none-any.whl

Download URL canbus_stepper-0.1.1-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23219fc45873190717ec042780adc1f6a4ed58137dd0da2e421078761b327fe2
BLAKE2b-256 checksum
How to use checksums
721493f6032add2060a7689aeb4271fd101261ad4d1da5ca72c462e23b272487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Security for canbus-stepper 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page