Macintosh PowerBook


Apple Macintosh PowerBook G3


How-to
Partition your hard disk
Configure X windows
Configure AfterStep
Make the PowerBook sleep
Set up the modem for PPP
HotSync a Palm Pilot via IrDA
Go wireless!


Links
J-Pilot
The Palm Desktop-like application
The IrDA Home Page
Linux IR HOWTO
Linux-IrDA Home Page
Palm Computing
Palm OS Desktop HOWTO
pilot-link
Linux HotSync software

Configuring IrDA

The IrDA (infrared) port on the back of the PowerBook can be used for a number of things. This page specifically describes how to use it to HotSync a Palm Pilot.

There are several steps to get IrDA up and running:

Having kernel support
In order to do IrDA, you need a kernel version 2.2.17 or later and have the following options set in the kernel configuration:
Option Setting    Found under
CONFIG_MAC_SERIAL   yGeneral setup
CONFIG_SERIAL mCharacter devices
CONFIG_IRDA mIrDA (infrared) support
CONFIG_IRCOMM m   "
CONFIG_IRTTY_SIR m   "
Additionally, you also need to add the following lines to /etc/modules.conf:
    alias char-major-161  ircomm-tty
    alias tty-ldisc-11    irtty
    post-install          irda  /usr/sbin/irattach /dev/irda
    pre-remove            irtty /usr/bin/killall -q irattach

Setting up the IrDA port
The first thing you might want to do is create the IrDA device /dev/irda by doing:
    ln -s ttyS1 /dev/irda
The reason I said "might" is because you don't have to do it: in everything that's below, you can simply use /dev/ttyS1 instead; however, using /dev/irda is clearer.

If it's not already there, you need to create the device to use the IrCOMM protocol (which is what is used by the Pilot):
    mknod /dev/ircomm0 c 161 0
    chgrp tty /dev/ircomm0
    chmod 666 /dev/ircomm0
    ln -s ircomm0 /dev/pilot
Unlike the previous symbolic link, /dev/pilot is actually the default device used to access the Pilot by Pilot-related software, so having it simplifies configuration and use.


Getting and configuring the necessary the software
The irda-utils package provides the basic software to access the IrDA port. For HotSync'ing a Pilot, you only need irattach. You should not run irmanager since doing so will commandeer the IrDA port and make it inaccessible as a plain serial device.

The pilot-link package provides the software to do the HoySync'ing itself. The only configuration necessary is to set the following environment variable (bash syntax shown):
    export PILOTRATE=115200

The J-Pilot package provides a nice, simple Palm Desktop application similar to Palm's MacPac version 1 (which I actually like much better than version 2). To configure it, under File > Preferences, set:
Serial Port /dev/pilot
Serial Rate 115200


[HoySync]

[Preferences]

[Edit]

[Details]
Configuring the Pilot
In order to HotSync via the IrDA port, the Pilot has to be running PalmOS 3.3 or later. On the Pilot:
  1. Launch HotSync
  2. From the Local|Modem choice, select Local
  3. From the pop-up menu, select IR to a PC/Handheld
  4. From the menu bar, select Connection Setup
  5. Select IR to a PC/Handheld
  6. Tap Edit...
  7. For Connection Method, select IrCOMM to PC
  8. Tap Details...
  9. For Speed, select 115,200
  10. For Flow Ctl, select Automatic
  11. Tap OK, OK, Done


Performing a HotSync
And now (finally), to perform a HotSync:
  1. On the PowerBook, launch J-Pilot.
  2. Click the Sync button.
  3. Set the Pilot down such that its IrDA port is aimed at the PowerBook's IrDA port.
  4. Turn on the Pilot.
  5. Launch HotSync.
  6. Tap the HotSync icon.
The first time you HotSync, it will take a long time since everything will need to be sync'd to the PowerBook.


Unloading IrDA modules
Whenever any communication with the Pilot is performed, all the IrDA modules and irattach will be loaded automatically. However, they will not unload automatically.

One way to solve this problem is to make things so that whenever the jpilot executable exits, kill irattach and unload the modules. To do that, a "wrapper" script can be written that you call instead of calling jpilot directly.

However, a complication is that only root can kill irattach and unload modules. A solution is to use a setuid root Perl script that forks and:
  • The child process sets its effective user-ID and group-ID to its real user-ID and group-ID and then execs jpilot so it won't run as root.
  • The parent process (still as root) will wait until the child terminates then kill irattach and unload the modules.
Here is such a script:
/usr/local/bin/jpilot-wrapper
    #! /usr/bin/suidperl

    $ENV{ PATH } = '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin';
    $ENV{ LD_LIBRARY_PATH } = '/usr/local/lib';
    map { delete $ENV{ $_ } } qw( BASH_ENV CDPATH );

    if ( fork ) {		# parent process: wait for child
        wait;
        system( '/usr/bin/killall -q irattach' );
        map { system( "/sbin/rmmod $_" ) }
            ( 'irtty', 'ircomm-tty', 'ircomm', 'irda' );
    } else {			# child process: exec jpilot
        ( $>, $) ) = ( $<, $( );
        exec( '/usr/local/bin/jpilot' );
        die "$0: $!\n";
    }
After creating that script, you need to change the owner and mode to setuid:
    chown root:root jpilot-wrapper
    chmod u+s jpilot-wrapper


[Personal] [Résumé] [Software] [Contact]
Last updated: November 23, 2001