Skip to content

Commit 423612c

Browse files
committed
add ublox gps win patch
Signed-off-by: wep21 <[email protected]>
1 parent 15c8e92 commit 423612c

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 5a9fdf1..3122dd8 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -64,6 +64,8 @@ target_link_libraries(ublox_gps PUBLIC
6+
ublox_serialization::ublox_serialization
7+
)
8+
9+
+target_compile_definitions(ublox_gps PRIVATE _USE_MATH_DEFINES)
10+
+
11+
install(TARGETS ublox_gps EXPORT export_${PROJECT_NAME}
12+
ARCHIVE DESTINATION lib
13+
LIBRARY DESTINATION lib
14+
diff --git a/include/ublox_gps/ublox_firmware7plus.hpp b/include/ublox_gps/ublox_firmware7plus.hpp
15+
index 84ffe7a..1b8043d 100644
16+
--- a/include/ublox_gps/ublox_firmware7plus.hpp
17+
+++ b/include/ublox_gps/ublox_firmware7plus.hpp
18+
@@ -175,7 +175,17 @@ class UbloxFirmware7Plus : public UbloxFirmware {
19+
}
20+
// Raise diagnostic level to error if no fix
21+
if (last_nav_pvt_.fix_type == ublox_msgs::msg::NavPVT::FIX_TYPE_NO_FIX) {
22+
+#if defined(_WIN32)
23+
+# if defined(ERROR)
24+
+# pragma push_macro("ERROR")
25+
+# undef ERROR
26+
+# endif
27+
+#endif
28+
stat.level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
29+
+#if defined(_WIN32)
30+
+# pragma warning(suppress : 4602)
31+
+# pragma pop_macro("ERROR")
32+
+#endif
33+
stat.message = "No fix";
34+
}
35+
36+
diff --git a/src/gps.cpp b/src/gps.cpp
37+
index e71377d..9e91478 100644
38+
--- a/src/gps.cpp
39+
+++ b/src/gps.cpp
40+
@@ -138,12 +138,6 @@ void Gps::initializeSerial(const std::string & port, unsigned int baudrate,
41+
42+
RCLCPP_INFO(logger_, "U-Blox: Opened serial port %s", port.c_str());
43+
44+
- int fd = serial->native_handle();
45+
- termios tio{};
46+
- tcgetattr(fd, &tio);
47+
- cfmakeraw(&tio);
48+
- tcsetattr(fd, TCSANOW, &tio);
49+
-
50+
// Set the I/O worker
51+
if (worker_) {
52+
return;
53+
diff --git a/src/hpg_ref_product.cpp b/src/hpg_ref_product.cpp
54+
index b12caaf..62c61b4 100644
55+
--- a/src/hpg_ref_product.cpp
56+
+++ b/src/hpg_ref_product.cpp
57+
@@ -224,7 +224,17 @@ void HpgRefProduct::tmode3Diagnostics(
58+
stat.message = "Disabled";
59+
} else if (mode_ == SURVEY_IN) {
60+
if (!last_nav_svin_.active && !last_nav_svin_.valid) {
61+
+#if defined(_WIN32)
62+
+# if defined(ERROR)
63+
+# pragma push_macro("ERROR")
64+
+# undef ERROR
65+
+# endif
66+
+#endif
67+
stat.level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
68+
+#if defined(_WIN32)
69+
+# pragma warning(suppress : 4602)
70+
+# pragma pop_macro("ERROR")
71+
+#endif
72+
stat.message = "Survey-In inactive and invalid";
73+
} else if (last_nav_svin_.active && !last_nav_svin_.valid) {
74+
stat.level = diagnostic_msgs::msg::DiagnosticStatus::WARN;
75+
diff --git a/src/hpg_rov_product.cpp b/src/hpg_rov_product.cpp
76+
index 7b524d5..b08a862 100644
77+
--- a/src/hpg_rov_product.cpp
78+
+++ b/src/hpg_rov_product.cpp
79+
@@ -65,7 +65,17 @@ void HpgRovProduct::carrierPhaseDiagnostics(
80+
if (carr_soln & ublox_msgs::msg::NavRELPOSNED::FLAGS_CARR_SOLN_NONE ||
81+
!(last_rel_pos_.flags & ublox_msgs::msg::NavRELPOSNED::FLAGS_DIFF_SOLN &&
82+
last_rel_pos_.flags & ublox_msgs::msg::NavRELPOSNED::FLAGS_REL_POS_VALID)) {
83+
+#if defined(_WIN32)
84+
+# if defined(ERROR)
85+
+# pragma push_macro("ERROR")
86+
+# undef ERROR
87+
+# endif
88+
+#endif
89+
stat.level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
90+
+#if defined(_WIN32)
91+
+# pragma warning(suppress : 4602)
92+
+# pragma pop_macro("ERROR")
93+
+#endif
94+
stat.message = "None";
95+
} else {
96+
if (carr_soln & ublox_msgs::msg::NavRELPOSNED::FLAGS_CARR_SOLN_FLOAT) {
97+
diff --git a/src/node.cpp b/src/node.cpp
98+
index 23f5172..2c7e499 100644
99+
--- a/src/node.cpp
100+
+++ b/src/node.cpp
101+
@@ -506,7 +506,17 @@ void UbloxNode::pollMessages() {
102+
}
103+
104+
void UbloxNode::printInf(const ublox_msgs::msg::Inf &m, uint8_t id) {
105+
+#if defined(_WIN32)
106+
+# if defined(ERROR)
107+
+# pragma push_macro("ERROR")
108+
+# undef ERROR
109+
+# endif
110+
+#endif
111+
if (id == ublox_msgs::Message::INF::ERROR) {
112+
+#if defined(_WIN32)
113+
+# pragma warning(suppress : 4602)
114+
+# pragma pop_macro("ERROR")
115+
+#endif
116+
RCLCPP_ERROR(this->get_logger(), "INF: %s", std::string(m.str.begin(), m.str.end()).c_str());
117+
} else if (id == ublox_msgs::Message::INF::WARNING) {
118+
RCLCPP_WARN(this->get_logger(), "INF: %s", std::string(m.str.begin(), m.str.end()).c_str());
119+
@@ -546,10 +556,20 @@ void UbloxNode::subscribe() {
120+
}
121+
122+
if (getRosBoolean(this, "inf.error")) {
123+
+#if defined(_WIN32)
124+
+# if defined(ERROR)
125+
+# pragma push_macro("ERROR")
126+
+# undef ERROR
127+
+# endif
128+
+#endif
129+
gps_->subscribeId<ublox_msgs::msg::Inf>(
130+
std::bind(&UbloxNode::printInf, this, std::placeholders::_1,
131+
ublox_msgs::Message::INF::ERROR),
132+
ublox_msgs::Message::INF::ERROR);
133+
+#if defined(_WIN32)
134+
+# pragma warning(suppress : 4602)
135+
+# pragma pop_macro("ERROR")
136+
+#endif
137+
}
138+
139+
if (getRosBoolean(this, "inf.notice")) {
140+
diff --git a/src/ublox_firmware6.cpp b/src/ublox_firmware6.cpp
141+
index 0bb7f3b..24046c5 100644
142+
--- a/src/ublox_firmware6.cpp
143+
+++ b/src/ublox_firmware6.cpp
144+
@@ -151,7 +151,17 @@ void UbloxFirmware6::fixDiagnostic(
145+
}
146+
// Raise diagnostic level to error if no fix
147+
if (last_nav_sol_.gps_fix == ublox_msgs::msg::NavSOL::GPS_NO_FIX) {
148+
+#if defined(_WIN32)
149+
+# if defined(ERROR)
150+
+# pragma push_macro("ERROR")
151+
+# undef ERROR
152+
+# endif
153+
+#endif
154+
stat.level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
155+
+#if defined(_WIN32)
156+
+# pragma warning(suppress : 4602)
157+
+# pragma pop_macro("ERROR")
158+
+#endif
159+
stat.message = "No fix";
160+
}
161+

0 commit comments

Comments
 (0)