SocketCANDevice.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 Intelligent Industrial Robotics (IIROB) Group,
3  * Institute for Anthropomatics and Robotics (IAR) -
4  * Intelligent Process Control and Robotics (IPR),
5  * Karlsruhe Institute of Technology (KIT)
6  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef SocketCANDevice_INCLUDEDEF_H
22 #define SocketCANDevice_INCLUDEDEF_H
23 //-----------------------------------------------
24 
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <sys/socket.h>
28 #include <sys/ioctl.h>
29 
30 #include <fcntl.h>
31 #include <cerrno>
32 #include <cstring>
33 
34 #include <linux/can.h>
35 #include <linux/can/bcm.h>
36 #include <linux/can/raw.h>
37 
38 #include <net/if.h>
39 #include <string.h>
40 
41 #ifndef PF_CAN
42 #define PF_CAN 29
43 #endif
44 
45 #ifndef AF_CAN
46 #define AF_CAN PF_CAN
47 #endif
48 
49 
50 //-----------------------------------------------
51 
52 #include <iostream>
53 #include <cstdio>
54 #include <libpcan/libpcan.h>
55 #include "ProtocolDevice.h"
56 
57 //-----------------------------------------------
58 
60 
61 private:
62 
63  // ---- private data ---------------------------------------------------- ;
64 
65  // ---- private auxiliary functions ------------------------------------- ;
66 
67 protected:
68  // ---- protected data ---------------------------------------------------- ;
72  unsigned short m_uiQueueSize;
73  unsigned long m_uiTimeOut;
74  char * m_DeviceName;
75 
76 
77  // ---- protected auxiliary functions ------------------------------------- ;
78  int getDeviceError(int iErrorState);
79  int setBaudRate();
80  int setBaudRate(unsigned char iBaudRate);
81  int setMessageId(unsigned long uiMessageId);
82  int clearReadQueue();
83  int reinit(unsigned char ucBaudRateId);
84  int readDevice(CProtocolMessage& rclProtocolMessage);
85  int writeDevice(CProtocolMessage& rclProtocolMessage);
86 
87 public:
88 
89  // ---- public data ----------------------------------------------------- ;
90 
91  // ---- constructors / destructor --------------------------------------- ;
92 
93  // default constructor
95  SocketCANDevice(const SocketCANDevice& rclSocketCANDevice);
97 
98  // ---- operators ------------------------------------------------------- ;
99  // assignment operator
100  SocketCANDevice& operator=(const SocketCANDevice& rclSocketCANDevice);
101 
102  // ---- query functions ------------------------------------------------- ;
103 
104  // ---- modify functions ------------------------------------------------ ;
105 
106  void setQueueSize(unsigned short uiQueueSize);
107  void setTimeOut(unsigned long uiTimeOut);
108 
109  // ---- I/O functions --------------------------------------------------- ;
110 
111  // ---- exec functions -------------------------------------------------- ;
112 
113  int init();
114  int init(unsigned long baudRate);
115  int init(const char* acInitString);
116  int exit();
117  int waitForStartMotionAll();
118 
119 
120 };
121 #endif
int getDeviceError(int iErrorState)
void setTimeOut(unsigned long uiTimeOut)
unsigned short m_uiQueueSize
void setQueueSize(unsigned short uiQueueSize)
int setMessageId(unsigned long uiMessageId)
int readDevice(CProtocolMessage &rclProtocolMessage)
int reinit(unsigned char ucBaudRateId)
SocketCANDevice & operator=(const SocketCANDevice &rclSocketCANDevice)
unsigned long m_uiTimeOut
int writeDevice(CProtocolMessage &rclProtocolMessage)


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:19