/      日本語

Flashing Firmware with Python

v0.3.7

Overview

The tweliter module is a Python module for flashing firmware to TWELITE devices.

It can be installed from PyPI, used as a command-line tool, or controlled from Python scripts.

Installation

Install it from PyPI:


pip install tweliter

With Poetry:


poetry add tweliter

Additional Notes for Linux

Additional Notes for Windows

Examples

As a Command-Line Tool

Specify a .bin binary file after tweliter:


tweliter dir/SomeApp_BLUE.bin

From a Python Script

from pathlib import Path
from tweliter import Tweliter

file = Path('dir/SomeApp_BLUE.bin')

try:
    with Tweliter(url="ftdi://:ft-x:/1") as liter:
        # Get serial interface
        ser = liter.get_serial_instance()
        # Write firmware
        liter.write(ser, file, verify=True)
        # Show startup message
        print(liter.get_startup_message_after(ser, "!INF MONO WIRELESS"))
except IOError as e:
    print(f"Cannot connect {e}")
except RuntimeError as e:
    print(f"Failed to write {e}")