cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaSocketCAN.h
Go to the documentation of this file.
1 /*
2 
3  Author(s): Simon Leonard
4  Created on: Dec 02 2009
5 
6  (C) Copyright 2009 Johns Hopkins University (JHU), All Rights
7  Reserved.
8 
9 --- begin cisst license - do not edit ---
10 
11 This software is provided "as is" under an open source license, with
12 no warranty. The complete license can be found in license.txt and
13 http://www.cisst.org/cisst/license.txt.
14 
15 --- end cisst license ---
16 */
17 
18 
19 #ifndef _osaSocketCAN_h
20 #define _osaSocketCAN_h
21 
22 #include <sys/socket.h>
23 #include <sys/types.h>
24 #include <sys/ioctl.h>
25 
26 #include <linux/can.h>
27 #include <linux/can/raw.h>
28 #include <linux/can/error.h>
29 #include <linux/if.h>
30 
31 #include <sawCANBus/osaCANBus.h> // the CAN base class
33 
35 
46 
47  private:
48 
50  std::string devicename;
51 
53  int canfd;
54 
56 
60  static const size_t MAX_NUM_FILTERS = 32;
61  struct can_filter filters[MAX_NUM_FILTERS];
62  size_t filterscnt;
63 
64 public:
65 
67 
72  osaSocketCAN( const std::string& devicename,
73  osaCANBus::Rate rate,
75 
77  ~osaSocketCAN();
78 
80 
84 
87 
89 
95  osaCANBus::Errno Send( const osaCANBusFrame& frame,
97 
99 
107 
110 
111 };
112 
113 #endif
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
virtual osaCANBus::Errno AddFilter(const osaCANBus::Filter &filter)=0
Add a CAN filter to the device.
virtual osaCANBus::Errno Open()=0
Open the CAN device.
virtual osaCANBus::Errno Close()=0
Close the CAN device.
Errno
The different CAN rates.
Definition: osaCANBus.h:25
CAN frame implementation.
Definition: osaCANBusFrame.h:16
Generic CAN bus.
Definition: osaCANBus.h:15
Flags
Definition: osaCANBus.h:28
virtual osaCANBus::Errno Send(const osaCANBusFrame &frame, osaCANBus::Flags flags=osaCANBus::MSG_NOFLAG)=0
Send a CAN frame on the bus.
Definition: osaCANBus.h:28
Loopback
Definition: osaCANBus.h:32
A Real Time Socket CAN device.
Definition: osaSocketCAN.h:45
Definition: osaCANBus.h:32
virtual osaCANBus::Errno Recv(osaCANBusFrame &frame, osaCANBus::Flags flags=osaCANBus::MSG_NOFLAG)=0
Receive a CAN frame.
Rate
The different CAN rates.
Definition: osaCANBus.h:20
Definition: osaCANBus.h:41