Introduced ecrt_voe_handler_received_header(); renamed
authorFlorian Pose <fp@igh-essen.com>
Tue, 30 Sep 2008 07:50:34 +0000
changeset 1226 afb189516fcf
parent 1225 4d5b739edcb5
child 1227 471ceaf7f89d
Introduced ecrt_voe_handler_received_header(); renamed
ecrt_voe_handler_header() to ecrt_voe_handler_send_header().
include/ecrt.h
master/voe_handler.c
--- a/include/ecrt.h	Tue Sep 30 07:34:55 2008 +0000
+++ b/include/ecrt.h	Tue Sep 30 07:50:34 2008 +0000
@@ -923,21 +923,35 @@
  * VoE handler methods.
  ****************************************************************************/
 
-/** Sets the VoE header containing vendor ID and vendor type.
+/** Sets the VoE header for future send operations.
  *
  * A VoE message shall contain a 4-byte vendor ID, followed by a 2-byte vendor
  * type at as header. These numbers can be set with this function.
  */
-void ecrt_voe_handler_header(
+void ecrt_voe_handler_send_header(
         ec_voe_handler_t *voe, /**< VoE handler. */
         uint32_t vendor_id, /**< Vendor ID. */
         uint16_t vendor_type /**< Vendor-specific type. */
         );
 
+/** Reads the header data of a received VoE message.
+ *
+ * This method can be used after a read operation has succeded, to get the
+ * received header information.
+ *
+ * The header information is stored at the memory given by the pointer
+ * parameters.
+ */
+void ecrt_voe_handler_received_header(
+        const ec_voe_handler_t *voe, /**< VoE handler. */
+        uint32_t *vendor_id, /**< Vendor ID. */
+        uint16_t *vendor_type /**< Vendor-specific type. */
+        );
+
 /** Access to the VoE handler's data.
  *
  * This function returns a pointer to the VoE handler's internal memory, after
- * the VoE header (see ecrt_voe_handler_header()).
+ * the VoE header (see ecrt_voe_handler_send_header()).
  *
  * - After a read operation was successful, the memory contains the received
  *   data. The size of the received data can be determined via
@@ -955,7 +969,7 @@
 /** Returns the current data size.
  *
  * The data size is the size of the VoE data without the header (see
- * ecrt_voe_handler_header()).
+ * ecrt_voe_handler_send_header()).
  *
  * When the VoE handler is created, the data size is set to the size of the
  * reserved memory. At a write operation, the data size is set to the number
@@ -971,7 +985,8 @@
 /** Start a VoE write operation.
  *
  * After this function has been called, the ecrt_voe_handler_execute() method
- * must be called in every bus cycle as long as it returns EC_REQUEST_BUSY.
+ * must be called in every bus cycle as long as it returns EC_REQUEST_BUSY. No
+ * other operation may be started while the handler is busy.
  */
 void ecrt_voe_handler_write(
         ec_voe_handler_t *voe, /**< VoE handler. */
@@ -981,10 +996,12 @@
 /** Start a VoE read operation.
  *
  * After this function has been called, the ecrt_voe_handler_execute() method
- * must be called in every bus cycle as long as it returns EC_REQUEST_BUSY.
+ * must be called in every bus cycle as long as it returns EC_REQUEST_BUSY. No
+ * other operation may be started while the handler is busy.
  *
  * On success, the size of the read data can be determined via
- * ecrt_voe_handler_data_size().
+ * ecrt_voe_handler_data_size(), while the VoE header of the received data
+ * can be retrieved with ecrt_voe_handler_received_header().
  */
 void ecrt_voe_handler_read(
         ec_voe_handler_t *voe /**< VoE handler. */
--- a/master/voe_handler.c	Tue Sep 30 07:34:55 2008 +0000
+++ b/master/voe_handler.c	Tue Sep 30 07:50:34 2008 +0000
@@ -111,7 +111,7 @@
  * Application interface.
  ****************************************************************************/
 
-void ecrt_voe_handler_header(ec_voe_handler_t *voe, uint32_t vendor_id,
+void ecrt_voe_handler_send_header(ec_voe_handler_t *voe, uint32_t vendor_id,
         uint16_t vendor_type)
 {
     voe->vendor_id = vendor_id;
@@ -120,6 +120,19 @@
 
 /*****************************************************************************/
 
+void ecrt_voe_handler_received_header(const ec_voe_handler_t *voe,
+        uint32_t *vendor_id, uint16_t *vendor_type)
+{
+    uint8_t *header = voe->datagram.data + EC_MBOX_HEADER_SIZE;
+
+    if (vendor_id)
+        *vendor_id = EC_READ_U32(header);
+    if (vendor_type)
+        *vendor_type = EC_READ_U16(header + 4);
+}
+
+/*****************************************************************************/
+
 uint8_t *ecrt_voe_handler_data(ec_voe_handler_t *voe)
 {
     return voe->datagram.data + EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE;
@@ -405,7 +418,8 @@
 
 /** \cond */
 
-EXPORT_SYMBOL(ecrt_voe_handler_header);
+EXPORT_SYMBOL(ecrt_voe_handler_send_header);
+EXPORT_SYMBOL(ecrt_voe_handler_received_header);
 EXPORT_SYMBOL(ecrt_voe_handler_data);
 EXPORT_SYMBOL(ecrt_voe_handler_data_size);
 EXPORT_SYMBOL(ecrt_voe_handler_read);