#!/bin/sh /etc/rc.common

START=99
STOP=99

boot(){
    if [ ! -d "/sys/class/gpio/gpio11" ]; then
        #echo "Set DTR input"
        echo 11 > /sys/class/gpio/export
        echo in > /sys/class/gpio/gpio11/direction
    fi
    if [ ! -d "/sys/class/gpio/gpio12" ]; then
        #echo "Set DCD output"
        echo 12 > /sys/class/gpio/export
        echo out > /sys/class/gpio/gpio12/direction
        echo 0 > /sys/class/gpio/gpio12/value
    fi
    if [ ! -d "/sys/class/gpio/gpio13" ]; then
        #echo "Set DSR output"
        echo 13 > /sys/class/gpio/export
        echo out > /sys/class/gpio/gpio13/direction
        echo 0 > /sys/class/gpio/gpio13/value
    fi
    if [ ! -d "/sys/class/gpio/gpio14" ]; then
        #echo "Set RI output"
        echo 14 > /sys/class/gpio/export
        echo out > /sys/class/gpio/gpio14/direction
        echo 0 > /sys/class/gpio/gpio14/value
    fi
}

start(){
    echo DTR value `cat /sys/class/gpio/gpio11/value`
    echo DCD value `cat /sys/class/gpio/gpio12/value`
    echo DSR value `cat /sys/class/gpio/gpio13/value`
    # Enable RI output and send HELLO
    echo 0 > /sys/class/gpio/gpio14/value
    echo "Snap Cap (enable==0): $(cat /sys/class/gpio/gpio14/value)"
    echo "HELLO" > /dev/ttyS1
}

stop() {}