Fixed SDO upload segment response for 10 bytes mailbox length (thanks to Joerg
authorFlorian Pose <fp@igh-essen.com>
Fri, 21 Aug 2009 09:45:53 +0200
changeset 1533 bd150d066ea2
parent 1528 dbc617badc33
child 1534 4844a8433915
Fixed SDO upload segment response for 10 bytes mailbox length (thanks to Joerg
Mohre).
NEWS
master/fsm_coe.c
--- a/NEWS	Thu Aug 13 15:18:53 2009 +0200
+++ b/NEWS	Fri Aug 21 09:45:53 2009 +0200
@@ -45,6 +45,8 @@
   methods to let an application transfer SDOs before activating the master
   (thanks to Stefan Weiser).
 * Fixed SDO upload segment response (thanks to Christoph Peter).
+* Fixed SDO upload segment response for 10 bytes mailbox length (thanks to
+  Joerg Mohre).
 * SDO entry access rights are shown in 'ethercat sdos'.
 * Added 64-bit data access macros to application header.
 * Added debug level for all masters as a module parameter. Thanks to Erwin
--- a/master/fsm_coe.c	Thu Aug 13 15:18:53 2009 +0200
+++ b/master/fsm_coe.c	Fri Aug 21 09:45:53 2009 +0200
@@ -1821,7 +1821,6 @@
     uint8_t *data, mbox_prot;
     size_t rec_size, data_size;
     ec_sdo_request_t *request = fsm->request;
-    uint32_t seg_size;
     unsigned int last_segment;
 
     if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
@@ -1899,14 +1898,11 @@
         return;
     }
 
-    last_segment = EC_READ_U8(data + 2) & 0x01;
-    seg_size = (EC_READ_U8(data + 2) & 0xE) >> 1;
-    if (rec_size > 10) {
-        data_size = rec_size - 3; /* Header of segment upload is smaller than
-                                     normal upload */
-    } else { // == 10
-        /* seg_size contains the number of trailing bytes to ignore. */
-        data_size = rec_size - seg_size;
+    data_size = rec_size - 3; /* Header of segment upload is smaller than
+                                 normal upload */
+    if (rec_size == 10) {
+        uint8_t seg_size = (EC_READ_U8(data + 2) & 0xE) >> 1;
+        data_size -= seg_size;
     }
 
     if (request->data_size + data_size > fsm->complete_size) {
@@ -1920,6 +1916,7 @@
     memcpy(request->data + request->data_size, data + 3, data_size);
     request->data_size += data_size;
 
+    last_segment = EC_READ_U8(data + 2) & 0x01;
     if (!last_segment) {
         fsm->toggle = !fsm->toggle;
         ec_fsm_coe_up_prepare_segment_request(fsm);