Apollo 10.0
自动驾驶开放平台
apollo::drivers::canbus::CanReceiver< SensorType > 模板类 参考

CAN receiver. 更多...

#include <can_receiver.h>

apollo::drivers::canbus::CanReceiver< SensorType > 的协作图:

Public 成员函数

 CanReceiver ()=default
 Constructor.
 
virtual ~CanReceiver ()=default
 Destructor.
 
common::ErrorCode Init (CanClient *can_client, MessageManager< SensorType > *pt_manager, bool enable_log)
 Initialize by a CAN client, message manager.
 
bool IsRunning () const
 Get the working status of this CAN receiver.
 
bool IsFinishRecvOnce () const
 Get the receive status in once receive buf.
 
::apollo::common::ErrorCode Start ()
 Start the CAN receiver.
 
void Stop ()
 Stop the CAN receiver.
 

详细描述

template<typename SensorType>
class apollo::drivers::canbus::CanReceiver< SensorType >

CAN receiver.

在文件 can_receiver.h54 行定义.

构造及析构函数说明

◆ CanReceiver()

template<typename SensorType >
apollo::drivers::canbus::CanReceiver< SensorType >::CanReceiver ( )
default

Constructor.

◆ ~CanReceiver()

template<typename SensorType >
virtual apollo::drivers::canbus::CanReceiver< SensorType >::~CanReceiver ( )
virtualdefault

Destructor.

成员函数说明

◆ Init()

template<typename SensorType >
apollo::common::ErrorCode apollo::drivers::canbus::CanReceiver< SensorType >::Init ( CanClient can_client,
MessageManager< SensorType > *  pt_manager,
bool  enable_log 
)

Initialize by a CAN client, message manager.

参数
can_clientThe CAN client to use for receiving messages.
pt_managerThe message manager which can parse and get protocol data by message id.
enable_logIf log the essential information during running.
返回
An error code indicating the status of this initialization.

在文件 can_receiver.h122 行定义.

124 {
125 can_client_ = can_client;
126 pt_manager_ = pt_manager;
127 enable_log_ = enable_log;
128 if (can_client_ == nullptr) {
129 AERROR << "Invalid can client.";
130 return ::apollo::common::ErrorCode::CANBUS_ERROR;
131 }
132 if (pt_manager_ == nullptr) {
133 AERROR << "Invalid protocol manager.";
134 return ::apollo::common::ErrorCode::CANBUS_ERROR;
135 }
136 is_init_ = true;
137 return ::apollo::common::ErrorCode::OK;
138}
#define AERROR
Definition log.h:44

◆ IsFinishRecvOnce()

template<typename SensorType >
bool apollo::drivers::canbus::CanReceiver< SensorType >::IsFinishRecvOnce ( ) const

Get the receive status in once receive buf.

To check if it is running.

返回
If this CAN receiver is running.

在文件 can_receiver.h203 行定义.

203 {
204 ADEBUG << "is_finish_recv_once_ state is " << is_finish_recv_once_.load();
205 return is_finish_recv_once_.load();
206}
#define ADEBUG
Definition log.h:41

◆ IsRunning()

template<typename SensorType >
bool apollo::drivers::canbus::CanReceiver< SensorType >::IsRunning ( ) const

Get the working status of this CAN receiver.

To check if it is running.

返回
If this CAN receiver is running.

在文件 can_receiver.h198 行定义.

198 {
199 return is_running_.load();
200}

◆ Start()

template<typename SensorType >
apollo::common::ErrorCode apollo::drivers::canbus::CanReceiver< SensorType >::Start ( )

Start the CAN receiver.

返回
The error code indicating the status of this action.

在文件 can_receiver.h209 行定义.

209 {
210 if (is_init_ == false) {
211 return ::apollo::common::ErrorCode::CANBUS_ERROR;
212 }
213 is_running_.exchange(true);
214
215 async_result_ = cyber::Async(&CanReceiver<SensorType>::RecvThreadFunc, this);
216 return ::apollo::common::ErrorCode::OK;
217}

◆ Stop()

template<typename SensorType >
void apollo::drivers::canbus::CanReceiver< SensorType >::Stop ( )

Stop the CAN receiver.

在文件 can_receiver.h220 行定义.

220 {
221 if (IsRunning()) {
222 AINFO << "Stopping can client receiver ...";
223 is_running_.exchange(false);
224 async_result_.wait();
225 } else {
226 AINFO << "Can client receiver is not running.";
227 }
228 AINFO << "Can client receiver stopped [ok].";
229}
bool IsRunning() const
Get the working status of this CAN receiver.
#define AINFO
Definition log.h:42

该类的文档由以下文件生成: