CanESD.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #ifndef CANESD_INCLUDEDEF_H
00019 #define CANESD_INCLUDEDEF_H
00020 //-----------------------------------------------
00021 
00022 #include <libntcan/ntcan.h>
00023 // general includes
00024 #include <cob_utilities/windows.h>
00025 #include <iostream>
00026 #include <errno.h>
00027 
00028 // Headers provided by other cob-packages
00029 #include <cob_generic_can/CanItf.h>
00030 
00031 // Headers provided by other cob-packages which should be avoided/removed
00032 #include <cob_utilities/IniFile.h>
00033 #include <cob_utilities/Mutex.h>
00034 
00035 
00036 //-----------------------------------------------
00040 class CanESD : public CanItf
00041 {
00042 private:
00043 
00044     BYTE m_DeviceNr;
00045     BYTE m_BaudRate;
00046     NTCAN_HANDLE m_Handle;
00047     int m_LastID;
00048     bool m_bObjectMode;
00049     bool m_bIsTXError;
00050     Mutex m_Mutex;
00051 
00052     IniFile m_IniFile;
00053 
00054     void initIntern();
00055 
00056 public:
00057     CanESD(const char* cIniFile, bool bObjectMode = false);
00058     ~CanESD();
00059     bool init_ret();
00060     void init(){};
00061     bool transmitMsg(CanMsg CMsg, bool bBlocking = true);
00062     bool receiveMsgRetry(CanMsg* pCMsg, int iNrOfRetry);
00063     bool receiveMsg(CanMsg* pCMsg);
00064     bool receiveMsgTimeout(CanMsg* pCMsg, int nMicroSeconds);
00065     bool isObjectMode() { return m_bObjectMode; }
00066     bool isTransmitError() { return m_bIsTXError; }
00067 
00068 protected:
00069 
00079     int invert(int id)
00080     {
00081             return (~id) & 0x7F8;
00082     }
00083 
00084     int canIdAddGroup(NTCAN_HANDLE handle, int id);
00085 
00086     std::string GetErrorStr(int ntstatus) const;
00087     int readEvent();
00088 };
00089 //-----------------------------------------------
00090 #endif


cob_generic_can
Author(s): Christian Connette
autogenerated on Sat Jun 8 2019 21:02:26