Browse Source

make serial ports easier to debug

Andrew Tridgell 3 năm trước cách đây
mục cha
commit
e439c39eb1

+ 0 - 3
RemoteIDModule/RemoteIDModule.ino

@@ -50,9 +50,6 @@ void setup()
     // Serial for debug printf
     Serial.begin(DEBUG_BAUDRATE);
 
-    Serial.printf("ArduRemoteID version %u.%u %08x\n",
-                  FW_VERSION_MAJOR, FW_VERSION_MINOR, GIT_VERSION);
-
     // Serial1 for MAVLink
     Serial1.begin(MAVLINK_BAUDRATE, SERIAL_8N1, PIN_UART_RX, PIN_UART_TX);
 

+ 7 - 0
RemoteIDModule/mavlink.cpp

@@ -4,6 +4,7 @@
 #include <Arduino.h>
 #include "mavlink.h"
 #include "board_config.h"
+#include "version.h"
 
 #define SERIAL_BAUD 115200
 
@@ -37,12 +38,18 @@ MAVLinkSerial::MAVLinkSerial(HardwareSerial &_serial, mavlink_channel_t _chan) :
 
 void MAVLinkSerial::init(void)
 {
+    // print banner at startup
+    serial.printf("ArduRemoteID version %u.%u %08x\n",
+                  FW_VERSION_MAJOR, FW_VERSION_MINOR, GIT_VERSION);
 }
 
 void MAVLinkSerial::update(void)
 {
     if (mavlink_system.sysid != 0) {
         update_send();
+    } else if (millis() - last_hb_warn_ms >= 2000) {
+        last_hb_warn_ms = millis();
+        serial.printf("Waiting for heartbeat\n");
     }
     update_receive();
 }

+ 1 - 0
RemoteIDModule/mavlink.h

@@ -18,6 +18,7 @@ private:
     HardwareSerial &serial;
     mavlink_channel_t chan;
     uint32_t last_hb_ms;
+    uint32_t last_hb_warn_ms;
 
     void update_receive(void);
     void update_send(void);