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.
| 274 | // was already started) This properly handles all the cases, e.g cleaning up an |
| 275 | // existing uart connection if set. |
| 276 | void 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 | |
| 296 | void AirTelemetry::set_link_handle(std::shared_ptr<OHDLink> link) { |
| 297 | m_wb_endpoint = std::make_unique<WBEndpoint>(link, "wb_tx"); |
nothing calls this directly
no test coverage detected