MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / connect_and_read_loop

Method connect_and_read_loop

OpenHD/ohd_telemetry/src/endpoints/SerialEndpoint.cpp:248–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248void SerialEndpoint::connect_and_read_loop() {
249 while (!_stop_requested) {
250 if (!OHDFilesystemUtil::exists(m_options.linux_filename)) {
251 if (!uart_log_warning_once) {
252 m_console->debug("UART not found!");
253 uart_log_warning_once = true;
254 }
255 std::this_thread::sleep_for(std::chrono::seconds(1));
256 continue;
257 }
258 // The file exists, so creating the FD should be no problem
259 m_fd = setup_port(m_options, m_console);
260 if (m_fd == -1) {
261 // But if it fails, we start over again, checking if at least the linux fd
262 // exists
263 m_console->warn("Cannot create uart fd " + m_options.to_string());
264 std::this_thread::sleep_for(std::chrono::seconds(1));
265 continue;
266 }
267 m_console->debug("Successfully created UART fd for: {}",
268 m_options.to_string());
269 receive_data_until_error();
270 // cleanup and start over again
271 close(m_fd);
272 m_fd = -1;
273 }
274}
275
276void SerialEndpoint::receive_data_until_error() {
277 m_console->debug("receive_data_until_error() begin");

Callers

nothing calls this directly

Calls 2

debugMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected