Skip to content

Commit 7ddcfa4

Browse files
authored
update serial port example
2 parents b57b7a9 + 63ecd83 commit 7ddcfa4

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

bazel/repositories.bzl

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ def dependencies():
5656
git_repository,
5757
name = "boringssl",
5858
commit = "87f3087d6343b89142d1191388a5885d74459df2",
59+
# Patch out -Werror to avoid error on GCC 11. The new warning that is
60+
# triggering an error is a conversion between `const uint8_t s[32]` and
61+
# `const uint8_t *s` in curve25519.c (-Werror=array-parameter=).
62+
patch_args = ["-p1"],
63+
patches = ["boringssl.patch"],
5964
# 2020/4/7
6065
remote = "https://boringssl.googlesource.com/boringssl",
6166
shallow_since = "1586306564 +0000",

c/bazel/repositories.bzl

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def dependencies():
2424
git_repository,
2525
name = "boringssl",
2626
commit = "87f3087d6343b89142d1191388a5885d74459df2",
27+
# Patch out -Werror to avoid error on GCC 11. The new warning that is
28+
# triggering an error is a conversion between `const uint8_t s[32]` and
29+
# `const uint8_t *s` in curve25519.c (-Werror=array-parameter=).
30+
patch_args = ["-p1"],
31+
patches = ["boringssl.patch"],
2732
# 2020/4/7
2833
remote = "https://boringssl.googlesource.com/boringssl",
2934
shallow_since = "1586306564 +0000",

c/external/boringssl.patch

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/BUILD b/BUILD
2+
index 5e62b44..ab64262 100644
3+
--- a/BUILD
4+
+++ b/BUILD
5+
@@ -68,7 +68,6 @@ posix_copts = [
6+
7+
# This list of warnings should match those in the top-level CMakeLists.txt.
8+
"-Wall",
9+
- "-Werror",
10+
"-Wformat=2",
11+
"-Wsign-compare",
12+
"-Wmissing-field-initializers",

examples/serial_port_example.cc

+8-6
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ DEFINE_string(polaris_api_key, "",
3030
"The service API key. Contact account administrator or "
3131
"[email protected] if unknown.");
3232

33-
DEFINE_string(polaris_unique_id, "device12345",
33+
DEFINE_string(polaris_unique_id, "",
3434
"The unique ID to assign to this Polaris connection.");
3535

3636
// Serial port forwarding options.
37-
DEFINE_string(receiver_serial_port, "/dev/ttyACM0",
37+
DEFINE_string(receiver_serial_port, "/dev/ttyUSB0",
3838
"The path to the serial port for which to forward corrections.");
3939

40-
DEFINE_int32(receiver_serial_baud, 115200, "The baud rate of the serial port.");
40+
DEFINE_int32(receiver_serial_baud, 460800, "The baud rate of the serial port.");
4141

4242
namespace {
4343
// Max size of string buffer to hold before clearing NMEA data. Should be larger
@@ -61,11 +61,12 @@ double ConvertGGADegreesToDecimalDegrees(double gga_degrees) {
6161
void OnNmea(const std::string& nmea_str, PolarisClient* polaris_client) {
6262
// Some receivers put out INGGA messages as opposed to GPGGA.
6363
if (!(boost::istarts_with(nmea_str, "$GPGGA") ||
64+
boost::istarts_with(nmea_str, "$GNGGA") ||
6465
boost::istarts_with(nmea_str, "$INGGA"))) {
65-
LOG(INFO) << nmea_str;
66+
VLOG(2) << nmea_str;
6667
return;
6768
}
68-
VLOG(4) << "Got GGA: " << nmea_str;
69+
LOG(INFO) << "Got GGA: " << nmea_str;
6970
std::stringstream ss(nmea_str);
7071
std::vector<std::string> result;
7172

@@ -82,7 +83,7 @@ void OnNmea(const std::string& nmea_str, PolarisClient* polaris_client) {
8283
(result[3] == "N" ? 1 : -1);
8384
double lon = ConvertGGADegreesToDecimalDegrees(std::stod(result[4], &sz)) *
8485
(result[5] == "E" ? 1 : -1);
85-
double alt = std::stod(result[8], &sz);
86+
double alt = std::stod(result[9], &sz);
8687
VLOG(3) << "Setting position: lat: " << lat << " lon: " << lon
8788
<< " alt: " << alt;
8889
polaris_client->SendLLAPosition(lat, lon, alt);
@@ -108,6 +109,7 @@ void OnSerialData(const void* data, size_t length,
108109

109110
if (nmea_sentence_buffer.size() > MAX_NMEA_SENTENCE_LENGTH) {
110111
LOG(WARNING) << "Clearing NMEA buffer. Are you sending NMEA ascii data?";
112+
nmea_sentence_buffer.clear();
111113
}
112114
}
113115

external/boringssl.patch

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/BUILD b/BUILD
2+
index 5e62b44..ab64262 100644
3+
--- a/BUILD
4+
+++ b/BUILD
5+
@@ -68,7 +68,6 @@ posix_copts = [
6+
7+
# This list of warnings should match those in the top-level CMakeLists.txt.
8+
"-Wall",
9+
- "-Werror",
10+
"-Wformat=2",
11+
"-Wsign-compare",
12+
"-Wmissing-field-initializers",

0 commit comments

Comments
 (0)