Apollo 10.0
自动驾驶开放平台
socket_can_client_raw.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 <unistd.h>
25
26#include <net/if.h>
27#include <sys/ioctl.h>
28#include <sys/socket.h>
29#include <sys/types.h>
30
31#include <linux/can.h>
32#include <linux/can/raw.h>
33
34#include <cstdio>
35#include <cstdlib>
36#include <cstring>
37#include <string>
38#include <vector>
39
40#include "modules/common_msgs/basic_msgs/error_code.pb.h"
41#include "modules/common_msgs/drivers_msgs/can_card_parameter.pb.h"
42
43#include "gflags/gflags.h"
46
51namespace apollo {
52namespace drivers {
53namespace canbus {
54namespace can {
55
61 public:
67 bool Init(const CANCardParameter &parameter) override;
68
72 virtual ~SocketCanClientRaw();
73
80
84 void Stop() override;
85
93 apollo::common::ErrorCode Send(const std::vector<CanFrame> &frames,
94 int32_t *const frame_num) override;
95
103 apollo::common::ErrorCode Receive(std::vector<CanFrame> *const frames,
104 int32_t *const frame_num) override;
105
110 std::string GetErrorString(const int32_t status) override;
111
112 private:
113 int dev_handler_ = 0;
116 can_frame send_frames_[MAX_CAN_SEND_FRAME_LEN];
117 can_frame recv_frames_[MAX_CAN_RECV_FRAME_LEN];
118};
119
120} // namespace can
121} // namespace canbus
122} // namespace drivers
123} // 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 an ESD CAN client which inherites CanClient.
void Stop() override
Stop the ESD CAN client.
apollo::common::ErrorCode Send(const std::vector< CanFrame > &frames, int32_t *const frame_num) override
Send messages
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
bool Init(const CANCardParameter &parameter) override
Initialize the ESD CAN client by specified CAN card parameters.
std::string GetErrorString(const int32_t status) override
Get the error string.
const int32_t MAX_CAN_RECV_FRAME_LEN
const int32_t MAX_CAN_SEND_FRAME_LEN
class register implement
Definition arena_queue.h:37