tweterm.py
This program incorporates the pyftdi (https://github.com/eblot/pyftdi) library sample script pyterm.py with a firmware write script for TWELITE. It has the following features
Writing firmware for TWELITE (TWELITE R/MONOSTICK)
Checking the behaviour via the serial port
This script requires the Python3 interpreter to run on OS X. It is intended for users who are familiar with the command line environment and the Python interpreter.
In order to make this script work on Linux, you will need the equivalent packages (libusb-dev, pyserial, pyftdi). It is intended for people who are familiar with the command line environment and the Python interpreter.
reference environment:Ubuntu 16.04 (i386 32bit), Python3.5.2 / Ubuntu 18.04 (x86-64 64bit), Python 3.6.5
Warranty and license
Anything in this package that is not specifically mentioned in the license is governed by the Mono Wireless Software License Agreement.
This software is not officially supported by Mono Wireless Inc. Please note that we may not be able to answer your enquiries. Please understand beforehand.
In response to reports of defects or other problems, Mono Wireless Inc. does not promise to fix or improve the product.
It may not work in all cases, depending on the package you have installed and your environment.
System requirements and required packages
Mac OS X or Linux
python3.5 or later
libusb
pyserial
pyftdi
reference environment
We have developed and tested the software in the following environments. However, we do not guarantee that it will work in these environments.
environment |
---|
Mac OS X 10.11.6, Python3.5.1 (2018/05) |
Ubuntu 18.04, Python3.6.7 (2018/05) |
Mac OS X 10.14.2, Python3.7.2 (2019/01) |
installation
packages
macOS
Below is an example of installing all new packages using Homebrew.
Homebrew
install Homebrew.
Python3
libusb
pyserial
pyftdi
Linux
Please check your distribution's package installation instructions. You will need the following packages.
python3.5 or later (In many cases, it has been introduced)
libusb-dev
pyserial
pyftdi
example for package installation.
実行
The folder where the TWELITE SDK was installed is described as ${TWELITESDK}
.
The script can be found below.
Gives the script permission to run.
If necessary, add it to the PATH environment variable.
Usage
Unload USB driver
Unload the driver as libusb conflicts with the OS driver.
macOS
Unloads FTDI-related drivers.
Linux
No need to unload the driver.
If you get an error, try unloading the driver.
Command parameters
parameter | remark |
---|---|
| Enumerates the list of devices. |
| Specify the device. |
| |
| |
| Specify the baud rate |
| |
| Program the specified firmware. |
| |
| Suppresses colour output of text. |
| It only programs the firmware and does not open the terminal. |
keyboard operation
Typing Ctrl+C will bring up a control prompt, which allows you to perform some special operations. Otherwise, the input string will be sent directly to the TWELITE radio module.
Key sequence | Remark |
---|---|
| quit the terminal |
| Reset TWELITE microcontroller. |
| Enter the |
| Start interpreting the format: for the output from the TWELITE wireless microcontroller and for the key input, the ascii format (like |
| Starts interpreting the format; binary format is interpreted for the output from the TWELITE microcontroller. Key input is interpreted in ASCII format. |
| Stops interpreting the format. |
During format interpretation, only messages from TWELITE that have been interpreted will be displayed, and keyboard input will be echoed back, but will be sent to TWELITE when the ASCII format has been completed.
[Execution example]
In the example, line breaks are inserted as appropriate.
If you get an error, it may be a problem with the permissions on the serial port, run it with root privileges (e.g. sudo
).
Make sure your device is listed first.
Program the firmware and start the terminal
The following example writes App_UART (UART communication app) and checks the boot message.
Typing Ctrl+C will bring up a control prompt
Then enter i. You are now in interactive mode
If you type + + +
three times as usual operation, you will get the same result.
Example of format interpretation: Set App_UART to binary format
In interactive mode, type m
B
Enter
S
in that order.
Examples of format interpretation
In the following example, App_UART does input and output in binary format. Input Ctrl+C
B
.
In this state, input and output is in format. Keyboard input is interpreted as ASCII (input is converted to binary and sent to the TWELITE) and messages from the TWELITE as binary.
Here is an example of receiving a message from TWELITE. The easiest way to do this is to reset the TWELITE. Type Ctrl+C
r
.
The output [dbf...]
is the message from TWELITE, which is actually 0xdb 0xf1 0x67... which is actually a binary sequence.
Conversely, to send a message to TWELITE, enter it in ASCII format. Type :7800112233AABBCCDDX
. This sends the data with a payload of 0x7800112233AABBCCDD to TWELITE in binary format. Immediately afterwards, [dba18001]
is returned as the response.
Quitting
Input Ctrl+C Ctrl+C
to quit terminal.
最終更新