[Xastir] HSP Problem
Stephen West-Fisher
steve at coastaldatasystems.com
Sun Jul 13 12:54:12 EDT 2003
Stephen West-Fisher wrote:
> There are two problems, but I haven't come up with a fix yet. The minor
> one is that you are correct, timings are a problem. I have found that
> setting the GPS timing at 20 seconds will cause DTR to switch back and
> forth, but 60 seconds will hold DTR low all the time.
>
> Now for the major problem, I'm trying to come up with something that
> will work for me until you can properly correct it. The problem is in
> interface.c in channel_data:
> switch(port_data[port].device_type) {
>
> case DEVICE_SERIAL_GPS:
> case DEVICE_SERIAL_TNC_HSP_GPS:
> case DEVICE_NET_GPSD:
>
> // One of the three types of interfaces that might
> // send in a lot of GPS data constantly. Save only
> // GPRMC and GPGGA strings into global variables.
> // Drop other GPS strings on the floor.
> //
> if ( (length > 7) && (strncmp(string,"$GPRMC,",7) == 0) ) {
> strncpy(gprmc_save_string,string,MAX_LINE_SIZE);
> gps_port_save = port;
> }
> else if ( (length > 7) && (strncmp(string,"$GPGGA,",7)
> == 0) ) {
> strncpy(gpgga_save_string,string,MAX_LINE_SIZE);
> gps_port_save = port;
> }
> else { // Else drop the string on the floor.
> }
> break;
> // We need to make sure that the variables stating that a string is
> // available are reset in any case. Look at how/where data_avail is
> // reset. We may not care if we just wait for data_avail to be
> // cleared before writing to the string again.
>
> default: // Not one of the above three types, decode
> // the string normally.
> incoming_data = string;
> incoming_data_length = length;
> data_port = port;
> data_avail = 1;
> //fprintf(stderr,"data_avail\n");
> break;
> }
>
> Since DEVICE_SERIAL_TNC_HSP_GPS is true, all data is considered GPS
> data. So the needed GPS strings are OK, but all other data received on
> the port goes into the bit bucket, including received packets!
>
> Packets are never moved to incomming_data and data_avail is never true,
> so they are never parsed in main.c.
My quick and dirty solution, which also speeds up getting the valid GPS fix:
switch(port_data[port].device_type) {
case DEVICE_SERIAL_GPS:
case DEVICE_NET_GPSD:
// One of the three types of interfaces that might
// send in a lot of GPS data constantly. Save only
// GPRMC and GPGGA strings into global variables.
// Drop other GPS strings on the floor.
//
if ( (length > 7) && (strncmp(string,"$GPRMC,",7) == 0) ) {
strncpy(gprmc_save_string,string,MAX_LINE_SIZE);
gps_port_save = port;
}
else if ( (length > 7) && (strncmp(string,"$GPGGA,",7)
== 0) ) {
strncpy(gpgga_save_string,string,MAX_LINE_SIZE);
gps_port_save = port;
}
else { // Else drop the string on the floor.
}
break;
case DEVICE_SERIAL_TNC_HSP_GPS:
// One of the three types of interfaces that might
// send in a lot of GPS data constantly. Save only
// GPRMC and GPGGA strings into global variables.
// Drop other GPS strings on the floor.
//
if ((length > 3) && (strncmp(string,"$GP",3) == 0)) {
if ( (length > 7) && (strncmp(string,"$GPRMC,",7) == 0) ) {
strncpy(gprmc_save_string,string,MAX_LINE_SIZE);
gps_port_save = port;
}
else if ( (length > 7) && (strncmp(string,"$GPGGA,",7)
== 0) ) {
strncpy(gpgga_save_string,string,MAX_LINE_SIZE);
gps_port_save = port;
}
else { // Else drop the string on the floor.
}
}
// We need to make sure that the variables stating that a string is
// available are reset in any case. Look at how/where data_avail is
// reset. We may not care if we just wait for data_avail to be
// cleared before writing to the string again.
default: // Not one of the above three types, decode
// the string normally.
incoming_data = string;
incoming_data_length = length;
data_port = port;
data_avail = 1;
//fprintf(stderr,"data_avail\n");
break;
}
I'm sure some developer who knows more about the GPS strings can do a
better job :-) I tried to just add the additional if statment to the
previous code, but I couldn't get the break to do what I want. The
system kept trying to parse invalid strings. It's been a number of years
since I did much work in C.
--
Stephen West-Fisher
Coastal Data Systems
727.418.9774
http://www.coastaldatasystems.com/
More information about the Xastir
mailing list