Apollo 10.0
自动驾驶开放平台
fake_can_client.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
22#pragma once
23
24#include <sstream>
25#include <string>
26#include <vector>
27
28#include "modules/common_msgs/basic_msgs/error_code.pb.h"
30
35namespace apollo {
36namespace drivers {
37namespace canbus {
38namespace can {
39
45class FakeCanClient : public CanClient {
46 public:
52 bool Init(const CANCardParameter &param) override;
53
57 virtual ~FakeCanClient() = default;
58
65
69 void Stop() override;
70
78 apollo::common::ErrorCode Send(const std::vector<CanFrame> &frames,
79 int32_t *const frame_num) override;
80
88 apollo::common::ErrorCode Receive(std::vector<CanFrame> *frames,
89 int32_t *const frame_num) override;
90
95 std::string GetErrorString(const int32_t status) override;
96
97 private:
98 int32_t send_counter_ = 0;
99 int32_t recv_counter_ = 0;
100 std::stringstream frame_info_;
101};
102
103} // namespace can
104} // namespace canbus
105} // namespace drivers
106} // namespace apollo
Defines the CanFrame struct and CanClient interface.
The class which defines the CAN client to send and receive message.
Definition can_client.h:92
The class which defines a fake CAN client which inherits CanClient.
apollo::common::ErrorCode Receive(std::vector< CanFrame > *frames, int32_t *const frame_num) override
Receive messages
virtual ~FakeCanClient()=default
Destructor
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 &param) override
Initialize the fake CAN client by specified CAN card parameters.
class register implement
Definition arena_queue.h:37