[TAG] 2c tips...
Paul Sephton
paul at inet.co.za
Tue Aug 3 02:09:13 MSD 2004
Dear LinuxGazette
I am the lucky owner of a Palm m515 handheld. One of my frustrations in
the past has been that under Linux, I need to establish a PPP connection
to synchronise my palm with AvantGo web pages, whilst my preference is
to use the normal HotSync button to synchronise the rest of the palm. A
frustration, since I wanted the PPP connecttion to establish
automatically without my having to do anything, but this conflicts with
JPilot Hotsync.
I thought to share the following little bash script with you, which
detects in which mode the Palm is attempting to communicate, and
establishes a PPP link if that is what the Palm is attempting to do.
Otherwise it waits until the Hotsync operation is over and repeats.
I hope that someone finds this useful. By the way, if Palm owners are
experiencing trouble with USB drivers in the later (2.6.7+) kernels, I
suggest they try 2.6.5. The USB support in that version is excellent.
Paul
#!/bin/bash
PIP='xxx.xxx.xxx.xxx' # Palm's IP address
DEV=/dev/ttyUSB1 # ttyUSB Port for comms
PPPD=/usr/sbin/pppd # where is pppd?
BAUD=57600 # BPS Rate for connection
PSTR="Product=Palm Handheld" # String present when palm is attached
# Detect the IP interface and DNS
# This does not use NAT, but I am sure the NATterers will know what to do
#
IF=`/sbin/ifconfig eth0 | grep 'inet addr'`
IP=`echo "$IF" | sed "s/^.*addr://" | cut -f1 -d' '`
MASK=`echo "$IF" | sed "s/^.*Mask://" | cut -f1 -d' '`
DNS=`cat /etc/resolv.conf | grep nameserver | head -1 | sed "s/nameserver //"`
OPT="$BAUD crtscts $IP:$PIP ms-dns $DNS"
OPT="$OPT nopersist noauth passive asyncmap 0"
echo "Listening for palm connection..."
while true; do
PDEV=`cat /proc/bus/usb/devices`
if echo "$PDEV" | grep "$PSTR" > /dev/null; then # Palm wakeup
sleep 2 # wait a bit
CHR=""
FUSR=`/usr/bin/fuser $DEV`
if [ -z "$FUSR" ]; then # Anyone else out there?
CHR=`head -c1 $DEV` # read a character from the device
fi
if [ "$CHR" = "~" ]; then # Initial character for PPP is a tilde
echo "Palm wants to PPP"
PDEVT=`echo "$PDEV" | grep -B4 "$PSTR"`
PDEV_T=`echo "$PDEVT" | grep "^T:"`
echo "$PDEV_T" # some verbosity
sleep 2
echo executing cmd: $PPPD $DEV $OPT
$PPPD $DEV $OPT # exec pppd
else
echo "Palm is HotSynching"
fi
while echo "$PDEV" | grep "$PSTR" > /dev/null; do
PDEV=`cat /proc/bus/usb/devices`
sleep 1 # Just wait for device to go away
done
if [ "$CHR" = "~" ]; then
echo "Done. Killing pppd..." # Kill off our pppd
killall pppd
fi
echo "Listening for palm connection..."
fi
sleep 1
done
That's all, folks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linuxgazette.net/mailman/private/tag/attachments/20040803/07e43bdd/attachment-0001.htm
More information about the TAG
mailing list