# HG changeset patch # User Christian Taedcke # Date 1296146748 -3600 # Node ID f923456f01e59b37d8a4ce81aaae46245ce529f7 # Parent ea1ddcc77acf51ef5b880d6ea6a9b0944d569d20 FIXED: - Sdo lines with the internal state SDO_ABORTED_ITERNAL are now closed. diff -r ea1ddcc77acf -r f923456f01e5 include/sdo.h --- a/include/sdo.h Wed Nov 10 13:08:26 2010 +0100 +++ b/include/sdo.h Thu Jan 27 17:45:48 2011 +0100 @@ -211,6 +211,21 @@ UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line); /** + * @brief Search for the line, in the transfers array, which contains the + * beginning of the reception of a fragmented SDO + * + * Because getSDOlineOnUse() does not return any line in state \c SDO_ABORTED_INTERNAL, + * this funtion is used to return them, too. + * + * @param *d Pointer on a CAN object data structure + * @param nodeId correspond to the message node-id + * @param whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER + * @param *line Pointer on a SDO line + * @return 0xFF if error. Else, return 0 + */ +UNS8 getSDOlineToClose (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line); + +/** * @brief Close a transmission. * @param *d Pointer on a CAN object data structure * @param nodeId Node id of the server if both server or client diff -r ea1ddcc77acf -r f923456f01e5 src/sdo.c --- a/src/sdo.c Wed Nov 10 13:08:26 2010 +0100 +++ b/src/sdo.c Thu Jan 27 17:45:48 2011 +0100 @@ -145,6 +145,9 @@ (*d->transfers[id].Callback)(d,d->transfers[id].nodeId); else if(d->transfers[id].whoami == SDO_SERVER) /*Else, if server, reset the line*/ + + /*Reset the line if (whoami == SDO_SERVER) or the callback did not close the line. + Otherwise this sdo transfer would never be closed. */ resetSDOline(d, (UNS8)id); } @@ -520,6 +523,33 @@ ** @param d ** @param nodeId ** @param whoami +** @param line +** +** @return +**/ +UNS8 getSDOlineToClose (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line) +{ + + UNS8 i; + + for (i = 0 ; i < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; i++){ + if ( (d->transfers[i].state != SDO_RESET) && + (d->transfers[i].nodeId == nodeId) && + (d->transfers[i].whoami == whoami) ) { + if (line) *line = i; + return 0; + } + } + return 0xFF; +} + + +/*! +** +** +** @param d +** @param nodeId +** @param whoami ** ** @return **/ @@ -527,7 +557,7 @@ { UNS8 err; UNS8 line; - err = getSDOlineOnUse(d, nodeId, whoami, &line); + err = getSDOlineToClose(d, nodeId, whoami, &line); if (err) { MSG_WAR(0x2A30, "No SDO communication to close for node : ", nodeId); return 0xFF;