Rahmen jetzt zustandslos.
authorFlorian Pose <fp@igh-essen.com>
Tue, 28 Feb 2006 09:25:51 +0000
changeset 90 044e97bce4bd
parent 89 e91ef35c36db
child 91 0120d6214948
Rahmen jetzt zustandslos.
master/canopen.c
master/domain.c
master/frame.c
master/frame.h
master/globals.h
master/master.c
--- a/master/canopen.c	Tue Feb 28 09:09:08 2006 +0000
+++ b/master/canopen.c	Tue Feb 28 09:25:51 2006 +0000
@@ -59,7 +59,7 @@
     ec_frame_init_npwr(&frame, master, slave->station_address,
                        0x1800, 0xF6, data);
 
-    if (unlikely(ec_frame_send_receive(&frame) < 0)) {
+    if (unlikely(ec_frame_send_receive(&frame))) {
         EC_ERR("Mailbox sending failed on slave %i!\n", slave->ring_position);
         return -1;
     }
--- a/master/domain.c	Tue Feb 28 09:09:08 2006 +0000
+++ b/master/domain.c	Tue Feb 28 09:25:51 2006 +0000
@@ -311,12 +311,7 @@
         }
 
         if (unlikely(ec_frame_receive(frame) < 0)) {
-            EC_ERR("Receive error!\n");
-            return -1;
-        }
-
-        if (unlikely(frame->state != ec_frame_received)) {
-            EC_WARN("Process data command not received!\n");
+            EC_ERR("Receiving process data failed!\n");
             return -1;
         }
 
--- a/master/frame.c	Tue Feb 28 09:09:08 2006 +0000
+++ b/master/frame.c	Tue Feb 28 09:25:51 2006 +0000
@@ -19,7 +19,6 @@
 
 #define EC_FUNC_HEADER \
     frame->master = master; \
-    frame->state = ec_frame_ready; \
     frame->index = 0; \
     frame->working_counter = 0;
 
@@ -258,10 +257,6 @@
         EC_DBG("ec_frame_send\n");
     }
 
-    if (unlikely(frame->state != ec_frame_ready)) {
-        EC_WARN("Frame not in \"ready\" state!\n");
-    }
-
     command_size = frame->data_length + EC_COMMAND_HEADER_SIZE
         + EC_COMMAND_FOOTER_SIZE;
     frame_size = command_size + EC_FRAME_HEADER_SIZE;
@@ -284,8 +279,6 @@
         EC_DBG("Sending command index 0x%X\n", frame->index);
     }
 
-    frame->state = ec_frame_sent;
-
     // Zeiger auf Socket-Buffer holen
     data = ec_device_prepare(&frame->master->device);
 
@@ -336,11 +329,6 @@
     uint8_t command_type, command_index;
     ec_device_t *device;
 
-    if (unlikely(frame->state != ec_frame_sent)) {
-        EC_ERR("Frame was not sent!\n");
-        return -1;
-    }
-
     device = &frame->master->device;
 
     if (!(received_length = ec_device_received(device))) return -1;
@@ -388,8 +376,6 @@
         return -1;
     }
 
-    frame->state = ec_frame_received;
-
     // Empfangene Daten in Kommandodatenspeicher kopieren
     memcpy(frame->data, data, data_length);
     data += data_length;
--- a/master/frame.h	Tue Feb 28 09:09:08 2006 +0000
+++ b/master/frame.h	Tue Feb 28 09:25:51 2006 +0000
@@ -16,23 +16,6 @@
 
 /*****************************************************************************/
 
-#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE - EC_FRAME_HEADER_SIZE \
-                                            - EC_COMMAND_HEADER_SIZE \
-                                            - EC_COMMAND_FOOTER_SIZE)
-
-/*****************************************************************************/
-
-/**
-   Status eines EtherCAT-Rahmens.
-*/
-
-typedef enum {
-  ec_frame_ready, ec_frame_sent, ec_frame_received
-}
-ec_frame_state_t;
-
-/*****************************************************************************/
-
 /**
    EtherCAT-Rahmen-Typ
 */
@@ -44,9 +27,9 @@
   ec_frame_type_apwr = 0x02, /**< Auto-increment physical write */
   ec_frame_type_nprd = 0x04, /**< Node-addressed physical read */
   ec_frame_type_npwr = 0x05, /**< Node-addressed physical write */
