OpcUaCanOpen
CANopen OPC-UA server
SockCanScan.h
Go to the documentation of this file.
1 /*
2  * SockCanScan.h
3  *
4  * Created on: Jul 21, 2011
5  * Author: vfilimon
6  */
7 
8 #ifndef SOCKCANSCAN_H_
9 #define SOCKCANSCAN_H_
10 
11 #include <pthread.h>
12 #include <unistd.h>
13 #ifdef WIN32
14 #include "Winsock2.h"
15 #endif
16 
17 #include <string>
18 using namespace std;
19 #include "CCanAccess.h"
20 
21 class CSockCanScan : public CCanAccess
22 {
23  public:
24 
25  CSockCanScan() : sock(0) { }
26 
27  virtual ~CSockCanScan();
28 
29  virtual bool sendMessage(short cobID, unsigned char len, unsigned char *message);
30  virtual bool sendRemoteRequest(short cobID);
31  virtual bool createBUS(const char *name ,const char *parameters );
32 
33  string &getNamePort() { return name_of_port; }
34  int getHandler() { return sock; }
35  string &getChannel() { return channelName; }
36 
37  private:
38  bool run_can;
39  int sock;
40 
41 #define Timeout 1000
42  pthread_t m_hCanScanThread;
44 
45  void sendErrorMessage(const char *);
46  void sendErrorMessage(const struct can_frame *);
47 
48  void clearErrorMessage();
49 
50  int configureCanboard(const char *,const char *);
51  int openCanPort();
52  void waitCanDriver();
53  static void* CanScanControlThread(void *);
54  string name_of_port;
55  string channelName;
56  string param;
57 };
58 
59 
60 #endif /* SOCKCANSCAN_H_ */