Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Sunday August 29, 2004
03:37 PM

Perl and the Magellan GPS Companion

[ #20627 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.