Skip to content

Configurable baudrate for NMEA GPS receiver. #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
7 changes: 2 additions & 5 deletions src/dwgpsnmea.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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);
Expand Down