从站:SSC 5.12
主站:SOEM 1.4
这是SOEM和SSC 5.12的老问题。是大小端转换问题。
解决方法:修改SOEM的代码:
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, int *Osize, int *Isize) { int wkc, rdl; int retVal = 0; uint8 nSM, iSM, tSM; int Tsize; uint8 SMt_bug_add; *Isize = 0; *Osize = 0; SMt_bug_add = 0; rdl = sizeof(ec_SMcommtypet); context->SMcommtype[Thread_n].n = 0; /* read SyncManager Communication Type object count Complete Access*/ wkc = ecx_SDOread(context, Slave, ECT_SDO_SMCOMMTYPE, 0x00, TRUE, &rdl, &(context->SMcommtype[Thread_n]), EC_TIMEOUTRXM); /* positive result from slave ? */ if ((wkc > 0) && (context->SMcommtype[Thread_n].n > 2)) { nSM = context->SMcommtype[Thread_n].n; /* limit to maximum number of SM defined, if true the slave can't be configured */ if (nSM > EC_MAXSM) { nSM = EC_MAXSM; ecx_packeterror(context, Slave, 0, 0, 10); /* #SM larger than EC_MAXSM */ } /* iterate for every SM type defined */ for (iSM = 2 ; iSM < nSM ; iSM++) { tSM = context->SMcommtype[Thread_n].SMtype[iSM]; // start slave bug prevention code, remove if possible if((iSM == 2) && (tSM == 2)) // SM2 has type 2 == mailbox out, this is a bug in the slave! { SMt_bug_add = 1; // try to correct, this works if the types are 0 1 2 3 and should be 1 2 3 4 } else if((iSM == 2) && (tSM == 4)) { tSM = 3; } else if((iSM == 3) && (tSM == 3)) { tSM = 4; } if(tSM) { tSM += SMt_bug_add; // only add if SMt > 0 }