1 /*****************************************************************
3 * Copyright 2011 - 2013 Intel Corporation All Rights Reserved.
5 * The source code contained or described herein and all documents related to the
6 * source code("Material") are owned by Intel Corporation or its suppliers or
7 * licensors.Title to the Material remains with Intel Corporation or its
8 * suppliers and licensors.The Material may contain trade secrets and proprietary
9 * and confidential information of Intel Corporation and its suppliers and
10 * licensors, and is protected by worldwide copyright and trade secret laws and
11 * treaty provisions.No part of the Material may be used, copied, reproduced,
12 * modified, published, uploaded, posted, transmitted, distributed, or disclosed
13 * in any way without Intels prior express written permission.
14 * No license under any patent, copyright, trade secret or other intellectual
15 * property right is granted to or conferred upon you by disclosure or delivery
16 * of the Materials, either expressly, by implication, inducement, estoppel or
17 * otherwise.Any license under such intellectual property rights must be
18 * express and approved by Intel in writing.
20 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
21 * notice or any other notice embedded in Materials by Intel or Intels suppliers
22 * or licensors in any way.
23 *****************************************************************/
25 #include "cansocketadapter.h"
26 #include "cansocket.h"
27 #include "canobserver.h"
28 #include "cansocketreader.h"
31 // TODO: handle socket errors
33 CANSocketAdapter::CANSocketAdapter(CANObserver& observer) :
41 CANSocketAdapter::~CANSocketAdapter()
48 bool CANSocketAdapter::start(const char* ifName)
52 if(!mSocket || !mReader) {
56 if(mSocket && mReader && mSocket->start(ifName) && mReader->start()) {
64 void CANSocketAdapter::stop()
80 bool CANSocketAdapter::sendFrame(const can_frame& frame)
86 return mSocket->write(frame, bytesWritten);
91 void CANSocketAdapter::init()
94 mSocket = new CANSocket();
96 mReader = new CANSocketReader(mObserver, *mSocket);