mirror of https://github.com/wb2osz/direwolf.git
Configurable baudrate for NMEA GPS receiver.
This commit is contained in:
parent
b66c21d39b
commit
b46cbdd4de
12
src/config.c
12
src/config.c
|
@ -894,6 +894,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
p_misc_config->kiss_serial_poll = 0;
|
||||
|
||||
strlcpy (p_misc_config->gpsnmea_port, "", sizeof(p_misc_config->gpsnmea_port));
|
||||
p_misc_config->gpsnmea_speed = 0;
|
||||
strlcpy (p_misc_config->waypoint_serial_port, "", sizeof(p_misc_config->waypoint_serial_port));
|
||||
|
||||
p_misc_config->log_daily_names = 0;
|
||||
|
@ -4685,7 +4686,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
|
||||
|
||||
/*
|
||||
* GPSNMEA - Device name for reading from GPS receiver.
|
||||
* GPSNMEA name [ speed ] - Device name and speed for reading from GPS receiver.
|
||||
* If no speed is provided, a default of 4800 is used.
|
||||
*/
|
||||
else if (strcasecmp(t, "gpsnmea") == 0) {
|
||||
t = split(NULL,0);
|
||||
|
@ -4697,6 +4699,14 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
|||
else {
|
||||
strlcpy (p_misc_config->gpsnmea_port, t, sizeof(p_misc_config->gpsnmea_port));
|
||||
}
|
||||
t = split(NULL,0);
|
||||
if (t == NULL) {
|
||||
p_misc_config->gpsnmea_speed = 4800;
|
||||
}
|
||||
else {
|
||||
p_misc_config->gpsnmea_speed = atoi(t);
|
||||
}
|
||||
dw_printf ("Using port %s at %d bps for NMEA GPS.\n", p_misc_config->gpsnmea_port, p_misc_config->gpsnmea_speed);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -76,7 +76,7 @@ struct misc_config_s {
|
|||
|
||||
char gpsnmea_port[20]; /* Serial port name for reading NMEA sentences from GPS. */
|
||||
/* e.g. COM22, /dev/ttyACM0 */
|
||||
/* Currently no option for setting non-standard speed. */
|
||||
int gpsnmea_speed; /* Speed in bps for the GPS serial port. */
|
||||
|
||||
char gpsd_host[20]; /* Host for gpsd server. */
|
||||
/* e.g. localhost, 192.168.1.2 */
|
||||
|
|
|
@ -145,10 +145,9 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
|
|||
/*
|
||||
* Open serial port connection.
|
||||
* 4800 baud is standard for GPS.
|
||||
* 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 __WIN32__
|
||||
|
@ -182,12 +181,10 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug)
|
|||
|
||||
|
||||
/* 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)
|
||||
{
|
||||
if (strcmp(s_save_configp->gpsnmea_port, wp_port_name) == 0 && speed == 4800) {
|
||||
if (strcmp(s_save_configp->gpsnmea_port, wp_port_name) == 0 && s_save_configp->gpsnmea_speed == speed) {
|
||||
return (s_gpsnmea_port_fd);
|
||||
}
|
||||
return (MYFDERROR);
|
||||
|
|
Loading…
Reference in New Issue