aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/gps/gps_helper.cpp
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2013-09-21 08:59:04 +0200
committerAnton Babushkin <anton.babushkin@me.com>2013-09-21 08:59:04 +0200
commit8d6a47546a32e6911a0f769070511baa6549ed03 (patch)
tree0a701bf0a1b92380e23435ad3b77765ababd1a81 /src/drivers/gps/gps_helper.cpp
parentcd8854e622793b3f3e7104d29f06e614d4dfac42 (diff)
downloadpx4-firmware-8d6a47546a32e6911a0f769070511baa6549ed03.tar.gz
px4-firmware-8d6a47546a32e6911a0f769070511baa6549ed03.tar.bz2
px4-firmware-8d6a47546a32e6911a0f769070511baa6549ed03.zip
gps: fixed code style, more informative and clean messages
Diffstat (limited to 'src/drivers/gps/gps_helper.cpp')
-rw-r--r--src/drivers/gps/gps_helper.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/drivers/gps/gps_helper.cpp b/src/drivers/gps/gps_helper.cpp
index ba86d370a..2e2cbc8dd 100644
--- a/src/drivers/gps/gps_helper.cpp
+++ b/src/drivers/gps/gps_helper.cpp
@@ -87,13 +87,15 @@ GPS_Helper::set_baudrate(const int &fd, unsigned baud)
case 115200: speed = B115200; break;
- warnx("try baudrate: %d\n", speed);
+ warnx("try baudrate: %d\n", speed);
default:
warnx("ERROR: Unsupported baudrate: %d\n", baud);
return -EINVAL;
}
+
struct termios uart_config;
+
int termios_state;
/* fill the struct for the new configuration */
@@ -109,14 +111,17 @@ GPS_Helper::set_baudrate(const int &fd, unsigned baud)
warnx("ERROR setting config: %d (cfsetispeed)\n", termios_state);
return -1;
}
+
if ((termios_state = cfsetospeed(&uart_config, speed)) < 0) {
warnx("ERROR setting config: %d (cfsetospeed)\n", termios_state);
return -1;
}
+
if ((termios_state = tcsetattr(fd, TCSANOW, &uart_config)) < 0) {
warnx("ERROR setting baudrate (tcsetattr)\n");
return -1;
}
+
/* XXX if resetting the parser here, ensure it does exist (check for null pointer) */
return 0;
}