Browse Source

GCS_MAVLink: integrate Serial Manager instance

master
Randy Mackay 10 years ago
parent
commit
d738eda59d
  1. 2
      libraries/GCS_MAVLink/GCS.h
  2. 6
      libraries/GCS_MAVLink/GCS_Common.cpp

2
libraries/GCS_MAVLink/GCS.h

@ -71,7 +71,7 @@ public:
GCS_MAVLINK(); GCS_MAVLINK();
void update(void (*run_cli)(AP_HAL::UARTDriver *)); void update(void (*run_cli)(AP_HAL::UARTDriver *));
void init(AP_HAL::UARTDriver *port, mavlink_channel_t mav_chan); void init(AP_HAL::UARTDriver *port, mavlink_channel_t mav_chan);
void setup_uart(const AP_SerialManager& serial_manager, AP_SerialManager::SerialProtocol protocol); void setup_uart(const AP_SerialManager& serial_manager, AP_SerialManager::SerialProtocol protocol, uint8_t instance);
void send_message(enum ap_message id); void send_message(enum ap_message id);
void send_text(gcs_severity severity, const char *str); void send_text(gcs_severity severity, const char *str);
void send_text_P(gcs_severity severity, const prog_char_t *str); void send_text_P(gcs_severity severity, const prog_char_t *str);

6
libraries/GCS_MAVLink/GCS_Common.cpp

@ -65,12 +65,12 @@ GCS_MAVLINK::init(AP_HAL::UARTDriver *port, mavlink_channel_t mav_chan)
setup a UART, handling begin() and init() setup a UART, handling begin() and init()
*/ */
void void
GCS_MAVLINK::setup_uart(const AP_SerialManager& serial_manager, AP_SerialManager::SerialProtocol protocol) GCS_MAVLINK::setup_uart(const AP_SerialManager& serial_manager, AP_SerialManager::SerialProtocol protocol, uint8_t instance)
{ {
// search for serial port // search for serial port
AP_HAL::UARTDriver *uart; AP_HAL::UARTDriver *uart;
uart = serial_manager.find_serial(protocol); uart = serial_manager.find_serial(protocol, instance);
if (uart == NULL) { if (uart == NULL) {
// return immediately if not found // return immediately if not found
return; return;
@ -78,7 +78,7 @@ GCS_MAVLINK::setup_uart(const AP_SerialManager& serial_manager, AP_SerialManager
// get associated mavlink channel // get associated mavlink channel
mavlink_channel_t mav_chan; mavlink_channel_t mav_chan;
if (!serial_manager.get_mavlink_channel(protocol, mav_chan)) { if (!serial_manager.get_mavlink_channel(protocol, instance, mav_chan)) {
// return immediately in unlikely case mavlink channel cannot be found // return immediately in unlikely case mavlink channel cannot be found
return; return;
} }

Loading…
Cancel
Save