Digi IX30 User Manual page 668

Table of Contents

Advertisement

Applications
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:
# python
Python 3.10.1 (default, May
[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().
Use the Paho MQTT python library
Your IX30 device includes support for the Paho MQTT python library. MQTT is a lightweight messaging
protocol used to communicate with various applications including cloud-based applications such as
Amazon Web Services and Microsoft Azure. The following is example code that reads CPU and RAM
usage on the device, updates the device firmware, then publishes information about DHCP clients and
system information to the MQTT server at 192.168.1.100. The MQTT server IP is configurable.
"""
MQTT client example:
- Reporting some device metrics from runt
- Reporting DHCP clients
- Firmware update feature (simple implementation, read TODO in cmd_fwupdate)
"""
import sys
import time
import paho.mqtt.client as mqtt
import json
from acl import runt, config
from http import HTTPStatus
import urllib.request
import tempfile
IX30 User Guide
by-path
by-usb
port1
Use Python to control the color of multi-colored LEDs
9 2021, 22:49:59)
668

Advertisement

Table of Contents
loading

Table of Contents