Check for data sizes when reading Pdo assignment/mapping from CoE.
authorFlorian Pose <fp@igh-essen.com>
Thu, 19 Jun 2008 08:06:49 +0000
changeset 1036 dc2008bc8113
parent 1035 7fafc1a7451e
child 1037 59f191c9185b
Check for data sizes when reading Pdo assignment/mapping from CoE.
TODO
master/fsm_coe_map.c
--- a/TODO	Thu Jun 19 07:54:45 2008 +0000
+++ b/TODO	Thu Jun 19 08:06:49 2008 +0000
@@ -14,9 +14,10 @@
 * Adapt remaining examples.
 * READMEs for examples.
 * Update documentation.
-* Check for sizes of uploaded Sdos when reading mapping from CoE.
 * Attach Pdo names from SII or Coe dictioary to Pdos read via CoE.
 * Add a -n (numeric) switch to ethercat command.
+* Remove Eoe cylces and Idle cycles.
+* Store Sdo abort code in sdo_request_t and output it in user space.
 
 Future issues:
 
--- a/master/fsm_coe_map.c	Thu Jun 19 07:54:45 2008 +0000
+++ b/master/fsm_coe_map.c	Thu Jun 19 08:06:49 2008 +0000
@@ -216,6 +216,14 @@
         return;
     }
 
+    if (fsm->request.data_size != sizeof(uint8_t)) {
+        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
+                "from slave %u.\n", fsm->request.data_size,
+                fsm->request.index, fsm->request.subindex,
+                fsm->slave->ring_position);
+        fsm->state = ec_fsm_coe_map_state_error;
+        return;
+    }
     fsm->sync_subindices = EC_READ_U8(fsm->request.data);
 
     if (fsm->slave->master->debug_level)
@@ -280,6 +288,15 @@
         return;
     }
 
+    if (fsm->request.data_size != sizeof(uint16_t)) {
+        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
+                "from slave %u.\n", fsm->request.data_size,
+                fsm->request.index, fsm->request.subindex,
+                fsm->slave->ring_position);
+        fsm->state = ec_fsm_coe_map_state_error;
+        return;
+    }
+
     if (!(fsm->pdo = (ec_pdo_t *)
                 kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
         EC_ERR("Failed to allocate Pdo.\n");
@@ -323,6 +340,14 @@
         return;
     }
 
+    if (fsm->request.data_size != sizeof(uint8_t)) {
+        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
+                "from slave %u.\n", fsm->request.data_size,
+                fsm->request.index, fsm->request.subindex,
+                fsm->slave->ring_position);
+        fsm->state = ec_fsm_coe_map_state_error;
+        return;
+    }
     fsm->pdo_subindices = EC_READ_U8(fsm->request.data);
 
     if (fsm->slave->master->debug_level)
@@ -377,7 +402,13 @@
         return;
     }
 
-    {
+    if (fsm->request.data_size != sizeof(uint32_t)) {
+        EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X "
+                "from slave %u.\n", fsm->request.data_size,
+                fsm->request.index, fsm->request.subindex,
+                fsm->slave->ring_position);
+        fsm->state = ec_fsm_coe_map_state_error;
+    } else {
         uint32_t pdo_entry_info;
         ec_pdo_entry_t *pdo_entry;