Serial Port Scripting

The following examples use Ubuntu 18.04 Linux OS and the USB-Serial COM Port on SynLink Controller Device file is identified as /dev/ttyUSB0 with dmesg

Get tty configuration:

stty -F /dev/ttyUSB0


Change baud rate:

stty -F /dev/ttyUSB0 115200


Write to Serial Port:

echo "system status" > /dev/ttyUSB0


Read from Serial Port:

cat /dev/ttyUSB0


Set Outlet Off

Configure tty with appropriate configurations beforehand

Identify outlet ID beforehand by printing list of outlets: system outlet status

Requires pre login to be able to issue commands.

user@host:~$ echo "system outlet set outlet_state 1-100001 OFF" > /dev/ttyUSB0

or

user@host:~$ sudo sh -c "echo 'system outlet set outlet_state 1-100001 OFF' >> /dev/ttyUSB0"