Comment 3 for bug 39526

Revision history for this message
Mohit Soni (spmsrh) wrote :

I have exaclty the saem problem. To be honest the script does nothing. it does not configure the serial port of the stylus or anything else. So nothing at all happens.

Here is the original script
. /lib/lsb/init-functions

if [ ! -d /sys/bus/pnp/devices ]; then exit; fi

cd /sys/bus/pnp/devices

case $1 in
    start|restart|reload|force-reload)
    log_begin_msg "Doing Wacom setup..."
    for x in *; do
        PORT=unknown;
        for y in `cat $x/id`; do
            case "$y" in
                WACf006*|WACf005*|WACf004*)
                PORT=/dev/`echo $x/tty:* | awk -F: '{print $3}'`
                echo "PORT is $PORT"
                ln -sf $PORT /dev/wacom
                ;;
            esac
        done
    done
    log_end_msg 0;
    ;;
    stop)
    exit 0;
    ;;
esac

and here is the replacement
. /lib/lsb/init-functions
cd /sys/bus/pnp/devices
DEVICENUM=0 # First serial port to try
WACOMNUM=0

case $1 in
    start|restart|reload|force-reload)
    log_begin_msg "Doing Wacom setup..."
    for x in *; do
        TYPE=none;
        PORT=unknown;
        CONFIGURED=0;
        for y in `cat $x/id`; do
            case "$y" in
                WACf006*|WACf005*|WACf004*)
                echo found device in $x and has id $y
            # Ensure that the device is enabled
                echo "activate" >$x/resources
            # And now figure out what port and IRQ it's on
                IOPORT=`grep io $x/resources | sed -e 's/io \(.*\)-.*/\1/'`
                echo "has IOPORT=$IOPORT"
                IRQ=`grep irq $x/resources | sed -e 's/irq \(.*\)/\1/'`
                echo "has IRQ=$IRQ"
                while [ "$CONFIGURED" = "0" ]; do
                    DEVICE="/dev/ttyS$DEVICENUM"
                    UART=`setserial -G $DEVICE | awk '{print $3}'`
                    echo "For device $DEVICE, UART=$UART"
                    if [ "$UART" = "unknown" ]; then
                    # Found an unused serial port
                        setserial $DEVICE port $IOPORT irq $IRQ autoconfig
                        if [ ! -e /dev/wacom$WACOMNUM ]; then
                            ln -s $DEVICE /dev/wacom$WACOMNUM
                        fi
                        let "WACOMNUM=$WACOMNUM+1";
                        CONFIGURED=1;
                    fi
                    let "DEVICENUM=$DEVICENUM+1";
                done;
            esac
        done
    done
    log_end_msg 0;
    ;;
    stop)
    exit 0;
    ;;
esac

I also changed the stylus device in xorg.conf from /dev/wacom to /dev/wacom0 to reflect this change.

I have not tested this script with USB based stylus. And also, it fails if I configure the stylus using setserial manually to another device. In that case it maps /dev/wacom0 to /dev/ttyS1 and things go haywire.