This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-07-24

Flashing Firmware with Python

Python module for flashing TWELITE firmware (beta version)
The tweliter module is a Python module for flashing firmware to TWELITE devices. It can be installed via PyPI and used as a command-line tool or controlled from Python scripts.

1 - Flashing Firmware with Python

Latest Edition

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 Script

Use an instance of the Tweliter class.

from pathlib import Path
from tweliter import Tweliter

file = Path("firmware/SomeApp_BLUE.bin")

try:
    with Tweliter(
        type_filter=Tweliter.Type.TWELITE_R2 | Tweliter.Type.TWELITE_R3
    ) 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"))
except IOError as e:
    print(f"Couldn't connect {e}")
except RuntimeError as e:
    print(f"Failed to write {e}")

2 - 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}")

3 - Flashing Firmware with Python

v0.4.0

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

Please install from PyPI.


pip install tweliter

If you use Poetry:


poetry add tweliter

Additional Notes for Linux

Additional Notes for Windows

Examples

As a Command-Line Tool

Specify the binary file (.bin) after tweliter.


tweliter dir/SomeApp_BLUE.bin

From a Python Script

Use an instance of the Tweliter class.

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"))
except IOError as e:
    print(f"Cannot connect {e}")
except RuntimeError as e:
    print(f"Failed to write {e}")