Allow speed for GPSNMEA configuration.

This commit is contained in:
wb2osz 2021-12-29 17:30:20 -05:00
parent 65869bc643
commit 5dbe2ce136
3 changed files with 13 additions and 7 deletions

View File

@ -4774,7 +4774,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
/* /*
* GPSNMEA - Device name for reading from GPS receiver. * GPSNMEA serial-device [ speed ] - Direct connection to GPS receiver.
*/ */
else if (strcasecmp(t, "gpsnmea") == 0) { else if (strcasecmp(t, "gpsnmea") == 0) {
t = split(NULL,0); t = split(NULL,0);
@ -4783,8 +4783,15 @@ void config_init (char *fname, struct audio_s *p_audio_config,
dw_printf ("Config file, line %d: Missing serial port name for GPS receiver.\n", line); dw_printf ("Config file, line %d: Missing serial port name for GPS receiver.\n", line);
continue; continue;
} }
else {
strlcpy (p_misc_config->gpsnmea_port, t, sizeof(p_misc_config->gpsnmea_port)); strlcpy (p_misc_config->gpsnmea_port, t, sizeof(p_misc_config->gpsnmea_port));
t = split(NULL,0);
if (t != NULL) {
int n = atoi(t);
p_misc_config->gpsnmea_speed = n;
}
else {
p_misc_config->gpsnmea_speed = 4800; // The standard at one time.
} }
} }

View File

@ -76,7 +76,8 @@ struct misc_config_s {
char gpsnmea_port[20]; /* Serial port name for reading NMEA sentences from GPS. */ char gpsnmea_port[20]; /* Serial port name for reading NMEA sentences from GPS. */
/* e.g. COM22, /dev/ttyACM0 */ /* e.g. COM22, /dev/ttyACM0 */
/* Currently no option for setting non-standard speed. */
int gpsnmea_speed; /* Speed for above, baud, default 4800. */
char gpsd_host[20]; /* Host for gpsd server. */ char gpsd_host[20]; /* Host for gpsd server. */
/* e.g. localhost, 192.168.1.2 */ /* e.g. localhost, 192.168.1.2 */

View File

@ -148,7 +148,7 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
* Should add an option to allow changing someday. * Should add an option to allow changing someday.
*/ */
s_gpsnmea_port_fd = serial_port_open (pconfig->gpsnmea_port, 4800); s_gpsnmea_port_fd = serial_port_open (pconfig->gpsnmea_port, pconfig->gpsnmea_speed);
if (s_gpsnmea_port_fd != MYFDERROR) { if (s_gpsnmea_port_fd != MYFDERROR) {
#if __WIN32__ #if __WIN32__
@ -182,12 +182,10 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
/* Return fd to share if waypoint wants same device. */ /* Return fd to share if waypoint wants same device. */
/* Currently both are fixed speed at 4800. */
/* If that ever becomes configurable, that needs to be compared too. */
MYFDTYPE dwgpsnmea_get_fd(char *wp_port_name, int speed) MYFDTYPE dwgpsnmea_get_fd(char *wp_port_name, int speed)
{ {
if (strcmp(s_save_configp->gpsnmea_port, wp_port_name) == 0 && speed == 4800) { if (strcmp(s_save_configp->gpsnmea_port, wp_port_name) == 0 && speed == s_save_configp->gpsnmea_speed) {
return (s_gpsnmea_port_fd); return (s_gpsnmea_port_fd);
} }
return (MYFDERROR); return (MYFDERROR);