25 #define NUM_BYTE_SEND 79 //Total amount of data sent to relayboard in one message, is now passed and set as protocol-version argument in constructor 27 #define RS422_BAUDRATE 420000 28 #define RS422_RX_BUFFERSIZE 1024 29 #define RS422_TX_BUFFERSIZE 1024 31 #define RS422_TIMEOUT 0.025 33 #define NUM_BYTE_REC_MAX 120 34 #define NUM_BYTE_REC_HEADER 4 //Header bytes, which are used to identify the beginning of a new received message {0x02, 0x80, 0xD6, 0x02} 35 #define NUM_BYTE_REC_CHECKSUM 2 //checksum for message, that is built as the sum of all data bytes contained in the message 36 #define NUM_BYTE_REC 104 //Total amount of data bytes in a received message (from the relayboard) 38 #define NUM_BYTE_SEND_RELAYBOARD_14 88 39 #define NUM_BYTE_REC_RELAYBOARD_14 124 78 static int siNoMsgCnt = 0;
87 const int c_iSizeBuffer = 4096;
91 int iNrBytesInQueue, iNrBytesRead, iDataStart;
92 unsigned char cDat[c_iSizeBuffer];
93 unsigned char cTest[4] = {0x02, 0x80, 0xD6, 0x02};
99 if(iNrBytesInQueue < c_iNrBytesMin)
119 for(i = (iNrBytesRead - c_iNrBytesMin); i >= 0 ; i--)
122 if((cDat[i] == cTest[0]) && (cDat[i+1] == cTest[1]) && (cDat[i+2] == cTest[2]) && (cDat[i+3] == cTest[3]))
371 for(i = 0; i < 20; i++)
385 for(i = 0; i < 60; i++)
464 const int c_iStartCheckSum = iNumByteRec;
467 unsigned int iTxCheckSum;
468 unsigned int iCheckSum;
473 iTxCheckSum = (cMsg[c_iStartCheckSum + 1] << 8) | cMsg[c_iStartCheckSum];
476 for(i = 0; i < c_iStartCheckSum; i++)
479 iCheckSum += cMsg[i];
482 if(iCheckSum != iTxCheckSum)
507 for(i = 0; i < 4; i++)
519 m_iDigIn = (cMsg[iCnt + 1] << 8) | cMsg[iCnt];
#define NUM_BYTE_REC_RELAYBOARD_14
unsigned char m_cTextDisplay[60]
int m_iVelCmdMotRightEncS
void setBufferSize(int ReadBufSize, int WriteBufSize)
int m_iRelBoardAnalogIn[4]
int m_iUSBoardSensorActive
int m_iVelCmdMotRearLeftEncS
void convDataToSendMsg(unsigned char cMsg[])
void setTimeout(double Timeout)
int m_iVelCmdMotRearRightEncS
#define RS422_TX_BUFFERSIZE
bool lock(unsigned int uiTimeOut=INFINITE)
void setDeviceName(const char *Name)
#define NUM_BYTE_REC_HEADER
int writeIO(const char *Buffer, int Length)
int setDigOut(int iChannel, bool bOn)
#define RS422_RX_BUFFERSIZE
int readBlocking(char *Buffer, int Length)
int m_iRelBoardBattVoltage
#define NUM_BYTE_SEND_RELAYBOARD_14
bool convRecMsgToData(unsigned char cMsg[])
void setBaudRate(int BaudRate)
int m_iRelBoardTempSensor
std::string m_sNumComPort
int getAnalogIn(int *piAnalogIn)
SerRelayBoard(std::string ComPort, int ProtocolVersion=1)
#define NUM_BYTE_REC_CHECKSUM