Digi TX40 User Manual page 810

Table of Contents

Advertisement

Applications
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 = allowed_incoming_phone_number
my_callback = Callback(sms_test_callback, metadata=True)
#send_sms(dest, 'Ready to receive incoming SMS message')
print("Waiting up to 60 seconds for incoming SMS message")
# 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()
os.system('rm -f /var/run/sms/scripts/*') # remove all stored SMS messages,
since we've processed them
print("SMS script finished.
incoming SMS messages")
os._exit(0)
Use Python to access serial ports
You can use the Python serial module to access serial ports on your TX40 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
configuring a serial port in Application mode, and see
configuring USB ports on the device to function as serial ports.
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 TX40 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
by-path
#
3. At the shell prompt, use the python command with no parameters to enter an interactive
Python session:
TX40 User Guide
Please re-run if you want to check for more
Configure Application mode
Add a USB serial port
by-usb
port1
USB_port1
Develop Python applications
for information about
for information about
USB_port2
810

Advertisement

Table of Contents
loading

Table of Contents