2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "canbusimpl.h"
20 #include "canobserver.h"
21 #include "canadapter.h"
24 //----------------------------------------------------------------------------
26 //----------------------------------------------------------------------------
28 CANBus::Impl::Impl(CANObserver& observer) :
42 bool CANBus::Impl::start(const char* name)
49 return mAdapter ? mAdapter->start(name) : false;
52 void CANBus::Impl::stop()
63 bool CANBus::Impl::sendStandardFrame(const can_frame& frame)
68 struct can_frame frm(frame);
69 frm.can_id &= CAN_SFF_MASK;
70 return mAdapter->sendFrame(frm);
75 bool CANBus::Impl::sendExtendedFrame(const can_frame& frame)
80 struct can_frame frm(frame);
81 frm.can_id &= CAN_EFF_MASK;
82 frm.can_id |= CAN_EFF_FLAG;
83 return mAdapter->sendFrame(frm);
88 void CANBus::Impl::init()
90 mAdapter = CANAdapter::createCANAdapter(mObserver);
93 //----------------------------------------------------------------------------
95 //----------------------------------------------------------------------------
97 CANBus::CANBus(CANObserver& observer) :
98 d(new CANBus::Impl(observer))
113 bool CANBus::start(const char* name)
117 return d ? d->start(name) : false;
128 bool CANBus::sendStandardFrame(const can_frame& frame)
132 return d ? d->sendStandardFrame(frame) : false;
135 bool CANBus::sendExtendedFrame(const can_frame& frame)
139 return d ? d->sendExtendedFrame(frame) : false;