Apollo  6.0
Open source self driving car software
esd_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 <string>
25 #include <vector>
26 
27 #include "esd_can/include/ntcan.h"
28 #include "gflags/gflags.h"
29 #include "modules/common/proto/error_code.pb.h"
32 #include "modules/drivers/canbus/proto/can_card_parameter.pb.h"
33 
38 namespace apollo {
39 namespace drivers {
40 namespace canbus {
41 namespace can {
42 
47 class EsdCanClient : public CanClient {
48  public:
54  bool Init(const CANCardParameter &parameter) override;
55 
59  virtual ~EsdCanClient();
60 
66  apollo::common::ErrorCode Start() override;
67 
71  void Stop() override;
72 
80  apollo::common::ErrorCode Send(const std::vector<CanFrame> &frames,
81  int32_t *const frame_num) override;
82 
90  apollo::common::ErrorCode Receive(std::vector<CanFrame> *const frames,
91  int32_t *const frame_num) override;
92 
97  std::string GetErrorString(const int32_t status) override;
98 
99  private:
100  NTCAN_HANDLE dev_handler_;
101  CANCardParameter::CANChannelId port_;
102  CMSG send_frames_[MAX_CAN_SEND_FRAME_LEN];
103  CMSG recv_frames_[MAX_CAN_RECV_FRAME_LEN];
104 };
105 
106 } // namespace can
107 } // namespace canbus
108 } // namespace drivers
109 } // namespace apollo
const int32_t MAX_CAN_RECV_FRAME_LEN
Definition: canbus_consts.h:35
bool Init(const CANCardParameter &parameter) override
Initialize the ESD CAN client by specified CAN card parameters.
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
The class which defines an ESD CAN client which inherits CanClient.
Definition: esd_can_client.h:47
Defines the CanFrame struct and CanClient interface.
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.
apollo::common::ErrorCode Send(const std::vector< CanFrame > &frames, int32_t *const frame_num) override
Send messages.
const int32_t MAX_CAN_SEND_FRAME_LEN
Definition: canbus_consts.h:34
apollo::common::ErrorCode Start() override
Start the ESD CAN client.
apollo::common::ErrorCode Receive(std::vector< CanFrame > *const frames, int32_t *const frame_num) override
Receive messages.
void Stop() override
Stop the ESD CAN client.