#ifndef USERCAN_H_ #define USERCAN_H_ #include #include #include #define OUSHENCAN_MAX_NUM_ESCS 6 class UserCAN : public AP_HAL::CANProtocol { public: UserCAN(); ~UserCAN(); UserCAN(const UserCAN &other) = delete; UserCAN &operator=(const UserCAN&) = delete; void init(uint8_t driver_index, bool enable_filters) override; void loop(); bool write_frame(uavcan::CanFrame &out_frame, uavcan::MonotonicTime timeout); bool read_frame(uavcan::CanFrame &recv_frame, uavcan::MonotonicTime timeout); uint16_t update_count; // counter increments each time main thread updates outputs uint16_t update_count2; /*struct telemetry_info_t { int16_t rpm;// 速度 float current; float voltage; int16_t temperature; uint16_t EF; } _telemetry[OUSHENCAN_MAX_NUM_ESCS];*/ private: uint8_t send_ID; //uint8_t driver_index; bool _enable_filters; bool _initialized; char _thread_name[9]; uint8_t _driver_index; uavcan::ICanDriver* _can_driver; uint16_t update_count_buffered; // counter when outputs copied to buffer before before sending to ESCs uint16_t update_count_sent; struct motor_rotation_cmd_t { uint8_t data[8]; }; struct sent_command { uint8_t data[4]; }; /* union motor_reply_data1_t { struct PACKED { uint16_t command_code; uint8_t reserve; uint8_t datatype; uint32_t data_reply; }packed_data; uint8_t data[8]; };*/ struct motor_reply_data1_t { uint8_t data[8]; }; uavcan::CanFrame mot_rot_frame1; const uavcan::CanFrame* _select_frames[uavcan::MaxCanIfaces] { }; }; #endif