17 boost::mutex::scoped_lock lock(mutex_);
19 LOG(
"ID: " << msg.
id);
25 :
Layer(device +
" Layer"), driver_(driver), device_(device), loopback_(loopback) { assert(driver_); }
28 if(current_state >
Init){
29 if(!driver_->getState().isReady()) status.
error(
"CAN not ready");
33 if(current_state >
Init){
34 if(!driver_->getState().isReady()) status.
error(
"CAN not ready");
41 report.
error(
"CAN layer not ready");
50 if(driver_->translateError(s.
internal_error, desc)) report.
add(
"internal_error_desc", desc);
51 std::stringstream sstr;
54 boost::mutex::scoped_lock lock(mutex_);
55 for(
size_t i=0; i < last_error_.
dlc; ++i){
56 sstr << (
unsigned int) last_error_.
data[i] <<
" ";
59 report.
add(
"can_error_frame", sstr.str());
67 status.
warn(
"CAN thread already running");
68 }
else if(!driver_->init(device_, loopback_)) {
69 status.
error(
"CAN init failed");
77 status.
error(
"CAN init timed out");
80 if(!driver_->getState().isReady()){
81 status.
error(
"CAN is not ready");
86 error_listener_.reset();
89 status.
warn(
"CAN shutdown timed out");
101 if(!driver_->getState().isReady()){
CANLayer(const can::DriverInterfaceSharedPtr &driver, const std::string &device, bool loopback)
const void warn(const std::string &r)
boost::array< value_type, 8 > data
virtual void handleRecover(LayerStatus &status)
const std::string device_
can::DriverInterfaceSharedPtr driver_
virtual void handleInit(LayerStatus &status)
can::FrameListenerConstSharedPtr error_listener_
boost::shared_ptr< boost::thread > thread_
boost::shared_ptr< DriverInterface > DriverInterfaceSharedPtr
CommInterface::FrameListenerConstSharedPtr FrameListenerConstSharedPtr
enum can::State::DriverState driver_state
virtual void handleWrite(LayerStatus &status, const LayerState ¤t_state)
virtual bool isReady() const
void handleFrame(const can::Frame &msg)
virtual void handleHalt(LayerStatus &status)
virtual void handleShutdown(LayerStatus &status)
virtual void handleRead(LayerStatus &status, const LayerState ¤t_state)
void add(const std::string &key, const T &value)
const void error(const std::string &r)
virtual void handleDiag(LayerReport &report)
unsigned int internal_error
boost::system::error_code error_code