82         int iHomeDigIn = 0x0001; 
    91                 iTemp1 = (msg.
getAt(3) << 24) | (msg.
getAt(2) << 16)
    95                         PosMotIncrToPosGearRad(iTemp1);
    97                 iTemp2 = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   101                         VelMotIncrPeriodToVelGearRadS(iTemp2);
   112                 if( (msg.
getAt(0) == 
'P') && (msg.
getAt(1) == 
'X') ) 
   116                 else if( (msg.
getAt(0) == 
'P') && (msg.
getAt(1) == 
'A') ) 
   120                 else if( (msg.
getAt(0) == 
'J') && (msg.
getAt(1) == 
'V') ) 
   124                 else if( (msg.
getAt(0) == 
'B') && (msg.
getAt(1) == 
'G') ) 
   128                 else if( (msg.
getAt(0) == 
'U') && (msg.
getAt(1) == 
'M') ) 
   130                         iDigIn = 0x1FFFFF & ( (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   134                 else if( (msg.
getAt(0) == 
'I') && (msg.
getAt(1) == 
'P') ) 
   136                         iDigIn = 0x1FFFFF & ( (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   138                         iDigIn = 0x1FFFFF & ( (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   141                         if( (iDigIn & iHomeDigIn) != 0x0000 )
   147                 else if( (msg.
getAt(0) == 
'S') && (msg.
getAt(1) == 
'R') ) 
   157                 else if( (msg.
getAt(0) == 
'M') && (msg.
getAt(1) == 
'F') ) 
   159                         iFailure = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   166                 else if( (msg.
getAt(0) == 
'U') && (msg.
getAt(1) == 
'M') )
   168                         iPara = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   171                         std::cout << 
"um " << iPara << std::endl;
   174                 else if( (msg.
getAt(0) == 
'P') && (msg.
getAt(1) == 
'M') )
   176                         iPara = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   179                         std::cout << 
"pm " << iPara << std::endl;
   182                 else if( (msg.
getAt(0) == 
'A') && (msg.
getAt(1) == 
'C') )
   184                         iPara = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   187                         std::cout << 
"ac " << iPara << std::endl;
   190                 else if( (msg.
getAt(0) == 
'D') && (msg.
getAt(1) == 
'C') )
   192                         iPara = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   195                         std::cout << 
"dc " << iPara << std::endl;
   197                 else if( (msg.
getAt(0) == 
'H') && (msg.
getAt(1) == 
'M') )
   200                         if(msg.
getAt(4) == 0)
   206                 else if( (msg.
getAt(0) == 
'I') && (msg.
getAt(1) == 
'Q') )
   209                         iVal = (msg.
getAt(7) << 24) | (msg.
getAt(6) << 16)
   231                 if( (msg.
getAt(0) >> 5) == 0) { 
   235                 } 
else if( (msg.
getAt(0) & 0xE2) == 0x40) { 
   239                 } 
else if( (msg.
getAt(0) >> 5) == 4) { 
   240                         unsigned int iErrorNum = (msg.
getAt(4) | msg.
getAt(5) << 8 | msg.
getAt(6) << 16 | msg.
getAt(7) << 24);
   280                 if( (Msg.
getAt(0) == 
'P') && (Msg.
getAt(1) == 
'X') )
   282                         iPosCnt = (Msg.
getAt(7) << 24) | (Msg.
getAt(6) << 16)
   292                         std::cout << 
"CanDriveHarmonica: initial position not set" << std::endl;
   365                 if( (Msg.
getAt(0) == 
'S') && (Msg.
getAt(1) == 
'R') )
   367                         iStatus = (Msg.
getAt(7) << 24) | (Msg.
getAt(6) << 16)
   376                         std::cout << 
"CanDriveHarmonica::enableMotor(): No answer on status request" << std::endl;
   401         msg.
set(1,0,0,0,0,0,0,0);
   423         if (bStarted == 
true)
   431                 const int c_iHeartbeatTimeMS = 1000;
   432                 const int c_iNMTNodeID = 0x00;
   580                 if( (Msg.
getAt(0) == 
'H') && (Msg.
getAt(1) == 
'M') )
   583                         if(Msg.
getAt(4) == 0)
   586                                 std::cout << 
"Got Homing-Signal "  << std::endl;
   602                 std::cout << 
"Homing failed - limit switch " << iNrDrive << 
" not reached" << std::endl;
   607                 std::cout << 
"Homing successful - limit switch " << iNrDrive << 
" ok" << std::endl;
   619         int iVelEncIncrPeriod;
   662         msg.
set(0,0,0,0,0,0,0,0);
   669         int iVelEncIncrPeriod;
   676                 std::cout << 
"SteerVelo asked for " << iVelEncIncrPeriod << 
" EncIncrements" << std::endl;
   682                 std::cout << 
"SteerVelo asked for " << iVelEncIncrPeriod << 
" EncIncrements" << std::endl;
   695         msg.
set(0,0,0,0,0,0,0,0);
   701         msg.
set(0x00,0,0,0,0,0,0,0);
   709                         << 
" is too large: " << dt << 
" s" << std::endl;
   746                                                                 int* piTorqueCtrl, 
int* piStatusCtrl)
   761         msg.
set(0,0,0,0,0,0,0,0);
   772         msg.
set(0x00,0,0,0,0,0,0,0);
   803                                         " has no can communication for " << dWatchTime << 
" s." << std::endl;
   893         cIndex[1] = (iIndex >> 8) & 0x3F;  
   896         cInt[1] = iData >> 8;
   897         cInt[2] = iData >> 16;
   898         cInt[3] = iData >> 24;
   900         CMsgTr.
set(cCmdChar1, cCmdChar2, cIndex[0], cIndex[1], cInt[0], cInt[1], cInt[2], cInt[3]);
   910         char* pTempFloat = NULL;
   917         cIndex[1] = (iIndex >> 8) & 0x3F;       
   918         cIndex[1] = cIndex[1] | 0x80;           
   920         pTempFloat = (
char*)&fData;
   921         for( 
int i=0; i<4; i++ )
   922                 cFloat[i] = pTempFloat[i];
   924         CMsgTr.
set(cCmdChar1, cCmdChar2, cIndex[0], cIndex[1], cFloat[0], cFloat[1], cFloat[2], cFloat[3]);
   936         const int ciAbortTransferReq = 0x04 << 5;
   941         unsigned char cMsg[8];
   943         cMsg[0] = ciAbortTransferReq;
   945         cMsg[2] = iObjIndex >> 8;
   946         cMsg[3] = iObjSubIndex;
   947         cMsg[4] = iErrorCode;
   948         cMsg[5] = iErrorCode >> 8;
   949         cMsg[6] = iErrorCode >> 16;
   950         cMsg[7] = iErrorCode >> 24;
   952         CMsgTr.
set(cMsg[0], cMsg[1], cMsg[2], cMsg[3], cMsg[4], cMsg[5], cMsg[6], cMsg[7]);
   958         std::cout << 
"SDO Abort Transfer received with error code: " << iErrorCode;
   966         const int ciInitUploadReq = 0x40;
   971         unsigned char cMsg[8];
   973         cMsg[0] = ciInitUploadReq;
   975         cMsg[2] = iObjIndex >> 8;
   976         cMsg[3] = iObjSubIndex;
   982         CMsgTr.
set(cMsg[0], cMsg[1], cMsg[2], cMsg[3], cMsg[4], cMsg[5], cMsg[6], cMsg[7]);
   991         const int ciInitDownloadReq = 0x20;
   992         const int ciNrBytesNoData = 0x00;
   993         const int ciExpedited = 0x02;
   994         const int ciDataSizeInd = 0x01;
   999         unsigned char cMsg[8];
  1001         cMsg[0] = ciInitDownloadReq | (ciNrBytesNoData << 2) | ciExpedited | ciDataSizeInd;
  1002         cMsg[1] = iObjIndex;
  1003         cMsg[2] = iObjIndex >> 8;
  1004         cMsg[3] = iObjSubIndex;
  1006         cMsg[5] = iData >> 8;
  1007         cMsg[6] = iData >> 16;
  1008         cMsg[7] = iData >> 24;
  1010         CMsgTr.
set(cMsg[0], cMsg[1], cMsg[2], cMsg[3], cMsg[4], cMsg[5], cMsg[6], cMsg[7]);
  1017         *pIndex = (CMsg.
getAt(2) << 8) | CMsg.
getAt(1);
  1018         *pSubindex = CMsg.
getAt(3);
  1024         int iData = (CMsg.
getAt(7) << 24) | (CMsg.
getAt(6) << 16) |
  1041                 if( (msg.
getAt(0) & 0x01) == 1) {
  1055         int numEmptyBytes = 0;
  1062                 std::cout << 
"Toggle Bit error, send Abort SDO with \"Toggle bit not alternated\" error" << std::endl;
  1067         if( (msg.
getAt(0) & 0x01) == 0x00) { 
  1074         numEmptyBytes = (msg.
getAt(0) >> 1) & 0x07;
  1077         for(
int i=1; i<=7-numEmptyBytes; i++) {
  1095         int iConfirmSegment = 0x60; 
  1096         iConfirmSegment = iConfirmSegment | (toggleBit << 4); 
  1101         unsigned char cMsg[8];
  1103         cMsg[0] = iConfirmSegment;
  1112         CMsgTr.
set(cMsg[0], cMsg[1], cMsg[2], cMsg[3], cMsg[4], cMsg[5], cMsg[6], cMsg[7]);
  1121                 std::cout << 
"WARNING: SDO tranfer finished but number of collected bytes "  1144         m_VelCalcTime.SetNow();
  1161                         if( (iStatus & 0x0000000E) == 2)
  1162                                 std::cout << 
"- drive error under voltage" << std::endl;
  1164                         if( (iStatus & 0x0000000E) == 4)
  1165                                 std::cout << 
"- drive error over voltage" << std::endl;
  1167                         if( (iStatus & 0x0000000E) == 10)
  1168                                 std::cout << 
"- drive error short circuit" << std::endl;
  1170                         if( (iStatus & 0x0000000E) == 12)
  1171                                 std::cout << 
"- drive error overheating" << std::endl;
  1258                 std::cout << 
"- feedback loss" << std::endl;
  1263                 std::cout << 
"- peak current excced" << std::endl;
  1268                 std::cout << 
"- speed track error" << std::endl;
  1273                 std::cout << 
"- position track error" << std::endl;
  1278                 std::cout << 
"- speed limit exceeded" << std::endl;
  1283                 std::cout << 
"- motor stuck" << std::endl;
  1297                 std::cout << 
"Torque command too high: " << fMotCurr << 
" Nm. Torque has been limitited." << std::endl;
  1302                 std::cout << 
"Torque command too high: " << fMotCurr << 
" Nm. Torque has been limitited." << std::endl;
  1312         msg.
set(0,0,0,0,0,0,0,0);
  1323                         << 
" is too large: " << dt << 
" s" << std::endl;
  1325         m_SendTime.SetNow();
  1357                         if(iParam < 1) iParam = 1;
  1366                                 if( (iParam != 1) && (iParam != 2) && (iParam != 10) && (iParam != 16) ) {
  1368                                         std::cout << 
"Changed the Readout object to #1 as your selected object hasn't been recorded!" << std::endl;
  1375                                 std::cout << 
"Previous transmission not finished or colected data hasn't been proceeded yet" << std::endl;
 
bool isInitialized(bool initNow)
void requestMotorTorque()
std::vector< unsigned char > data
void receivedSDOTransferAbort(unsigned int iErrorCode)
bool evalStatusRegister(int iStatus)
void evalSDO(CanMsg &CMsg, int *pIndex, int *pSubindex)
void getMotorTorque(double *dTorqueNm)
bool m_bLimitSwitchEnabled
double estimVel(double dPos)
int processData(segData &SDOData)
bool isBitSet(int iVal, int iNrBit)
double getTimeToLastMsg()
void evalMotorFailure(int iFailure)
int getEncIncrPerRevMot()
int setRecorder(int iFlag, int iParam=0, std::string sParam="/home/MyLog_")
bool disableBrake(bool bDisabled)
void sendSDODownload(int iObjIndex, int iObjSub, int iData)
int VelGearRadSToVelMotIncrPeriod(double dVelGearRadS)
Conversions of gear velocity in rad/s to encoder increments per measurment period. 
void setGearVelRadS(double dVelEncRadS)
void setCanOpenParam(int iTxPDO1, int iTxPDO2, int iRxPDO2, int iTxSDO, int iRxSDO)
unsigned int numTotalBytes
void getGearPosVelRadS(double *pdAngleGearRad, double *pdVelGearRadS)
void finishedSDOSegmentedTransfer()
double m_dAngleGearRadMem
void setGearPosVelRadS(double dPosRad, double dVelRadS)
void getGearDeltaPosVelRadS(double *pdDeltaAngleGearRad, double *pdVelGearRadS)
void IntprtSetFloat(int iDataLen, char cCmdChar1, char cCmdChar2, int iIndex, float fData)
ParamCanOpenType m_ParamCanOpen
bool getStatusLimitSwitch()
int receivedSDODataSegment(CanMsg &msg)
void sendSDOUploadSegmentConfirmation(bool toggleBit)
int configureElmoRecorder(int iRecordingGap, int driveID, int startImmediately=1)
int readoutRecorderTryStatus(int iStatusReg, segData &SDOData)
void IntprtSetInt(int iDataLen, char cCmdChar1, char cCmdChar2, int iIndex, int iData)
int setLogFilename(std::string sLogFileprefix)
double PosMotIncrToPosGearRad(int iPosIncr)
Conversions of encoder increments to gear position in radians. 
int receivedSDOSegmentedInitiation(CanMsg &msg)
virtual bool receiveMsg(CanMsg *pCMsg)=0
virtual bool receiveMsgRetry(CanMsg *pCMsg, int iNrOfRetry)=0
void sendSDOUpload(int iObjIndex, int iObjSub)
void set(BYTE Data0=0, BYTE Data1=0, BYTE Data2=0, BYTE Data3=0, BYTE Data4=0, BYTE Data5=0, BYTE Data6=0, BYTE Data7=0)
void sendSDOAbort(int iObjIndex, int iObjSubIndex, unsigned int iErrorCode)
void getData(double *pdPosGearRad, double *pdVelGearRadS, int *piTorqueCtrl, int *piStatusCtrl)
int getSDODataInt32(CanMsg &CMsg)
void getGearPosRad(double *pdPosGearRad)
TimeStamp m_FailureStartTime
void PosVelRadToIncr(double dPosRad, double dVelRadS, int *piPosIncr, int *piVelIncrPeriod)
bool setTypeMotion(int iType)
int readoutRecorderTry(int iObjSubIndex)
bool startWatchdog(bool bStarted)
double m_dVelGearMeasRadS
virtual bool transmitMsg(CanMsg CMsg, bool bBlocking=true)=0
void setMotorTorque(double dTorqueNm)