Hello!
I tried the code from the original post on Windows XP, ActivePerl 5.8.7 Build 815 with a Garmin GPS 12CX attached to COM4 and it didn't work.
No worries though.
So... I put together a variation of the original post
using
GPS::Garmin which is a subset module to
perl::GPS
I have posted the "new code" below.
++ to the original author for inspiring me to dig further and find this module to interface with my Garmin! Yet Another Cool Use For Perl!
Important Note: Garmin::GPS on Win32 wants to see installed
Win32::SerialPort, however, ActiveState does not appear to offer it for perl 5.8 and above. I did a little digging and installed it directly via the ppm prompt by issuing the command
ppm>install http://www.bribes.org/perl/ppm/Win32-SerialPort.ppd
With that little problem solved the script below works quite well.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use GPS::Garmin;
use Win32::SerialPort;
my $mw = MainWindow->new;
$mw->withdraw;
my $location;
my $gps = new GPS::Garmin( 'Port' => 'COM4', 'Baud' => 9600, );
my ($latsign,$lat,$lonsign,$lon) = $gps->get_position;
my ($sec,$min,$hour,$mday,$mon,$year) = $gps->get_time;
my $time="$hour:$min:$sec";
$lat=sprintf("%.4f",$lat);
$lon=sprintf("%.4f",$lon);
$location="$lat$latsign $lon$lonsign";
my $locationandtime="$lat$latsign $lon$lonsign\n$time"." GMT";
$mw->messageBox (
-message => $locationandtime, -title => 'Time and location', -type
+ => 'Ok'
);
I am thinking more possibilities for tinkering there will soon be! :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.