-  ec_frame_type_brd = 0x07,  /**< Broadcast read */
-  ec_frame_type_bwr = 0x08,  /**< Broadcast write */
-  ec_frame_type_lrw = 0x0C   /**< Logical read/write */
+  ec_frame_type_brd  = 0x07, /**< Broadcast read */
+  ec_frame_type_bwr  = 0x08, /**< Broadcast write */
+  ec_frame_type_lrw  = 0x0C  /**< Logical read/write */
 }
 ec_frame_type_t;
 
@@ -90,7 +73,6 @@
     ec_address_t address; /**< Adresse des/der Empfänger */
     unsigned int data_length; /**< Länge der zu sendenden und/oder empfangenen
                                  Daten */
-    ec_frame_state_t state; /**< Zustand des Kommandos */
     uint8_t index; /**< Kommando-Index, mit dem der Frame gesendet wurde
                             (wird vom Master beim Senden gesetzt). */
     uint16_t working_counter; /**< Working-Counter */
--- a/master/globals.h	Tue Feb 28 09:09:08 2006 +0000
+++ b/master/globals.h	Tue Feb 28 09:25:51 2006 +0000
@@ -24,6 +24,11 @@
 #define EC_FMMU_SIZE 16 /**< Größe einer FMMU-Konfigurationsseite */
 #define EC_MAX_FMMUS 16 /**< Maximale Anzahl FMMUs pro Slave */
 
+#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE \
+                          - EC_FRAME_HEADER_SIZE \
+                          - EC_COMMAND_HEADER_SIZE \
+                          - EC_COMMAND_FOOTER_SIZE) /**< Maximale Datengröße */
+
 #define EC_MASTER_MAX_DOMAINS 10 /**< Maximale Anzahl Domänen eines Masters */
 
 #ifndef NULL
--- a/master/master.c	Tue Feb 28 09:09:08 2006 +0000
+++ b/master/master.c	Tue Feb 28 09:25:51 2006 +0000
@@ -164,24 +164,23 @@
     unsigned int i;
     unsigned char data[2];
 
-    if (master->slaves || master->slave_count)
-        EC_WARN("Slave scan already done!\n");
-    ec_master_clear_slaves(master);
+    if (master->slaves || master->slave_count) {
+        EC_ERR("Slave scan already done!\n");
+        return -1;
+    }
 
     // Determine number of slaves on bus
-
     ec_frame_init_brd(&frame, master, 0x0000, 4);
-    if (unlikely(ec_frame_send_receive(&frame) < 0)) return -1;
-
+    if (unlikely(ec_frame_send_receive(&frame))) return -1;
     master->slave_count = frame.working_counter;
     EC_INFO("Found %i slaves on bus.\n", master->slave_count);
 
     if (!master->slave_count) return 0;
 
     if (!(master->slaves = (ec_slave_t *) kmalloc(master->slave_count
-                                                      * sizeof(ec_slave_t),
-                                                      GFP_KERNEL))) {
-        EC_ERR("Could not allocate memory for bus slaves!\n");
+                                                  * sizeof(ec_slave_t),
+                                                  GFP_KERNEL))) {
+        EC_ERR("Could not allocate memory for slaves!\n");
         return -1;
     }
 
@@ -204,7 +203,7 @@
         ec_frame_init_apwr(&frame, master, slave->ring_position, 0x0010,
                            sizeof(uint16_t), data);
 
-        if (unlikely(ec_frame_send_receive(&frame) < 0)) {
+        if (unlikely(ec_frame_send_receive(&frame))) {
             EC_ERR("Writing station address failed on slave %i!\n", i);
             return -1;
         }
@@ -486,7 +485,7 @@
             memset(data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count);
             ec_frame_init_npwr(&frame, master, slave->station_address, 0x0600,
                                EC_FMMU_SIZE * slave->base_fmmu_count, data);
-            if (unlikely(ec_frame_send_receive(&frame) < 0)) {
+            if (unlikely(ec_frame_send_receive(&frame))) {
                 EC_ERR("Resetting FMMUs failed on slave %i!\n",
                        slave->ring_position);
                 return -1;
@@ -498,7 +497,7 @@
             memset(data, 0x00, EC_SYNC_SIZE * slave->base_sync_count);
             ec_frame_init_npwr(&frame, master, slave->station_address, 0x0800,
                                EC_SYNC_SIZE * slave->base_sync_count, data);
-            if (unlikely(ec_frame_send_receive(&frame) < 0)) {
+            if (unlikely(ec_frame_send_receive(&frame))) {
                 EC_ERR("Resetting sync managers failed on slave %i!\n",
                        slave->ring_position);
                 return -1;