Skip to content

Commit

Permalink
update serial port example
Browse files Browse the repository at this point in the history
  • Loading branch information
markhuge authored Jun 11, 2023
2 parents b57b7a9 + 63ecd83 commit 7ddcfa4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
5 changes: 5 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def dependencies():
git_repository,
name = "boringssl",
commit = "87f3087d6343b89142d1191388a5885d74459df2",
# Patch out -Werror to avoid error on GCC 11. The new warning that is
# triggering an error is a conversion between `const uint8_t s[32]` and
# `const uint8_t *s` in curve25519.c (-Werror=array-parameter=).
patch_args = ["-p1"],
patches = ["boringssl.patch"],
# 2020/4/7
remote = "https://boringssl.googlesource.com/boringssl",
shallow_since = "1586306564 +0000",
Expand Down
5 changes: 5 additions & 0 deletions c/bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def dependencies():
git_repository,
name = "boringssl",
commit = "87f3087d6343b89142d1191388a5885d74459df2",
# Patch out -Werror to avoid error on GCC 11. The new warning that is
# triggering an error is a conversion between `const uint8_t s[32]` and
# `const uint8_t *s` in curve25519.c (-Werror=array-parameter=).
patch_args = ["-p1"],
patches = ["boringssl.patch"],
# 2020/4/7
remote = "https://boringssl.googlesource.com/boringssl",
shallow_since = "1586306564 +0000",
Expand Down
12 changes: 12 additions & 0 deletions c/external/boringssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/BUILD b/BUILD
index 5e62b44..ab64262 100644
--- a/BUILD
+++ b/BUILD
@@ -68,7 +68,6 @@ posix_copts = [

# This list of warnings should match those in the top-level CMakeLists.txt.
"-Wall",
- "-Werror",
"-Wformat=2",
"-Wsign-compare",
"-Wmissing-field-initializers",
14 changes: 8 additions & 6 deletions examples/serial_port_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ DEFINE_string(polaris_api_key, "",
"The service API key. Contact account administrator or "
"[email protected] if unknown.");

DEFINE_string(polaris_unique_id, "device12345",
DEFINE_string(polaris_unique_id, "",
"The unique ID to assign to this Polaris connection.");

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

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

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

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

if (nmea_sentence_buffer.size() > MAX_NMEA_SENTENCE_LENGTH) {
LOG(WARNING) << "Clearing NMEA buffer. Are you sending NMEA ascii data?";
nmea_sentence_buffer.clear();
}
}

Expand Down
12 changes: 12 additions & 0 deletions external/boringssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/BUILD b/BUILD
index 5e62b44..ab64262 100644
--- a/BUILD
+++ b/BUILD
@@ -68,7 +68,6 @@ posix_copts = [

# This list of warnings should match those in the top-level CMakeLists.txt.
"-Wall",
- "-Werror",
"-Wformat=2",
"-Wsign-compare",
"-Wmissing-field-initializers",

0 comments on commit 7ddcfa4

Please sign in to comment.