USB Syncing a Visor

|
I'm just trying to get all my crap together for linux palm development. I'm working on USB hotsyncing. The support is there but with some idiosyncracies. I was haxxor and successfull. My kind of night. Details...

First you have to get USB stuff into the kernel. From 'make menuconfig' I'm using version 2.4.2 right now. <*> Support for USB [ ] USB verbose debug messages --- Miscellaneous USB options [*] Preliminary USB device filesystem --- USB Controllers <*> UHCI Alternate Driver (JE) support < > OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support --- USB Device Class drivers < > USB Audio support < > USB Mass Storage support < > USB Modem (CDC ACM) support < > USB Printer support --- USB Human Interface Devices (HID) --- Input core support is needed for USB HID --- USB Imaging devices < > USB Kodak DC-2xx Camera support < > USB Scanner support --- USB Multimedia devices < > DABUSB driver --- USB Network adaptors --- USB port drivers USB Serial Converter support ---> --- USB misc drivers Also go into USB serial converter support and do the following <*> USB Serial Converter support [*] USB Serial Converter verbose debug [*] USB Generic Serial Driver < > USB Digi International AccelePort USB Serial Driver <*> USB Handspring Visor Driver Then rebuild, install, and reboot your new kernel. As far as sync and PIM software. There's a couple of options out there. I went with the ones that seemed to have momentum. pilot-link is hotsync software and libraries (it has an sibling coldsync that has made major contributions to the general code pool). Pilot-link has preliminary support for USB. Widespread devfs use will help. Remember when glibc2 first came out? :) http://pilot-link.sourceforge.net http://www.ooblick.com/software/coldsync/ root@synergy:~/pilot-link# ./configure --prefix=/usr/local/pilot-link-cvs root@synergy:~/pilot-link# make root@synergy:~/pilot-link# make install gnome-pilot is a gnome utility that uses pilot-link. It even has a few conduits builtin and plenty of sample conduit code. I'm still looking for the PIM conduits. Very slick. Needs some work in troubleshooting bad palm connections. root@synergy:~/gnome-pilot-0.1.55#./configure --prefix=/usr/local/gnome --enable-usb-visor=yes --with-pisock=/usr/local/pilot-link/ root@synergy:~/gnome-pilot-0.1.55# make root@synergy:~/gnome-pilot-0.1.55# make install Once you have the usb stuff working right gnome-pilot is a snap. Just add the applet to your gnome bar and away you go. pilot-link is more articulate. Try this to list all the files on your palm..... root@synergy:~# pilot-xfer -p /dev/ttyUSB1 -l Port: /dev/ttyUSB1 Please press the HotSync button now... Connected... Reading list of databases in RAM... 'CityTimeDB' 'Datebk3HDB' 'HSAdvCalcDB' 'AddressDB' 'DatebookDB' [etc.] The way pilot sync was setup you had to push hotsync first then run the program. I hated it. I wanted the program to poll until I decided to push the button. My hackomatic fix is below. It doesn't make a whole lot of difference if you use gnome-pilot. It seems to handle the usb stuff just fine b/c it has a daemon running.


From       James Weller 
Date       Saturday, April 7, 2001 0:35 am
To         pilot-unix@hcirisc.cs.binghamton.edu
Subject    pi_serial_open USB Visor Hack

 All,
 This is my hacked up version of libsock/unixserial.c:pi_serial_open . It
 is linux specific and probably butt ugly, but it works for me and should
 spawn a brainchild.

 All it does is check /proc/bus/usb/devices for the string
 Product=Handspring Visor usb_wait_count times. During that time you get
 .... feedback. Press the hotsync button in under usb_wait_count and you
 get the goods. This probably will break non-usb/non-linux systems.

 I got the idea when my gnome-pilot wouldn't work because I forgot to
 compile in usbdevfs. Trip huh?

 Diff what?
 Jim Weller


 libsock/unixserial.c:pi_serial_open
 --------------------------------------------------------------------

 int
 pi_serial_open(struct pi_socket *ps, struct pi_sockaddr *addr, int
 addrlen)
 {
    char *tty = addr->pi_device;
    int i;





 /* begin jim weller Fri Apr 6 14:34:16 AKDT 2001 */
 char line[256]; /* this is more than enough to fit any line from 
          * /proc/bus/usb/devices */
 int visor_exists = 0;
 FILE *f;
 int usb_wait_count = 10;
 /* end jim weller */







 #ifndef SGTTY
    struct termios tcn;
 #else
    struct sgttyb tcn;
 #endif

    if ((!tty) || !strlen(tty))
       tty = getenv("PILOTPORT");
    if (!tty)
       tty = "";




 /* begin jim weller Fri Apr 6 14:34:16 AKDT 2001*/
 /* block until a device becomes available */
 /* give ..... feedback */
 printf("Push hotsync button now. Waiting %d seconds for USB visor
 device
 
", usb_wait_count);
 while( visor_exists == 0 && usb_wait_count > 0 ){
   f = fopen ("/proc/bus/usb/devices", "r");
   fgets (line, 255, f);
   while (!feof (f)) {
     if (line[0] == 'S') {
       if (!strncmp (line + 4, "Product=Handspring Visor", 24)) {
     visor_exists = 1;
     break;
       }
     }
     fgets (line, 255, f);
   }
   fclose (f);
   printf(".");
   fflush(stdout);
   sleep(1);
   usb_wait_count--;
 }
  if( visor_exists == 0 ){
    printf("
Hotsync not pressed or no Visor found on port
");
    return -1;
  }
 /* end jim weller Fri Apr 6 14:34:16 AKDT 2001*/




    if ((ps->mac->fd = open(tty, O_RDWR | O_NONBLOCK)) == -1) {
       return -1; /* errno already set */
    }




 /* crazy hack by Chris Hanson cph@zurich.ai.mit.edu */
 /* much criticized on the list, but effective :) */
 /* while ((ps->mac->fd = open(tty, O_RDWR | O_NONBLOCK)) == -1) { */
 /* if (errno != ENODEV) */
 /* return -1; */
 /* printf("No Device. Sleeping for 1 sec... (hack)
"); */
 /* sleep (1); */
 /* } */





    if (!isatty(ps->mac->fd)) {
       close(ps->mac->fd);
       errno = EINVAL;
       return -1;
    }

[...snip...]