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

Method setup_uart

OpenHD/ohd_telemetry/src/AirTelemetry.cpp:276–294  ·  view source on GitHub ↗

Every time the UART configuration changes, we just re-start the UART (if it was already started) This properly handles all the cases, e.g cleaning up an existing uart connection if set.

Source from the content-addressed store, hash-verified

274// was already started) This properly handles all the cases, e.g cleaning up an
275// existing uart connection if set.
276void AirTelemetry::setup_uart() {
277 assert(m_air_settings);
278 using namespace openhd::telemetry;
279 const auto uart_linux_fd = serial_openhd_param_to_linux_fd(
280 m_air_settings->get_settings().fc_uart_connection_type);
281 if (uart_linux_fd.has_value()) {
282 SerialEndpoint::HWOptions options{};
283 options.linux_filename = uart_linux_fd.value();
284 options.baud_rate = m_air_settings->get_settings().fc_uart_baudrate;
285 options.flow_control = m_air_settings->get_settings().fc_uart_flow_control;
286 options.enable_reading = true;
287 m_fc_serial->configure(options, "fc_ser",
288 [this](std::vector<MavlinkMessage> messages) {
289 this->on_messages_fc(messages);
290 });
291 } else {
292 m_fc_serial->disable();
293 }
294}
295
296void AirTelemetry::set_link_handle(std::shared_ptr<OHDLink> link) {
297 m_wb_endpoint = std::make_unique<WBEndpoint>(link, "wb_tx");

Callers

nothing calls this directly

Calls 4

on_messages_fcMethod · 0.95
disableMethod · 0.80
configureMethod · 0.45

Tested by

no test coverage detected