Skip to content

int-brain-lab/tycmd-wrapper

Repository files navigation

tycmd-wrapper

A Python wrapper for tycmd by Niels Martignène - a tool for managing Teensy USB Development Boards by PJRC.

Examples

Identifying a firmware file

To identify which models are compatible with a specific firmware file, use the identify() method.

import tycmd
compatible_models = tycmd.identify('blink.hex')

Models compatible with the firmware file will be returned as a list of strings:

['Teensy 4.0', 'Teensy 4.0 (beta 1)']

List Available Boards

To list all available boards, use the list_boards() method.

import tycmd
boards = list_boards()

Details for the available boards will be returned as a list of python dictionaries.

[
    {
        'action': 'add',
        'tag': '3576040-Teensy',
        'serial': '3576040',
        'description': 'USB Serial',
        'model': 'Teensy 3.1',
        'location': 'usb-1-4',
        'capabilities': ['unique', 'run', 'reboot', 'serial'],
        'interfaces': [['Serial', '/dev/ttyACM1']],
    },
    {
        'action': 'add',
        'tag': '14014980-Teensy',
        'serial': '14014980',
        'description': 'USB Serial',
        'model': 'Teensy 4.0',
        'location': 'usb-1-3',
        'capabilities': ['unique', 'run', 'rtc', 'reboot', 'serial'],
        'interfaces': [['Serial', '/dev/ttyACM0']],
    },
]

Uploading a firmware file

To upload a firmware file to a board, use the upload() method. You can specify a board by its port or by its serial number.

import tycmd
import logging

logging.basicConfig(level=logging.INFO)
tycmd.upload('blink.hex', port='/dev/ttyACM0')

The upload progress will be logged:

INFO:tycmd:Uploading to board '14014980-Teensy' (Teensy 4.0)
INFO:tycmd:Triggering board reboot
INFO:tycmd:Firmware: blink40.hex
INFO:tycmd:Flash usage: 19 kiB (1.0%)
INFO:tycmd:Uploading...
INFO:tycmd:Sending reset command (with RTC)

Full Documentation

The full API documentation is available here.

License Coverage CI PyPI