src/sdo.c
changeset 1 b3dc740b4b04
parent 0 4472ee7c6c3e
child 6 8038ced64796
equal deleted inserted replaced
0:4472ee7c6c3e 1:b3dc740b4b04
    18 You should have received a copy of the GNU Lesser General Public
    18 You should have received a copy of the GNU Lesser General Public
    19 License along with this library; if not, write to the Free Software
    19 License along with this library; if not, write to the Free Software
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    21 */
    21 */
    22 
    22 
    23 //#define DEBUG_WAR_CONSOLE_ON
    23 #define DEBUG_WAR_CONSOLE_ON
    24 //#define DEBUG_ERR_CONSOLE_ON
    24 #define DEBUG_ERR_CONSOLE_ON
    25 
    25 
    26 #include "objacces.h"
    26 #include "objacces.h"
    27 #include "sdo.h"
    27 #include "sdo.h"
    28 
    28 
    29 /***************************************************************************/
    29 /***************************************************************************/
   114 {
   114 {
   115   const indextable *ptrTable;
   115   const indextable *ptrTable;
   116   UNS8 i;
   116   UNS8 i;
   117   UNS8      size;
   117   UNS8      size;
   118   UNS32 errorCode;
   118   UNS32 errorCode;
       
   119   MSG_WAR(0x3A08, "Enter in SDOlineToObjdict ", line);
   119   size = d->transfers[line].count;
   120   size = d->transfers[line].count;
   120   errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, 
   121   errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, 
   121 			 (void *) d->transfers[line].data, &size, 1);
   122 			 (void *) d->transfers[line].data, &size, 1);
   122   if (errorCode != OD_SUCCESSFUL)
   123   if (errorCode != OD_SUCCESSFUL)
   123     return errorCode;
   124     return errorCode;
   124 
   125   MSG_WAR(0x3A08, "exit of SDOlineToObjdict ", line);
   125   return 0;
   126   return 0;
   126 
   127 
   127 }
   128 }
   128 
   129 
   129 /***************************************************************************/
   130 /***************************************************************************/
   194 		UNS8 subIndex, UNS32 abortCode)
   195 		UNS8 subIndex, UNS32 abortCode)
   195 {
   196 {
   196   UNS8 err;
   197   UNS8 err;
   197   UNS8 line;
   198   UNS8 line;
   198   err = getSDOlineOnUse( d, nodeId, whoami, &line );
   199   err = getSDOlineOnUse( d, nodeId, whoami, &line );
   199   if (!err)
   200   if (!err) // If a line on use have been found.
   200     MSG_WAR(0x3A20, "FailedSDO : line found : ", line);
   201     MSG_WAR(0x3A20, "FailedSDO : line found : ", line);
   201   if ((! err) && (whoami == SDO_SERVER)) {
   202   if ((! err) && (whoami == SDO_SERVER)) {
   202     resetSDOline( d, line );
   203     resetSDOline( d, line );
   203     MSG_WAR(0x3A21, "FailedSDO : line released : ", line);
   204     MSG_WAR(0x3A21, "FailedSDO : line released : ", line);
   204   }
   205   }
   205   if ((! err) && (whoami == SDO_CLIENT))
   206   if ((! err) && (whoami == SDO_CLIENT)) {
   206     StopSDO_TIMER(line)
   207     StopSDO_TIMER(line);
   207     d->transfers[line].state = SDO_ABORTED_INTERNAL;
   208     d->transfers[line].state = SDO_ABORTED_INTERNAL;
       
   209   }
   208   MSG_WAR(0x3A22, "Sending SDO abort ", 0);
   210   MSG_WAR(0x3A22, "Sending SDO abort ", 0);
   209   err = sendSDOabort(d, whoami, index, subIndex, abortCode);
   211   err = sendSDOabort(d, whoami, index, subIndex, abortCode);
   210   if (err) {
   212   if (err) {
   211     MSG_WAR(0x3A23, "Unable to send the SDO abort", 0);
   213     MSG_WAR(0x3A23, "Unable to send the SDO abort", 0);
   212     return 0xFF;
   214     return 0xFF;
   216 
   218 
   217 /***************************************************************************/
   219 /***************************************************************************/
   218 void resetSDOline ( CO_Data* d, UNS8 line )
   220 void resetSDOline ( CO_Data* d, UNS8 line )
   219 {
   221 {
   220   UNS8 i; 
   222   UNS8 i; 
   221 
   223   MSG_WAR(0x3A25, "reset SDO line nb : ", line); 
   222   initSDOline(d, line, 0, 0, 0, SDO_RESET);
   224   initSDOline(d, line, 0, 0, 0, SDO_RESET);
   223   for (i = 0 ; i < SDO_MAX_LENGTH_TRANSFERT ; i++)
   225   for (i = 0 ; i < SDO_MAX_LENGTH_TRANSFERT ; i++)
   224     d->transfers[line].data[i] = 0;
   226     d->transfers[line].data[i] = 0;
   225 }
   227 }
   226 
   228 
   227 /***************************************************************************/
   229 /***************************************************************************/
   228 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state)
   230 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state)
   229 {
   231 {
       
   232   MSG_WAR(0x3A25, "init SDO line nb : ", line); 
   230   if (state == SDO_DOWNLOAD_IN_PROGRESS || state == SDO_UPLOAD_IN_PROGRESS){
   233   if (state == SDO_DOWNLOAD_IN_PROGRESS || state == SDO_UPLOAD_IN_PROGRESS){
   231   	StartSDO_TIMER(line)
   234   	StartSDO_TIMER(line)
   232   }else{
   235   }else{
   233   	StopSDO_TIMER(line)
   236   	StopSDO_TIMER(line)
   234   }
   237   }
   389 /***************************************************************************/
   392 /***************************************************************************/
   390 UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode)
   393 UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode)
   391 {
   394 {
   392   s_SDO sdo;
   395   s_SDO sdo;
   393   UNS8 ret;
   396   UNS8 ret;
   394   MSG_WAR(0x2A50,"Sending SDO abort", abortCode);
   397   MSG_WAR(0x2A50,"Sending SDO abort ", abortCode);
   395   sdo.nodeId = *d->bDeviceNodeId;
   398   sdo.nodeId = *d->bDeviceNodeId;
   396   sdo.body.data[0] = 0x80;
   399   sdo.body.data[0] = 0x80;
   397   // Index
   400   // Index
   398   sdo.body.data[1] = index & 0xFF; // LSB
   401   sdo.body.data[1] = index & 0xFF; // LSB
   399   sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
   402   sdo.body.data[2] = (index >> 8) & 0xFF; // MSB
  1273     return SDO_ABORTED_INTERNAL;
  1276     return SDO_ABORTED_INTERNAL;
  1274   }
  1277   }
  1275   * abortCode = d->transfers[line].abortCode;
  1278   * abortCode = d->transfers[line].abortCode;
  1276   return d->transfers[line].state;
  1279   return d->transfers[line].state;
  1277 }
  1280 }
       
  1281