30#include "modules/common_msgs/basic_msgs/error_code.pb.h"
31#include "modules/common_msgs/drivers_msgs/can_card_parameter.pb.h"
70 std::stringstream output_stream(
"");
72 <<
",len:" <<
static_cast<int>(
len) <<
",data:";
73 for (uint8_t i = 0; i <
len; ++i) {
77 return output_stream.str();
131 int32_t *
const frame_num) = 0;
140 const std::vector<CanFrame> &frames) {
141 CHECK_EQ(frames.size(), 1U)
142 <<
"frames size not equal to 1, actual frame size :" << frames.size();
144 return Send(frames, &n);
155 int32_t *
const frame_num) = 0;
static std::string byte_to_hex(const uint8_t value)
Transform an integer with the size of one byte to its hexadecimal represented by a string.
The class which defines the CAN client to send and receive message.
virtual apollo::common::ErrorCode Send(const std::vector< CanFrame > &frames, int32_t *const frame_num)=0
Send messages
virtual bool Init(const CANCardParameter ¶meter)=0
Initialize the CAN client by specified CAN card parameters.
virtual std::string GetErrorString(const int32_t status)=0
Get the error string.
virtual void Stop()=0
Stop the CAN client.
virtual ~CanClient()=default
Destructor
CanClient()=default
Constructor
virtual apollo::common::ErrorCode Receive(std::vector< CanFrame > *const frames, int32_t *const frame_num)=0
Receive messages
virtual apollo::common::ErrorCode SendSingleFrame(const std::vector< CanFrame > &frames)
Send a single message.
virtual apollo::common::ErrorCode Start()=0
Start the CAN client.
bool is_started_
The CAN client is started.
const int CAN_ERROR_FRAME_NUM
const int CAN_ERROR_SEND_FAILED
const int CAN_ERROR_OPEN_DEVICE_FAILED
const int CAN_RESULT_SUCC
const int CAN_ERROR_RECV_FAILED
The class which defines the information to send and receive.
std::string CanFrameString() const
CanFrame string including essential information about the message.
uint8_t len
Message length
struct timeval timestamp
Time stamp
uint8_t data[8]
Message content