Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_DroneCAN/AP_DroneCAN_serial.h
Views: 1798
#pragma once12#include <AP_SerialManager/AP_SerialManager.h>34#ifndef AP_DRONECAN_SERIAL_NUM_PORTS5#define AP_DRONECAN_SERIAL_NUM_PORTS 36#endif78class AP_DroneCAN;910class AP_DroneCAN_Serial11{12public:13/* Do not allow copies */14CLASS_NO_COPY(AP_DroneCAN_Serial);1516AP_DroneCAN_Serial() {}1718AP_Int8 enable;1920void init(AP_DroneCAN *dronecan);21void update(void);2223public:24class Port : public AP_SerialManager::RegisteredPort {25public:26friend class AP_DroneCAN_Serial;27void init(void);2829AP_Int8 node;30AP_Int8 idx;3132private:33bool is_initialized() override {34return true;35}36bool tx_pending() override {37return false;38}3940bool init_buffers(const uint32_t size_rx, const uint32_t size_tx);4142uint32_t txspace() override;43void _begin(uint32_t b, uint16_t rxS, uint16_t txS) override;44size_t _write(const uint8_t *buffer, size_t size) override;45ssize_t _read(uint8_t *buffer, uint16_t count) override;46uint32_t _available() override;47void _end() override {}48void _flush() override {}49bool _discard_input() override;50uint64_t receive_time_constraint_us(uint16_t nbytes) override;5152ByteBuffer *readbuffer;53ByteBuffer *writebuffer;54uint32_t baudrate;55uint32_t last_send_ms;56uint32_t last_size_tx;57uint32_t last_size_rx;58uint64_t last_recv_us;5960HAL_Semaphore sem;61};6263Port ports[AP_DRONECAN_SERIAL_NUM_PORTS];6465private:66AP_DroneCAN *dronecan;6768Canard::Publisher<uavcan_tunnel_Targetted> *targetted;69static void handle_tunnel_targetted(AP_DroneCAN *dronecan,70const CanardRxTransfer& transfer,71const uavcan_tunnel_Targetted &msg);7273static AP_DroneCAN_Serial *serial[HAL_MAX_CAN_PROTOCOL_DRIVERS];74};757677