LCOV - code coverage report
Current view: top level - AP_DroneCAN - AP_DroneCAN_serial.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 4 10 40.0 %
Date: 2026-09-09 11:02:08 Functions: 4 8 50.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <AP_SerialManager/AP_SerialManager.h>
       4             : 
       5             : #ifndef AP_DRONECAN_SERIAL_NUM_PORTS
       6             : #define AP_DRONECAN_SERIAL_NUM_PORTS 3
       7             : #endif
       8             : 
       9             : class AP_DroneCAN;
      10             : 
      11             : class AP_DroneCAN_Serial
      12             : {
      13             : public:
      14             :     /* Do not allow copies */
      15             :     CLASS_NO_COPY(AP_DroneCAN_Serial);
      16             : 
      17          20 :     AP_DroneCAN_Serial() {}
      18             : 
      19             :     AP_Int8 enable;
      20             : 
      21             :     void init(AP_DroneCAN *dronecan);
      22             :     void update(void);
      23             : 
      24             : public:
      25             :     class Port : public AP_SerialManager::RegisteredPort {
      26             :     public:
      27             :         friend class AP_DroneCAN_Serial;
      28             :         void init(void);
      29             : 
      30             :         AP_Int8 node;
      31             :         AP_Int8 idx;
      32             : 
      33             :     private:
      34           0 :         bool is_initialized() override {
      35           0 :             return true;
      36             :         }
      37           0 :         bool tx_pending() override {
      38           0 :             return false;
      39             :         }
      40             : 
      41             :         bool init_buffers(const uint32_t size_rx, const uint32_t size_tx);
      42             : 
      43             :         uint32_t txspace() override;
      44             :         void _begin(uint32_t b, uint16_t rxS, uint16_t txS) override;
      45             :         size_t _write(const uint8_t *buffer, size_t size) override;
      46             :         ssize_t _read(uint8_t *buffer, uint16_t count) override;
      47             :         uint32_t _available() override;
      48           0 :         void _end() override {}
      49           0 :         void _flush() override {}
      50             :         bool _discard_input() override;
      51             :         uint64_t receive_time_constraint_us(uint16_t nbytes) override;
      52             : 
      53             :         ByteBuffer *readbuffer;
      54             :         ByteBuffer *writebuffer;
      55             :         uint32_t baudrate;
      56             :         uint32_t last_send_ms;
      57             :         uint32_t last_size_tx;
      58             :         uint32_t last_size_rx;
      59             :         uint64_t last_recv_us;
      60             : 
      61             :         // statistics
      62             :         uint32_t tx_stats_bytes;
      63             :         uint32_t rx_stats_bytes;
      64             :         uint32_t rx_stats_dropped_bytes;
      65             : 
      66             :         HAL_Semaphore sem;
      67             : 
      68             :     protected:
      69             : 
      70             : #if HAL_UART_STATS_ENABLED
      71             :         // Getters for cumulative tx and rx counts
      72          66 :         uint32_t get_total_tx_bytes() const override { return tx_stats_bytes; }
      73          66 :         uint32_t get_total_rx_bytes() const override { return rx_stats_bytes; }
      74          66 :         uint32_t get_total_dropped_rx_bytes() const override { return rx_stats_dropped_bytes; }
      75             : #endif
      76             :     };
      77             : 
      78             :     Port ports[AP_DRONECAN_SERIAL_NUM_PORTS];
      79             : 
      80             : private:
      81             :     AP_DroneCAN *dronecan;
      82             : 
      83             :     Canard::Publisher<uavcan_tunnel_Targetted> *targetted;
      84             :     static void handle_tunnel_targetted(AP_DroneCAN *dronecan,
      85             :                                         const CanardRxTransfer& transfer,
      86             :                                         const uavcan_tunnel_Targetted &msg);
      87             : 
      88             :     static AP_DroneCAN_Serial *serial[HAL_MAX_CAN_PROTOCOL_DRIVERS];
      89             : };

Generated by: LCOV version 1.14