Syncronizing time to PalmOS

First, you definitely want ColdSync to synchronize your PalmOS handheld. Unlike pilot-link which is merely a hacked-together set of programs, ColdSync is the orthogonal Unix tool to synchronize your PalmOS handheld to your Unix box.

This is what I have set up to synchronize my NTP-driven Unix time to my PalmOS handheld.

Add to ~/.coldsyncrc:

conduit sync {
        path: "/where/ever/you/have/SetSysDateTime.pl";
        type: memo/DATA;
}
conduit sync {
        path: [generic];
        type: memo/DATA;
}

Note that the [generic] sync conduit must be specified explicitely (without default clause!) unless there already is another sync conduit for memo/DATA. The reason is that by explicitely specifying a sync conduit (by naming the time-sync script) the default [generic] sync conduit gets overridden. But it still should apply, or else the database won't be synced at all. Hence it must be specified explictely.

To avoid this issue it is sensible to synchronize time by hooking to a database which doesn't require the default [generic] sync conduit, so that it can be safely replaced with the time-sync script. See below.

The script SetSysDateTime.pl simply is:

#!/usr/bin/perl

use strict;
use Palm::Memo;
use ColdSync;
use ColdSync::SPC;

StartConduit("sync");

@_ = localtime(time);
$_[5] += 1900;        # year correction
++$_[4];        # month 0..11 -> 1..12
&dlp_SetSysDateTime(reverse @_[0..5]) && die "501 Cannot SetSysDateTime";

EndConduit();

Unfortunately there is some overhead in this procedure: ColdSync automatically reads and writes the database involved (MemoDB.pdb in this case). This is rather pointless as the database is completely ignored; it is merely used as a hook for a single creator/type so that time synchronization takes place only once.

So you may decide to use a small and simple database instead that does not need a sync conduit. A good choice is Saved Preferences.prc:

conduit sync {
        path: "/where/ever/you/have/SetSysDateTime.pl";
        type: psys/sprf;
}
# note the [default] sync conduit is unnecessary for this database
# hence it does not need to be specified explicitely

But there is one gotcha: This is a PRC database and not a PDB database. Hence an amended script is needed which declares a proper handler for this particular PRC database:

#!/usr/bin/perl

use strict;
use Palm::Raw;
use ColdSync;
use ColdSync::SPC;

&Palm::PDB::RegisterPRCHandlers("Palm::Raw", "");

StartConduit("sync");

@_ = localtime(time);
$_[5] += 1900;        # year correction
++$_[4];        # month 0..11 -> 1..12
&dlp_SetSysDateTime(reverse @_[0..5]) && die "501 Cannot SetSysDateTime";

EndConduit();

automagically generated for 38.103.63.18 at 22 May 2008 21:59:42 CEST
last modified by myself at 23 Feb 2006 07:57:01 CET
accessed 1759 times since 13 May 2005 16:37:24 CEST
validated HTML 4.01