Below is the script I used:start connectstring = '/C=' inputbox 'Enter the COM port number of the optical probe:' 'Optical COM Port' '4' str2int portnumber inputstr if 0result then messagebox 'That was not a valid COM port number, please try again.'
Miniterm¶
- Teraterm macro language is documented at MACRO Help Index.They can be created in any text editor. There is VIM script that provide highlighting for Teraterm - Teraterm MACRO syntax highlighting vim online.The extension used for Teraterm macros is.ttl.you can launch the macro by just cling on the file is the right program is associated with this extension.
- Tera term supports: citation needed Serial port connections over UART. TCP/IP (telnet, SSH1, SSH2) connections. Named pipe connection. IPv6 communication. VT100 emulation and selected VT200/VT300 emulation. TEK4010 emulation. File transfer protocols (Kermit, XMODEM, YMODEM, ZMODEM, B-PLUS and Quick-VAN). Scripts using the 'Tera.
- Choose Serial Port The first thing you’ll want to do is create a new connection to a device. The new connection screen may pop up when you first open it, otherwise select ‘New Connection’ (Alt + N) from the ‘File’ menu. Choose the ‘Serial’ option and then select the appropriate board from the drop-down menu.
Miniterm is now available as module instead of example.see serial.tools.miniterm for details.
- miniterm.py
- The miniterm program.
- setup-miniterm-py2exe.py
- This is a py2exe setup script for Windows. It can be used to create astandalone
miniterm.exe
.
TCP/IP - serial bridge¶
This program opens a TCP/IP port. When a connection is made to that port (e.g.with telnet) it forwards all data to the serial port and vice versa.
This example only exports a raw socket connection. The next examplebelow gives the client much more control over the remote serial port.
- The serial port settings are set on the command line when starting theprogram.
- There is no possibility to change settings from remote.
- All data is passed through as-is.
- tcp_serial_redirect.py
- Main program.
Single-port TCP/IP - serial bridge (RFC 2217)¶
Simple cross platform RFC 2217 serial port server. It uses threads and isportable (runs on POSIX, Windows, etc).
- The port settings and control lines (RTS/DTR) can be changed at any timeusing RFC 2217 requests. The status lines (DSR/CTS/RI/CD) are polled everysecond and notifications are sent to the client.
- Telnet character IAC (0xff) needs to be doubled in data stream. IAC followedby another value is interpreted as Telnet command sequence.
- Telnet negotiation commands are sent when connecting to the server.
- RTS/DTR are activated on client connect and deactivated on disconnect.
- Default port settings are set again when client disconnects.
New in version 2.5.
- rfc2217_server.py
- Main program.
- setup-rfc2217_server-py2exe.py
- This is a py2exe setup script for Windows. It can be used to create astandalone
rfc2217_server.exe
.
Multi-port TCP/IP - serial bridge (RFC 2217)¶
This example implements a TCP/IP to serial port service that works withmultiple ports at once. It uses select, no threads, for the serial ports andthe network sockets and therefore runs on POSIX systems only.
- Full control over the serial port with RFC 2217.
- Check existence of
/tty/USB0...8
. This is done every 5 seconds usingos.path.exists
. - Send zeroconf announcements when port appears or disappears (usespython-avahi and dbus). Service name:
_serial_port._tcp
. - Each serial port becomes available as one TCP/IP server. e.g.
/dev/ttyUSB0
is reachable at<host>:7000
. - Single process for all ports and sockets (not per port).
- The script can be started as daemon.
- Logging to stdout or when run as daemon to syslog.
- Default port settings are set again when client disconnects.
- modem status lines (CTS/DSR/RI/CD) are not polled periodically and the servertherefore does not send NOTIFY_MODEMSTATE on its own. However it responds torequest from the client (i.e. use the
poll_modem
option in the URL whenusing a pySerial client.)
Requirements:
- Python (>= 2.4)
- python-avahi
- python-dbus
- python-serial (>= 2.5)
Installation as daemon:
- Copy the script
port_publisher.py
to/usr/local/bin
. - Copy the script
port_publisher.sh
to/etc/init.d
. - Add links to the runlevels using
update-rc.dport_publisher.shdefaults99
- That’s it :-) the service will be started on next reboot. Alternatively run
invoke-rc.dport_publisher.shstart
as root.
New in version 2.5: new example
- port_publisher.py
- Multi-port TCP/IP-serial converter (RFC 2217) for POSIX environments.
- port_publisher.sh
- Example init.d script.
wxPython examples¶
A simple terminal application for wxPython and a flexible serial portconfiguration dialog are shown here.
- wxTerminal.py
- A simple terminal application. Note that the length of the buffer islimited by wx and it may suddenly stop displaying new input.
- wxTerminal.wxg
- A wxGlade design file for the terminal application.
- wxSerialConfigDialog.py
- A flexible serial port configuration dialog.
- wxSerialConfigDialog.wxg
- The wxGlade design file for the configuration dialog.
- setup-wxTerminal-py2exe.py
- A py2exe setup script to package the terminal application.
Unit tests¶
The project uses a number of unit test to verify the functionality. They allneed a loop back connector. The scripts itself contain more information. Alltest scripts are contained in the directory test
.
The unit tests are performed on port loop://
unless a different devicename or URL is given on the command line (sys.argv[1]
). e.g. to run thetest on an attached USB-serial converter hwgrep://USB
could be used orthe actual name such as /dev/ttyUSB0
or COM1
(depending on platform).
- run_all_tests.py
- Collect all tests from all
test*
files and run them. By default, theloop://
device is used. - test.py
- Basic tests (binary capabilities, timeout, control lines).
- test_advanced.py
- Test more advanced features (properties).
- test_high_load.py
- Tests involving sending a lot of data.
- test_readline.py
- Tests involving
readline
. - test_iolib.py
- Tests involving the
io
library. Only available for Python 2.6 andnewer. - test_url.py
- Tests involving the URL feature.
Tera Term (Windows)
Serial Port Arduino
Tera Term is one of the more popular Windows terminal programs. It's been around for years, it's open source, and it's simple to use. For Windows users, it's one of the best options out there.
You can download a copy from here. Once you have Tera Term installed, open up it up, and let's poke around.
Making a Connection
You should initially be presented with a 'TeraTerm: New connection' pop-up within the program. Here, you can select which serial port you'd like to open up. Select the 'Serial' radio button. Then select your port from the drop-down menu. (If this window doesn't open when you start TeraTerm, you can get here by going to ****File > New connection...'**.)
That'll open up the port. TeraTerm defaults to setting the baud rate at 9600 bps (8-N-1). If you need to adjust the serial settings, go up to Setup > Serial Port. You'll see a window pop up with a lot of familiar looking serial port settings. Adjust what you need to and hit 'OK'.
The title of your TeraTerm window should change to something like 'COM##:9600baud' -- good sign.
Parallel Port
That's about all there is to it. The blank window with the blinking cursor is where data is both sent (by typing it in) and received.
TeraTerm Tips and Tricks
Local Echo
It can be weird to type stuff in the window and not see it show up in the terminal. It's undoubtedly still flowing through the serial terminal to your device, but it can be difficult to type when you don't have any visual feedback for exactly what you're typing. You can turn on local echo by going to the Setup menu and selecting Terminal.
Check the Local echo box if you'd like to turn the feature on.
There are other settings to be made in this window as well. You can adjust the size of the terminal (the values are in terms of characters per row/column), or adjust how new-lines are displayed (either a carriage return, line feed, or both).
Clear Buffer and Clear Screen
If you want to clear your terminal screen you can use either the 'Clear buffer' or 'Clear screen' commands. Both are located under the Edit menu.
Clear screen will do just that, blank out the terminal screen, but any data received will still be preserved in the buffer. Scroll up in the window to have another look at it. Clear buffer deletes the entire buffer of received data -- no more data to scroll up to.
Shortcut Keys
Teraterm Macro Manual
Menus are a pain! If you want to get really fast with TeraTerm, remember some of these shortcuts:
- ALT+N: Connects to a new serial port.
- ALT+I: Disconnects from the current port.
- ALT+V: Pastes text from clipboard to the serial port (not CTRL+V).
- ALT+C: Copy selected text into clipboard (not CTRL+C).
- CTRL+TAB: Switch between two TeraTerm windows.
Teraterm Script Serial Port Chester
Hyperterminal (Windows)