00001 /* ----------------------------------------------------------------------------------- 00002 * 00003 * Copyright (c) 2005 Neobotix (www.neobotix.de) 00004 * 00005 * This software is allowed to be used and modified only in association with a Neobotix 00006 * robot platform. It is allowed to include the software into applications and 00007 * to distribute it with a Neobotix robot platform. 00008 * It is not allowed to distribute the software without a Neobotix robot platform. 00009 * 00010 * This software is provided WITHOUT ANY WARRANTY; without even the 00011 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the Neobotix License (Version 1.0) for more details. 00013 * 00014 * You should have received a copy of the Neobotix License 00015 * along with this software; if not, write to the 00016 * Gesellschaft fuer Produktionssysteme, Neobotix, Nobelstrasse 12, 70569 Stuttgart, Germany 00017 * 00018 * ----------------------------------------------------------------------------------- 00019 */ 00020 00021 00022 #ifndef CANESD_INCLUDEDEF_H 00023 #define CANESD_INCLUDEDEF_H 00024 //----------------------------------------------- 00025 //#include <windows.h> 00026 #include <iostream> 00027 #include <cstdio> 00028 #include <errno.h> 00029 #include <cob_forcetorque/CanItf.h> 00030 #include <libntcan/ntcan.h> 00031 //#include <Neobotix/Utilities/IniFile.h> 00032 #include <cob_forcetorque/Mutex.h> 00033 00034 //----------------------------------------------- 00039 class CanESD : public CanItf 00040 { 00041 private: 00042 BYTE m_DeviceNr; 00043 BYTE m_BaudRate; 00044 int m_Handle; 00045 int m_LastID; 00046 bool m_bObjectMode; 00047 bool m_bIsTXError; 00048 Mutex m_Mutex; 00049 00050 //IniFile m_IniFile; 00051 00052 void initIntern(); 00053 00054 public: 00055 CanESD(const char* cIniFile, bool bObjectMode = false); 00056 ~CanESD(); 00057 void init(){}; 00058 bool transmitMsg(CanMsg CMsg, bool bBlocking = true); 00059 bool receiveMsgRetry(CanMsg* pCMsg, int iNrOfRetry); 00060 bool receiveMsg(CanMsg* pCMsg); 00061 bool isObjectMode() { return m_bObjectMode; } 00062 bool isTransmitError() { return m_bIsTXError; } 00063 protected: 00064 00074 int invert(int id) 00075 { 00076 //return (~id) & 0x7FF; 00077 return (~id) & 0x7F8; 00078 } 00079 00080 int canIdAddGroup(int handle, int id); 00081 00082 std::string GetErrorStr(int ntstatus) const; 00083 int readEvent(); 00084 }; 00085 //----------------------------------------------- 00086 #endif