Apollo  6.0
Open source self driving car software
fake_can_client.h
Go to the documentation of this file.
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/proto/error_code.pb.h"
30 
35 namespace apollo {
36 namespace drivers {
37 namespace canbus {
38 namespace can {
39 
45 class FakeCanClient : public CanClient {
46  public:
52  bool Init(const CANCardParameter &param) override;
53 
57  virtual ~FakeCanClient() = default;
58 
64  apollo::common::ErrorCode Start() override;
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
apollo::common::ErrorCode Receive(std::vector< CanFrame > *frames, int32_t *const frame_num) override
Receive messages.
The class which defines a fake CAN client which inherits CanClient. This fake CAN client is used for ...
Definition: fake_can_client.h:45
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Defines the CanFrame struct and CanClient interface.
apollo::common::ErrorCode Start() override
Start the fake CAN client.
The class which defines the CAN client to send and receive message.
Definition: can_client.h:92
std::string GetErrorString(const int32_t status) override
Get the error string.
bool Init(const CANCardParameter &param) override
Initialize the fake CAN client by specified CAN card parameters.
apollo::common::ErrorCode Send(const std::vector< CanFrame > &frames, int32_t *const frame_num) override
Send messages.
virtual ~FakeCanClient()=default
Destructor.
void Stop() override
Stop the fake CAN client.