2 Copyright (C) 2012 Intel Corporation
3 Copyright (C) 2015 Cogent Embedded Inc.
4 Copyright (C) 2015 Renesas Electronics Corporation
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "canbusimpl.h"
22 #include "canobserver.h"
23 #include "canadapter.h"
26 CANBusImpl::CANBusImpl(CANObserver& observer) :
33 CANBusImpl::~CANBusImpl()
40 bool CANBusImpl::start(const char* name)
47 return mAdapter ? mAdapter->start(name) : false;
50 void CANBusImpl::stop()
61 bool CANBusImpl::sendStandardFrame(const can_frame& frame)
66 struct can_frame frm(frame);
67 frm.can_id &= CAN_SFF_MASK;
68 return mAdapter->sendFrame(frm);
73 bool CANBusImpl::sendExtendedFrame(const can_frame& frame)
78 struct can_frame frm(frame);
79 frm.can_id &= CAN_EFF_MASK;
80 frm.can_id |= CAN_EFF_FLAG;
81 return mAdapter->sendFrame(frm);
86 void CANBusImpl::init()
88 mAdapter = CANAdapter::createCANAdapter(mObserver);
91 bool CANBusImpl::registerCyclicMessageForReceive(int canId, double minCycleTime, double maxCycleTime)
94 return mAdapter->registerCyclicMessageForReceive(canId, minCycleTime, maxCycleTime);
99 bool CANBusImpl::unregisterMessageForReceive(int canId)
102 return mAdapter->unregisterMessageForReceive(canId);