![Digi Connect EZ Mini User Manual Download Page 402](http://html.mh-extra.comconnect-ez-mini_user-manual_2496436402.png)
Applications
Use Python to access serial ports
Digi Connect EZ Mini User Guide
402
passed.")
# acquire the semaphore and wait until a callback occurs
COND.acquire()
try:
COND.wait(60.0)
except Exception as err:
print("exception occured while waiting")
print(err)
COND.release()
my_callback.unregister_callback()
Use Python to access serial ports
You can use the Python
serial
module to access serial ports on your Connect EZ device that are
configured to be in Application mode. See
for information about
configuring a serial port in Application mode.
To use Python to access serial ports:
1. Log into the Connect EZ 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
#
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/port1", 115200)
>>> s.write(b"Hello from serial port")
26
>>>
6. Use
Ctrl-D
to exit the Python session. You can also exit the session using
exit()
or
quit()
.