A question was implied. Here's the relevant code, which I didn't post before because I doubt it'll help. I was hoping that someone had already encountered this trouble, which I suspect has something to do with Win32::SerialPort.
# First call this sub.
sub connectToGPS {
my $gps;
if ($winMain->rbNMEA->Checked()) {
$gps = new GPS::NMEA(Port => $winMain->cbGPSPort->Text(),
Baud => $winMain->cbPortBaud->Text());
}
else {
$gps = new GPS::Garmin(Port => $winMain->cbGPSPort->Text(),
Baud => $winMain->cbPortBaud->Text());
}
return $gps;
}
# Then pass its returned value to this sub.
sub getGPSData {
my $gps = shift;
my %gpsHash = %{$gps};
my $port = $gpsHash{serial};
$port->purge_all();
$port->stty_kill("\cU");
my ($time, $satsUsed, $accuracy, $quality, $speed);
if ($winMain->rbNMEA->Checked()) {
$gps->parse();
my %gpsData = %{$gps->{NMEADATA}};
$time = $gpsData{time_utc};
$time = "---" unless $time;
$satsUsed = $gpsData{num_sat_tracked};
$satsUsed = "---" unless $satsUsed;
$satsUsed = 0 if $satsUsed eq "00";
$accuracy = $gpsData{data_valid};
$accuracy = "---" unless $accuracy;
$quality = $gpsData{fixq012};
$quality = "---" unless $quality;
$speed = $gpsData{speed_over_ground};
$speed = "---" unless $speed;
$speed = "---" if $speed eq "";
}
else {
my ($sec, $min, $hour, $mday, $mon, $year) = $gps->get_time();
$time = "$hour:$min:$sec";
$time = "---" if $time eq "::";
}
my ($latitudeSign, $latitude, $longitudeSign, $longitude) = $gps->
+get_position();
$port->close();
# Irrelevant GUI update code goes here.
}
|