CoE state machines raising error, if the slave does not support CoE.
authorFlorian Pose <fp@igh-essen.com>
Fri, 22 Feb 2008 18:25:44 +0000
changeset 825 3771f5a0ed90
parent 824 e2501463f7d1
child 826 70aeae0de217
CoE state machines raising error, if the slave does not support CoE.
master/fsm_coe.c
master/fsm_coe.h
--- a/master/fsm_coe.c	Fri Feb 22 18:22:05 2008 +0000
+++ b/master/fsm_coe.c	Fri Feb 22 18:25:44 2008 +0000
@@ -249,6 +249,12 @@
     ec_slave_t *slave = fsm->slave;
     uint8_t *data;
 
+    if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) {
+        EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
+        fsm->state = ec_fsm_coe_error;
+        return;
+    }
+
     if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8))) {
         fsm->state = ec_fsm_coe_error;
         return;
@@ -955,6 +961,12 @@
         EC_DBG("Downloading Sdo 0x%04X:%i to slave %i.\n",
                sdodata->index, sdodata->subindex, slave->ring_position);
 
+    if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) {
+        EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
+        fsm->state = ec_fsm_coe_error;
+        return;
+    }
+
     if (slave->sii_rx_mailbox_size < 6 + 10 + sdodata->size) {
         EC_ERR("Sdo fragmenting not supported yet!\n");
         fsm->state = ec_fsm_coe_error;
@@ -1170,6 +1182,12 @@
         EC_DBG("Uploading Sdo 0x%04X:%i from slave %i.\n",
                entry->sdo->index, entry->subindex, slave->ring_position);
 
+    if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) {
+        EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
+        fsm->state = ec_fsm_coe_error;
+        return;
+    }
+
     if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10))) {
         fsm->state = ec_fsm_coe_error;
         return;
--- a/master/fsm_coe.h	Fri Feb 22 18:22:05 2008 +0000
+++ b/master/fsm_coe.h	Fri Feb 22 18:25:44 2008 +0000
@@ -51,12 +51,9 @@
 
 typedef struct ec_fsm_coe ec_fsm_coe_t; /**< \see ec_fsm_coe */
 
-/**
-   Finite state machine of an EtherCAT master.
-*/
-
-struct ec_fsm_coe
-{
+/** Finite state machines for the CANopen-over-EtherCAT protocol.
+ */
+struct ec_fsm_coe {
     ec_slave_t *slave; /**< slave the FSM runs on */
     ec_datagram_t *datagram; /**< datagram used in the state machine */
     unsigned int retries; /**< retries upon datagram timeout */