36 int32_t *
const frame_num) {
37 if (frame_num ==
nullptr) {
38 AERROR <<
"frame_num pointer is null";
39 return ErrorCode::CAN_CLIENT_ERROR_BASE;
42 if (
static_cast<size_t>(*frame_num) != frames.size()) {
43 AERROR <<
"frame num is incorrect.";
44 return ErrorCode::CAN_CLIENT_ERROR_FRAME_NUM;
46 for (
size_t i = 0; i < frames.size(); ++i) {
47 ADEBUG <<
"send frame i:" << i;
48 ADEBUG << frames[i].CanFrameString();
49 frame_info_ << frames[i].CanFrameString();
56 int32_t *
const frame_num) {
57 if (frame_num ==
nullptr || frames ==
nullptr) {
58 AERROR <<
"frames or frame_num pointer is null";
59 return ErrorCode::CAN_CLIENT_ERROR_BASE;
61 frames->resize(*frame_num);
62 const int MOCK_LEN = 8;
63 for (
size_t i = 0; i < frames->size(); ++i) {
64 for (
int j = 0; j < MOCK_LEN; ++j) {
65 (*frames)[i].data[j] =
static_cast<uint8_t
>(j);
67 (*frames)[i].id =
static_cast<uint32_t
>(i);
68 (*frames)[i].len = MOCK_LEN;
69 ADEBUG << (*frames)[i].CanFrameString() <<
"frame_num[" << i <<
"]";
71 std::this_thread::sleep_for(std::chrono::milliseconds(10));
apollo::common::ErrorCode Receive(std::vector< CanFrame > *frames, int32_t *const frame_num) override
Receive messages
apollo::common::ErrorCode Send(const std::vector< CanFrame > &frames, int32_t *const frame_num) override
Send messages
std::string GetErrorString(const int32_t status) override
Get the error string.
apollo::common::ErrorCode Start() override
Start the fake CAN client.
void Stop() override
Stop the fake CAN client.
bool Init(const CANCardParameter ¶m) override
Initialize the fake CAN client by specified CAN card parameters.
Defines the FakeCanClient class which inherites CanClient.