[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coldsync-hackers] Snapshot: 2.0.0




Looks pretty neat Andrew.  I'm looking forward to trying the daemon mode
(maybe a little HOWTO collecting people's experiences would be in
order).  

Still doesn't fix the ACK Timeout problem or allow the highest serial
speed for me... sigh.  Could we just reinstate the serial code from the
last version that worked well (circa 1.5.x)?  Are others having this
problem?

On an unrelated note, someone once asked here about setting the Palm
Time from your system's time.  I implemented this.  Attached is a diff
to Coldsync::SPC, which implements dlp_{Set,Get}SysDateTime.  I also
made a sync conduit which calls these functions.  I did not include it,
for the following reasons:

1.  There's no convenient way to run a conduit which is not associated
with a given database.  I ended up kludging it to run with the Datebook
database, with all the overhead of reading the AppInfoBlock, etc.  It
would be nice if you could run any given conduit always, without
specifically finding it on a given database's list.  

2.  There's apparently an error in the PalmOS code for OS version 3.3,
which causes the Palm to crash as soon as the time gets set (reading is
no problem).  Palm Developer site has this to say:

<<<<<<<<<<<<
When I try to use the sync manager SyncWriteSysDateTime function, the
time on the hand-held device does not change. What is going wrong?
 
This is caused by a bug in SyncWriteSysDateTime. 
 
If you are using a version of HotSync manager prior to 3.0,
SyncWriteSysDateTime will return an error code. If you are using HotSync
manager 3.0, SyncWriteSysDateTime will return successfully, but will not
actually change the time on the device. 
 
There is currently no other Sync Manager API to use to workaround this
bug.
>>>>>>>>>>>>>

There is a piece of Windows freeware which does this, timePal, which had
the same problem, but managed to get around it somehow, saying: "There
is an early access release of TimePAL 2.0 which has a workaround for the
OS 3.3 incompatibility."  We'll see if they share the secret with us.

Until then, you can try playing with the new SPC functions, but beware
of the bugs I indicated.  If either/both get resolved, I'll release the
conduit itself (all of 10 lines or so).  Then, stir in a little NNTP,
and presto, instant time synchronization.

JD
*** SPC_save.pm	Wed Feb 21 16:23:43 2001
--- SPC.pm	Wed Feb 21 18:23:43 2001
***************
*** 61,66 ****
--- 61,68 ----
  	dlp_CloseDB
  	dlp_ReadAppBlock
  	dlp_WriteAppBlock
+ 	dlp_GetSysDateTime
+ 	dlp_SetSysDateTime
  );
  
  # Various useful constants
***************
*** 78,83 ****
--- 80,87 ----
  use constant DLPCMD_CloseDB		=> 0x19;
  use constant DLPCMD_ReadAppBlock	=> 0x1b;
  use constant DLPCMD_WriteAppBlock	=> 0x1c;
+ use constant DLPCMD_GetSysDateTime      => 0x13;
+ use constant DLPCMD_SetSysDateTime      => 0x14;
  
  # spc_init
  # Initialize a conduit for SPC.
***************
*** 652,657 ****
--- 656,722 ----
  	# No return arguments to parse
  
  	return $err;
+ }
+ 
+ =head2 dlp_GetSysDateTime
+ 
+ 	$datetime = &dlp_GetSysDateTime();
+ 
+ Reads the date and time from the Palm.  Returns a reference to a hash
+ containing the date, with fields
+ "year","month","day","hour","minute","second".
+ 
+ =cut
+ 
+ sub dlp_GetSysDateTime
+ {
+   my $errno;
+   my @argv;
+   my $retval;
+ 
+   ($errno, @argv) = &dlp_req(DLPCMD_GetSysDateTime);
+ 
+   $retval = {};
+   foreach my $arg (@argv) {
+     if ($arg->{id} == 0x20) {
+       @$retval{"year","month","day","hour","minute","second"}=
+ 	unpack("nC5",$arg->{data});
+     }
+   }
+ 
+   return $retval;
+ }
+ 
+ =head2 dlp_SetSysDateTime
+ 
+ 	$err = &dlp_SetSysDateTime($year,$mon,$day,$hour,$min,$sec);
+ 
+ Sets the time on the Palm as indicated.  Make sure C<$year> is a 4
+ digit number, and is not 1900 subtracted, as returned from
+ localtime().  Also ensure C<$mon> is 1 offset (January=1).
+ 
+ Returns the DLP error code.
+ 
+ =cut
+ 
+ sub dlp_SetSysDateTime
+ {
+ 
+   my($year,$mon,$day,$hour,$min,$sec)=@_;
+   my $err;
+   my @argv;
+ 
+   print STDERR "Setting Date To: $mon/$day/$year $hour:$min:$sec\n";
+ 
+   ($err, @argv)=&dlp_req(DLPCMD_SetSysDateTime,
+ 			 {
+ 			  id   => 0x20,
+ 			  data => pack("nC5x",$year,$mon,$day,$hour,$min,$sec)
+ 			 }
+ 			);
+   # No return arguments to parse
+   print STDERR "ERROR: $err\n";
+   return $err;
  }
  
  1;