wacom-tools init.d script is broken

Bug #39526 reported by lcampagn
14
Affects Status Importance Assigned to Milestone
wacom-tools (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

The last update I did of wacom-tools (1:0.7.2-0ubuntu4) stopped the pen working on my
tablet (a tc4200 tablet PC, wacdump calls it an "acer c100 tablet pc screen"). I did a little investigating and found that the init scrip was no longer configuring my serial port correctly. The problem code seems to be this bit:
  PORT=/dev/`echo $x/tty:* | awk -F: '{print $3}'`
  ln -sf $PORT /dev/wacom

My limited understanding of shell scripting tells me this can't possibly
work: $x usually looks something like "00:04", so the echo command
should output "00:04/tty:*", and then the awk command will chop that
down to "*". I can't imagine this bit of code working under any
circumstances, so I'm pretty sure there's something wrong here.. I
checked, and when the script is run, that second command does turn out
as "ln -sf /dev/* /dev/wacom".

Additionally, there is no longer any IO port or IRQ setting as there used to be. I have restored the old init script and it still works just fine.

Luke

Revision history for this message
lcampagn (luke-campagnola) wrote :

I should clarify that the real problem with the init script is not that it doesn't create the /dev/wacom symlink as I had discussed, but rather that it makes no attempt to configure the serial port at all.

Revision history for this message
T-Bone (varenet) wrote :

exact same issue on my tc4200 too. The script is definitely broken:

$ sudo /etc/init.d/wacom-tools start
 * Doing Wacom setup... ln: target `/dev/wacom' is not a directory
                                                                         [ ok ]

Note that it doesn't even detect its own failure...

HTH

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.

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

I forgot to add, please remove the echo statements, I used them for my own debugging and had left them there

Changed in wacom-tools:
status: Unconfirmed → Confirmed
Revision history for this message
Sven Herzberg (herzi) wrote :

Your script is broken. It's likely to re-introduce the same error that the old script had when it didn't detect any devices. This script is DANGEROUS (as in "an end user will only see lots of '/dev/ttySn: file or directory not found' errors").

Attaching the one I am using on my machine (which only checks existing devices).

Revision history for this message
Sven Herzberg (herzi) wrote : Proposed script

both fixes this error and doesn't introduce an old one

Revision history for this message
Sven Herzberg (herzi) wrote :

You might want to add setting the CONFIGURED variable to one on success and check it for potential warnings.

Revision history for this message
Matthew Garrett (mjg59) wrote :

The kernel should be doing the setup now. Can you test with the latest kernel and the stock init script?

Revision history for this message
T-Bone (varenet) wrote : Re: [Bug 39526] Re: wacom-tools init.d script is broken

works for me, thanks!

On 5/3/06, Matthew Garrett <email address hidden> wrote:
> The kernel should be doing the setup now. Can you test with the latest
> kernel and the stock init script?
>
> --
> wacom-tools init.d script is broken
> https://launchpad.net/bugs/39526
>

--
Thibaut VARENE
http://www.parisc-linux.org/~varenet/

Revision history for this message
Wouter (woutervanwijk-netscape) wrote :

In Flight 7 on my computer, it is detected, but it is not configured properly in xorg.conf . The xorg.conf entry for the wacom tablet points to /dev/wacom, but there is no /dev/wacom at all.

Revision history for this message
Matthew Garrett (mjg59) wrote :

Then it's not detected properly. What sort of hardware are you talking about?

Revision history for this message
Wouter (woutervanwijk-netscape) wrote :

It's a Graphire usb. When using the Flight 7 live-cd, the symlink /dev/wacom is not available. This is my wacdump output:

MODEL=Wacom Graphire ROM=1.1-1
CLS=USB VNDR=Wacom DEV=Graphire SUB=ET_0405

Revision history for this message
Sascha Silbe (sascha-ubuntu-launchpad) wrote :

I had the same problem as Wouter. Checking /etc/udev/rules.d/65-wacom.rules showed that udev creates a symlink /dev/input/wacom, not /dev/wacom. After changing /etc/X11/xorg.conf to use /dev/input/wacom instead of /dev/wacom, it works fine so far.

Revision history for this message
Loïc Martin (loic-martin3) wrote :

Wouter, Sasha,

This seems fixed now. The bug about /dev/input/wacom created instead of /dev/wacom is an old longstanding bug.

You should now check if /dev/input/wacom is created (should be). See Bug #40473 for news about that.

Since the initial bug seems closed, I'll close the bug but you are free to reopen it in case even /dev/input/wacom isn't created

Changed in wacom-tools:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.