Applications
Use Python to access serial ports
TX54 User Guide
718
DeviceInfo
builtins.Exception(builtins.BaseException)
HIDException
builtins.object
Device
...
>>>
5. Use
Ctrl-D
to exit the Python session. You can also exit the session using
exit()
or
quit()
.
Use Python to access serial ports
You can use the Python
serial
module to access serial ports on your TX54 device that are configured
to be in Application mode. For example, you can configure USB ports to function serial ports and
interact programmatically with those ports. See
for information about
configuring a serial port in Application mode, and see
for information about
configuring USB ports on the device to function as serial ports.
To use Python to access serial ports:
1. Log into the TX54 command line as a user with shell access.
Depending on your device configuration, you may be presented with an
Access selection
menu
. Type
shell
to access the device shell.
2. Determine the path to the serial port:
# ls /dev/serial/
by-id
by-path
by-usb
port1
USB_port1
USB_port2
#
3. At the shell prompt, use the
python
command with no parameters to enter an interactive
Python session:
# python
Python 3.6.13 (default, May
9 2021, 22:49:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
4. Import the
serial
module:
>>> import serial
>>>
5. You can now perform operations on the serial port. For example, to write a message to the
serial port:
>>> s = serial.Serial("/dev/serial/USB_port1", 115200)
>>> s.write(b"Hello from USB serial port")
26
>>>
6. Use
Ctrl-D
to exit the Python session. You can also exit the session using
exit()
or
quit()
.
Summary of Contents for TX54
Page 1: ...TX54 User Guide Firmware version 22 2 ...
Page 190: ...Interfaces Bridging TX54 User Guide 190 ...
Page 293: ...Hotspot Hotspot configuration TX54 User Guide 293 ...
Page 332: ...Hotspot Show hotspot status and statistics TX54 User Guide 332 ...
Page 584: ...Services Simple Network Management Protocol SNMP TX54 User Guide 584 4 Click Download ...