CanESD.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef CANESD_INCLUDEDEF_H
19 #define CANESD_INCLUDEDEF_H
20 //-----------------------------------------------
21 
22 #include <libntcan/ntcan.h>
23 // general includes
24 #include <cob_utilities/windows.h>
25 #include <iostream>
26 #include <errno.h>
27 
28 // Headers provided by other cob-packages
29 #include <cob_generic_can/CanItf.h>
30 
31 // Headers provided by other cob-packages which should be avoided/removed
32 #include <cob_utilities/IniFile.h>
33 #include <cob_utilities/Mutex.h>
34 
35 
36 //-----------------------------------------------
40 class CanESD : public CanItf
41 {
42 private:
43 
47  int m_LastID;
51 
53 
54  void initIntern();
55 
56 public:
57  CanESD(const char* cIniFile, bool bObjectMode = false);
58  ~CanESD();
59  bool init_ret();
60  void init(){};
61  bool transmitMsg(CanMsg CMsg, bool bBlocking = true);
62  bool receiveMsgRetry(CanMsg* pCMsg, int iNrOfRetry);
63  bool receiveMsg(CanMsg* pCMsg);
64  bool receiveMsgTimeout(CanMsg* pCMsg, int nMicroSeconds);
65  bool isObjectMode() { return m_bObjectMode; }
66  bool isTransmitError() { return m_bIsTXError; }
67 
68 protected:
69 
79  int invert(int id)
80  {
81  return (~id) & 0x7F8;
82  }
83 
84  int canIdAddGroup(NTCAN_HANDLE handle, int id);
85 
86  std::string GetErrorStr(int ntstatus) const;
87  int readEvent();
88 };
89 //-----------------------------------------------
90 #endif
bool receiveMsgRetry(CanMsg *pCMsg, int iNrOfRetry)
Definition: CanESD.cpp:141
NTCAN_HANDLE m_Handle
Definition: CanESD.h:46
CanESD(const char *cIniFile, bool bObjectMode=false)
Definition: CanESD.cpp:27
Definition: CanESD.h:40
void init()
Definition: CanESD.h:60
bool isObjectMode()
Definition: CanESD.h:65
Definition: CanMsg.h:28
bool receiveMsg(CanMsg *pCMsg)
Definition: CanESD.cpp:184
bool transmitMsg(CanMsg CMsg, bool bBlocking=true)
Definition: CanESD.cpp:108
Definition: CanItf.h:44
~CanESD()
Definition: CanESD.cpp:40
int32_t NTCAN_HANDLE
void initIntern()
Definition: CanESD.cpp:54
int canIdAddGroup(NTCAN_HANDLE handle, int id)
Definition: CanESD.cpp:280
int invert(int id)
Definition: CanESD.h:79
BYTE m_DeviceNr
Definition: CanESD.h:44
bool init_ret()
Definition: CanESD.cpp:47
bool isTransmitError()
Definition: CanESD.h:66
IniFile m_IniFile
Definition: CanESD.h:52
bool receiveMsgTimeout(CanMsg *pCMsg, int nMicroSeconds)
Definition: CanESD.cpp:266
int m_LastID
Definition: CanESD.h:47
std::string GetErrorStr(int ntstatus) const
Definition: CanESD.cpp:300
Mutex m_Mutex
Definition: CanESD.h:50
unsigned char BYTE
bool m_bIsTXError
Definition: CanESD.h:49
int readEvent()
Definition: CanESD.cpp:344
BYTE m_BaudRate
Definition: CanESD.h:45
bool m_bObjectMode
Definition: CanESD.h:48


cob_generic_can
Author(s): Christian Connette
autogenerated on Wed Apr 7 2021 02:11:52