Inhaltsverzeichnis

sbserial

Description

sbserial starts the serial terminal program seyon with a preset baud rate on a preset serial port.

The baud rate and port are read from config files located in $HOME/.config/sbserial/<name>. Start the script with the name of the config file as the only parameter eg.:

sbserial usb

If no config file is specified or it cannot be found, sberial expects the baudrate in arg 1 and devicefile in arg 2, eg.:

sbserial 115200 ttyS0

Notes:

Conifg File Examples

#!/bin/bash
# file: $HOME/.config/sbserial/usb
baud='19200'
device='ttyUSB0'
#!/bin/bash
# file: $HOME/.config/sbserial/38400
baud='38400'
device='ttyS0'

Code

#!/bin/bash
# file: /user/local/bin/sbserial
# Usage: See http://wiki.think-deep.com/becki/sources/sbserial
# License: See http://think-deep.com/becki/sources/COPYING
 
CONFDIR="$HOME/.config/sbserial"
SEYONDIR="$HOME/.seyon"
SEYONSCRIPT="$SEYONDIR/sbserial"
 
if [ -f "$CONFDIR/$1" ]; then
    . "$CONFDIR/$1"
else
    if [ "$1" ]; then
        echo "Configfile \"$CONFDIR/$1\" not found!" >&2 ;
    else 
        echo "Configfile not specified!" >&2 ;
    fi
    echo "Expecting baudrate in arg 1 and devicefile in arg 2." >&2 ;
    baud="$1"
    device="$2"
fi
 
if [ ! "$baud" ]; then
    echo "Baudrate not passed!" >&2 ;
    exit 1
fi
 
if [ ! "$device" ]; then
    echo "Devicefile not passed!" >&2 ;
    exit 1
fi
 
echo "Generating config script: $SEYONSCRIPT:" >&2 ;
if [ ! -d $SEYONDIR ]; then
    mkdir $SEYONDIR
fi
echo "set baud $baud" > $SEYONSCRIPT
cat $SEYONSCRIPT
echo "On $device"
 
seyon -noemulator -script sbserial -modems "/dev/$device"