--- a/src/pdo.c Wed Apr 23 14:12:08 2008 +0200
+++ b/src/pdo.c Thu Apr 24 14:08:34 2008 +0200
@@ -122,7 +122,7 @@
UNS8
sendPDOrequest (CO_Data * d, UNS16 RPDOIndex)
{
- UNS16 *pwCobId;
+ UNS32 *pwCobId;
UNS16 offset = d->firstIndex->PDO_RCV;
UNS16 lastIndex = d->lastIndex->PDO_RCV;
@@ -138,12 +138,12 @@
if (offset <= lastIndex)
{
/* get the CobId */
- pwCobId = (UNS16 *) d->objdict[offset].pSubindex[1].pObject;
+ pwCobId = d->objdict[offset].pSubindex[1].pObject;
MSG_WAR (0x3930, "sendPDOrequest cobId is : ", *pwCobId);
{
Message pdo;
- pdo.cob_id = *pwCobId;
+ pdo.cob_id = UNS16_LE(*pwCobId);
pdo.rtr = REQUEST;
pdo.len = 0;
return canSend (d->canHandle, &pdo);
@@ -176,7 +176,7 @@
UNS32 *pMappingParameter = NULL;
UNS8 *pTransmissionType = NULL; /* pointer to the transmission
type */
- UNS16 *pwCobId = NULL;
+ UNS32 *pwCobId = NULL;
UNS8 Size;
UNS8 offset;
UNS8 status;
@@ -186,7 +186,7 @@
status = state2;
- MSG_WAR (0x3935, "proceedPDO, cobID : ", ((*m).cob_id & UNS16_LE (0x7ff)));
+ MSG_WAR (0x3935, "proceedPDO, cobID : ", (UNS16_LE(m->cob_id) & 0x7ff));
offset = 0x00;
numPdo = 0;
numMap = 0;
@@ -209,11 +209,11 @@
/* get CobId of the dictionary correspondant to the received
PDO */
pwCobId =
- (UNS16 *) d->objdict[offsetObjdict].pSubindex[1].pObject;
+ d->objdict[offsetObjdict].pSubindex[1].pObject;
/* check the CobId coherance */
/*pwCobId is the cobId read in the dictionary at the state 3
*/
- if (*pwCobId == (*m).cob_id)
+ if (*pwCobId == UNS16_LE(m->cob_id))
{
/* The cobId is recognized */
status = state4;
@@ -291,7 +291,7 @@
MSG_WAR (0x3942,
"Variable updated with value received by PDO cobid : ",
- m->cob_id);
+ UNS16_LE(m->cob_id));
MSG_WAR (0x3943, " Mapped at index : ",
(*pMappingParameter) >> 16);
MSG_WAR (0x3944, " subindex : ",
@@ -302,8 +302,6 @@
numMap++;
} /* end loop while on mapped variables */
- offset = 0x00;
- numMap = 0;
return 0;
} /* end switch status */
@@ -311,7 +309,7 @@
} /* end if Donnees */
else if ((*m).rtr == REQUEST)
{
- MSG_WAR (0x3946, "Receive a PDO request cobId : ", m->cob_id);
+ MSG_WAR (0x3946, "Receive a PDO request cobId : ", UNS16_LE(m->cob_id));
status = state1;
offsetObjdict = d->firstIndex->PDO_TRS;
lastIndex = d->lastIndex->PDO_TRS;
@@ -327,9 +325,9 @@
/* get CobId of the dictionary which match to the received PDO
*/
pwCobId =
- (UNS16 *) (d->objdict +
+ (d->objdict +
offsetObjdict)->pSubindex[1].pObject;
- if (*pwCobId == (*m).cob_id)
+ if (*pwCobId == UNS16_LE(m->cob_id))
{
status = state4;
break;
@@ -369,7 +367,7 @@
/* DS301 do not tell what to do in such a case... */
MSG_ERR (0x1947,
"Not ready RTR_SYNC TPDO send current data : ",
- m->cob_id);
+ UNS16_LE(m->cob_id));
status = state5;
}
break;
@@ -393,7 +391,7 @@
/* The requested PDO is not to send on request. So, does
nothing. */
MSG_WAR (0x2947, "PDO is not to send on request : ",
- m->cob_id);
+ UNS16_LE(m->cob_id));
return 0xFF;
}
@@ -402,7 +400,7 @@
Message pdo;
if (buildPDO (d, numPdo, &pdo))
{
- MSG_ERR (0x1948, " Couldn't build TPDO n°", numPdo);
+ MSG_ERR (0x1948, " Couldn't build TPDO n�", numPdo);
return 0xFF;
}
canSend (d->canHandle, &pdo);
@@ -697,7 +695,7 @@
case state5: /*Send the pdo */
/*store_as_last_message */
d->PDO_status[pdoNum].last_message = pdo;
- MSG_WAR (0x396D, "sendPDO cobId :", pdo.cob_id);
+ MSG_WAR (0x396D, "sendPDO cobId :", UNS16_LE(pdo.cob_id));
MSG_WAR (0x396E, " Nb octets : ", pdo.len);
canSend (d->canHandle, &pdo);
--- a/src/sdo.c Wed Apr 23 14:12:08 2008 +0200
+++ b/src/sdo.c Thu Apr 24 14:08:34 2008 +0200
@@ -493,7 +493,7 @@
UNS8 found = 0;
Message m;
UNS8 i;
- UNS16 * pwCobId = NULL;
+ UNS32 * pwCobId = NULL;
UNS8 * pwNodeId = NULL;
MSG_WAR(0x3A38, "sendSDO",0);
@@ -509,7 +509,7 @@
MSG_ERR(0x1A42, "SendSDO : No SDO server found", 0);
return 0xFF;
}
- pwCobId = (UNS16*) d->objdict[offset].pSubindex[2].pObject;
+ pwCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
MSG_WAR(0x3A41, "I am server. cobId : ", *pwCobId);
}
else { /*case client*/
@@ -542,10 +542,10 @@
return 0xFF;
}
/* Second, read the cobid client->server */
- pwCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
+ pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
}
/* message copy for sending */
- m.cob_id = *pwCobId;
+ m.cob_id = UNS16_LE(*pwCobId);
m.rtr = NOT_A_REQUEST;
/* the length of SDO must be 8 */
m.len = 8;
@@ -610,7 +610,7 @@
UNS8 subIndex;
UNS32 abortCode;
UNS8 i,j;
- UNS16 *pCobId = NULL;
+ UNS32 *pCobId = NULL;
UNS16 offset;
UNS16 lastIndex;
@@ -626,8 +626,8 @@
MSG_ERR(0x1A61, "Subindex 1 not found at index ", 0x1200 + j);
return 0xFF;
}
- pCobId = (UNS16*) d->objdict[offset].pSubindex[1].pObject;
- if ( *pCobId == (*m).cob_id ) {
+ pCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject;
+ if ( *pCobId == UNS16_LE(m->cob_id) ) {
whoami = SDO_SERVER;
MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j);
/* In case of server, the node id of the client may be unknown. So we put the index minus offset */
@@ -649,8 +649,8 @@
return 0xFF;
}
/* a) Looking for the cobid received. */
- pCobId = (UNS16*) d->objdict[offset].pSubindex[2].pObject;
- if (*pCobId == (*m).cob_id ) {
+ pCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject;
+ if (*pCobId == UNS16_LE(m->cob_id) ) {
/* b) cobid found, so reading the node id of the server. */
pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject;
whoami = SDO_CLIENT;
@@ -669,7 +669,7 @@
/* Test if the size of the SDO is ok */
if ( (*m).len != 8) {
- MSG_ERR(0x1A67, "Error size SDO. CobId : ", (*m).cob_id);
+ MSG_ERR(0x1A67, "Error size SDO. CobId : ", UNS16_LE(m->cob_id));
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_GENERAL_ERROR);
return 0xFF;
}
@@ -678,7 +678,7 @@
MSG_WAR(0x3A68, "I am CLIENT. Received SDO from nodeId : ", nodeId);
}
else {
- MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", (*m).cob_id);
+ MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", UNS16_LE(m->cob_id));
}
/* Testing the command specifier */
--- a/src/states.c Wed Apr 23 14:12:08 2008 +0200
+++ b/src/states.c Thu Apr 24 14:08:34 2008 +0200
@@ -255,14 +255,12 @@
/* Adjust COB-ID Client->Server (rx) only id already set to default value or id not valid (id==0xFF)*/
if((*(UNS32*)d->objdict[offset].pSubindex[1].pObject == 0x600 + *d->bDeviceNodeId)||(*d->bDeviceNodeId==0xFF)){
/* cob_id_client = 0x600 + nodeId; */
- UNS32 tmp = 0x600 + nodeId;
- *(UNS32*)d->objdict[offset].pSubindex[1].pObject = tmp;
+ *(UNS32*)d->objdict[offset].pSubindex[1].pObject = 0x600 + nodeId;
}
/* Adjust COB-ID Server -> Client (tx) only id already set to default value or id not valid (id==0xFF)*/
if((*(UNS32*)d->objdict[offset].pSubindex[2].pObject == 0x580 + *d->bDeviceNodeId)||(*d->bDeviceNodeId==0xFF)){
/* cob_id_server = 0x580 + nodeId; */
- UNS32 tmp = 0x580 + nodeId;
- *(UNS32*)d->objdict[offset].pSubindex[2].pObject = tmp;
+ *(UNS32*)d->objdict[offset].pSubindex[2].pObject = 0x580 + nodeId;
}
}
--- a/src/sync.c Wed Apr 23 14:12:08 2008 +0200
+++ b/src/sync.c Thu Apr 24 14:08:34 2008 +0200
@@ -131,7 +131,7 @@
MSG_WAR(0x3001, "sendSYNC ", 0);
- m.cob_id = m.cob_id = UNS16_LE(*d->COB_ID_Sync);
+ m.cob_id = UNS16_LE(*d->COB_ID_Sync);
m.rtr = NOT_A_REQUEST;
m.len = 0;