Use Python To Access Serial Ports - Digi IX10-00G4 User Manual

Table of Contents

Advertisement

Applications
def sms_test_callback(sms, info):
print(f"SMS message from {info['content.number']} received")
print(sms)
print(info)
COND.acquire()
COND.notify()
COND.release()
def send_sms(destination, msg):
print("sending SMS message", msg)
if len(destination) == 10:
destination = "+1" + destination
send(destination, msg)
if __name__ == '__main__':
if len(sys.argv) > 1:
dest = sys.argv[1]
else:
dest = '+15005550006'
my_callback = Callback(sms_test_callback, metadata=True)
send_sms(dest, 'Hello World!')
print("Please send an SMS message now.")
print("Execution halted until a message is received or 60 seconds have
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 IX10 device that are configured to
be in Application mode. See
port in Application mode.
To use Python to access serial ports:
1. Select a device in Remote Manager that is configured to allow shell access to the admin user,
and click Actions > Open Console. Alternatively, log into the IX10 local 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
#
3. At the shell prompt, use the python command with no parameters to enter an interactive
Python session:
IX10 User Guide
Configure Application mode
by-path
by-usb
port1
for information about configuring a serial
Python modules
559

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ix10Ix10-00n4

Table of Contents