merge -c1617 branches/stable-1.4 1.4-foe
authorFlorian Pose <fp@igh-essen.com>
Tue, 20 Jan 2009 08:04:50 +0000
branch1.4-foe
changeset 1710 4522459bb5a4
parent 1709 63e4bc918640
child 1711 2b017fcc1c6d
merge -c1617 branches/stable-1.4
master/fsm_slave_config.c
master/master.c
tool/CommandDownload.cpp
tool/CommandUpload.cpp
tool/SdoCommand.cpp
--- a/master/fsm_slave_config.c	Mon Jan 19 14:46:55 2009 +0000
+++ b/master/fsm_slave_config.c	Tue Jan 20 08:04:50 2009 +0000
@@ -42,6 +42,7 @@
 void ec_fsm_slave_config_state_start(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_state_init(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_state_clear_fmmus(ec_fsm_slave_config_t *);
+void ec_fsm_slave_config_state_clear_sync(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_state_mbox_sync(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_state_boot_preop(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_state_sdo_conf(ec_fsm_slave_config_t *);
@@ -52,6 +53,7 @@
 void ec_fsm_slave_config_state_op(ec_fsm_slave_config_t *);
 
 void ec_fsm_slave_config_enter_init(ec_fsm_slave_config_t *);
+void ec_fsm_slave_config_enter_clear_sync(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_enter_mbox_sync(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_enter_boot_preop(ec_fsm_slave_config_t *);
 void ec_fsm_slave_config_enter_sdo_conf(ec_fsm_slave_config_t *);
@@ -213,7 +215,7 @@
     }
 
     if (!slave->base_fmmu_count) { // skip FMMU configuration
-        ec_fsm_slave_config_enter_mbox_sync(fsm);
+        ec_fsm_slave_config_enter_clear_sync(fsm);
         return;
     }
 
@@ -258,6 +260,65 @@
         return;
     }
 
+    ec_fsm_slave_config_enter_clear_sync(fsm);
+}
+
+/*****************************************************************************/
+
+/** Clear the sync manager configurations.
+ */
+void ec_fsm_slave_config_enter_clear_sync(
+        ec_fsm_slave_config_t *fsm /**< slave state machine */
+        )
+{
+    ec_slave_t *slave = fsm->slave;
+    ec_datagram_t *datagram = fsm->datagram;
+    size_t sync_size;
+
+    if (!slave->sii.sync_count) {
+        // no mailbox protocols supported
+        ec_fsm_slave_config_enter_mbox_sync(fsm);
+        return;
+    }
+
+    sync_size = EC_SYNC_PAGE_SIZE * slave->sii.sync_count;
+
+    // clear sync manager configurations
+    ec_datagram_fpwr(datagram, slave->station_address, 0x0800, sync_size);
+    memset(datagram->data, 0x00, sync_size);
+    fsm->retries = EC_FSM_RETRIES;
+    fsm->state = ec_fsm_slave_config_state_clear_sync;
+}
+
+/*****************************************************************************/
+
+/** Slave configuration state: CLEAR SYNC.
+ */
+void ec_fsm_slave_config_state_clear_sync(
+        ec_fsm_slave_config_t *fsm /**< slave state machine */
+        )
+{
+    ec_datagram_t *datagram = fsm->datagram;
+
+    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
+        return;
+
+    if (datagram->state != EC_DATAGRAM_RECEIVED) {
+        fsm->state = ec_fsm_slave_config_state_error;
+        EC_ERR("Failed receive sync manager clearing datagram"
+                " for slave %u.\n", fsm->slave->ring_position);
+        return;
+    }
+
+    if (datagram->working_counter != 1) {
+        fsm->slave->error_flag = 1;
+        fsm->state = ec_fsm_slave_config_state_error;
+        EC_ERR("Failed to clear sync manager configurations of slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_wc_error(datagram);
+        return;
+    }
+
     ec_fsm_slave_config_enter_mbox_sync(fsm);
 }
 
--- a/master/master.c	Mon Jan 19 14:46:55 2009 +0000
+++ b/master/master.c	Tue Jan 20 08:04:50 2009 +0000
@@ -888,7 +888,9 @@
             schedule_timeout(1);
         }
         else {
-            schedule();
+            //schedule();
+            set_current_state(TASK_INTERRUPTIBLE);
+            schedule_timeout(1);
         }
     }
     
@@ -933,7 +935,8 @@
             schedule_timeout(1);
         }
         else {
-            schedule();
+            set_current_state(TASK_INTERRUPTIBLE);
+            schedule_timeout(1);
         }
     }
     
--- a/tool/CommandDownload.cpp	Mon Jan 19 14:46:55 2009 +0000
+++ b/tool/CommandDownload.cpp	Tue Jan 20 08:04:50 2009 +0000
@@ -37,7 +37,8 @@
 		<< "the --type option is mandatory." << endl
     	<< endl
     	<< "These are the valid SDO entry data types:" << endl
-    	<< "  int8, int16, int32, uint8, uint16, uint32, string." << endl
+    	<< "  int8, int16, int32, uint8, uint16, uint32, string," << endl
+        << "  octet_string." << endl
     	<< endl
     	<< "Arguments:" << endl
     	<< "  INDEX    is the SDO index and must be an unsigned" << endl
@@ -191,6 +192,14 @@
                 data.data_size = strValue.str().size();
                 strValue >> (char *) data.data;
                 break;
+            case 0x000a: // octet_string
+                if (strValue.str().size() >= data.data_size) {
+                    err << "String too large";
+                    throwCommandException(err);
+                }
+                data.data_size = strValue.str().size();
+                strValue >> (char *) data.data;
+                break;
 
             default:
                 delete [] data.data;
--- a/tool/CommandUpload.cpp	Mon Jan 19 14:46:55 2009 +0000
+++ b/tool/CommandUpload.cpp	Tue Jan 20 08:04:50 2009 +0000
@@ -37,7 +37,8 @@
         << "the --type option is mandatory."  << endl
         << endl
         << "These are the valid SDO entry data types:" << endl
-        << "  int8, int16, int32, uint8, uint16, uint32, string." << endl
+        << "  int8, int16, int32, uint8, uint16, uint32, string," << endl
+        << "  octet_string." << endl
         << endl
         << "Arguments:" << endl
         << "  INDEX    is the SDO index and must be an unsigned" << endl
@@ -182,6 +183,10 @@
             cout << string((const char *) data.target, data.data_size)
                 << endl;
             break;
+        case 0x000a: // octet_string
+            cout << string((const char *) data.target, data.data_size)
+                << endl;
+            break;
         default:
             printRawData(data.target, data.data_size); // FIXME
             break;
--- a/tool/SdoCommand.cpp	Mon Jan 19 14:46:55 2009 +0000
+++ b/tool/SdoCommand.cpp	Tue Jan 20 08:04:50 2009 +0000
@@ -57,14 +57,15 @@
 /****************************************************************************/
 
 const SdoCommand::DataType SdoCommand::dataTypes[] = {
-    {"int8",   0x0002, 1},
-    {"int16",  0x0003, 2},
-    {"int32",  0x0004, 4},
-    {"uint8",  0x0005, 1},
-    {"uint16", 0x0006, 2},
-    {"uint32", 0x0007, 4},
-    {"string", 0x0009, 0},
-    {"raw",    0xffff, 0},
+    {"int8",         0x0002, 1},
+    {"int16",        0x0003, 2},
+    {"int32",        0x0004, 4},
+    {"uint8",        0x0005, 1},
+    {"uint16",       0x0006, 2},
+    {"uint32",       0x0007, 4},
+    {"string",       0x0009, 0},
+    {"octet_string", 0x000a, 0},
+    {"raw",          0xffff, 0},
     {}
 };