#!/bin/sh if [[ $# -lt 1 || $# -gt 2 ]] then echo 1>&2 echo "Usage: $0 device [mode]" 1>&2 echo 1>&2 echo " Mode Description" 1>&2 echo " ---- -----------" 1>&2 echo " 0 RS232" 1>&2 echo " 1 RS422: No Terminating Resistor" 1>&2 echo " 9 RS422: Terminating Resistor" 1>&2 echo " 13 RS485: Half Duplex, End Unit, Echo" 1>&2 echo " 15 RS485: Half Duplex, End Unit, No Echo" 1>&2 echo " 5 RS485: Half Duplex, Middle Unit, Echo" 1>&2 echo " 7 RS485: Half Duplex, Middle Unit, No Echo" 1>&2 echo " 9 RS485: Full Duplex, End Unit, Master" 1>&2 echo " 13 RS485: Full Duplex, End Unit, Slave" 1>&2 echo " 1 RS485: Full Duplex, Middle Unit, Master" 1>&2 echo " 5 RS485: Full Duplex, Middle Unit, Slave" 1>&2 echo 1>&2 exit 1 fi uart_mode_path=/sys/bus/usb-serial/devices/${1##*/}/uart_mode if [[ ! -f $uart_mode_path ]] then echo "$0: cannot find $uart_mode_path" exit 1 fi if [[ $# -eq 1 ]] then cat $uart_mode_path else echo $2 > $uart_mode_path fi