Perl and the Magellan GPS Companion

brian_d_foy on 2004-08-29T20:37:17

I have the Magellan GPS Companion, which is a Springboard module for my Visor Edge (but really any Palm thingy).

I've been having a bit of fun taking it around Chicago, and even on trips. Now I have a bunch of waypoints, but until last night they were stuck on my Visor. The software lets me beam waypoints, presumably to other thingys with the same module, but I don't see any way to export them to something like text.

No matter. Perl can do it just fine. I started with the Palm::PDB module, wrote my own concrete class for the factory, and shazam!: Palm::Magellan::NavCompanion. It's a developer's release right now, but you should be able to access your waypoints even if the module is a bit ugly and incomplete. It should make its way around CPAN in a day or so.

	use Palm::Magellan::NavCompanion;

my $pdb = Palm::Magellan::NavCompanion->new; $pdb->Load( $file );

my $waypoints = $pdb->{records};

$, = ", "; foreach my $wp ( @$waypoints ) { print $wp->name, $wp->latitude, $wp->longitude; print "\n"; }


I can only read the file right now. I need to reverse engineer some more bits before I figure out how to write things back out.

Interesting tech note: a lot of the things in the database format as C strings, so they end in a null byte. I thought that I could handle that with some "x" placeholders in unpack, but I kept getting errors like "x outside of string". Apparently it can't figure out the null byte positions on its own. I punted and read the strings as one chunk then split on the null bytes.

I know the maximum length of the strings (because the GUI won't let me enter more characters than that), so I should be able to use the Z format specifier, but I didn't get around to trying that. When I don't have much time, I use stuff I know will work. I can refactor later.


Visor oddness

drhyde on 2004-08-31T08:14:57

... Springboard module for my Visor Edge (but really any Palm thingy).

Springboard is some weird Visor-only thing, and definitely not for "any Palm thingy".

Re:Visor oddness

brian_d_foy on 2004-08-31T08:18:47

Hmmm, maybe so. I guess the actual Palms don't do this sort of thing.