Introduced ec_datagram_type_string().
authorFlorian Pose <fp@igh-essen.com>
Fri, 22 Feb 2008 16:03:08 +0000
changeset 816 d02761e14eb0
parent 815 002fe9ec778f
child 817 118dea2fa505
Introduced ec_datagram_type_string().
master/datagram.c
master/datagram.h
--- a/master/datagram.c	Fri Feb 22 15:35:39 2008 +0000
+++ b/master/datagram.c	Fri Feb 22 16:03:08 2008 +0000
@@ -63,6 +63,30 @@
 
 /*****************************************************************************/
 
+/** Array of datagram type strings used in ec_datagram_type_string().
+ *
+ * \attention This is indexed by ec_datagram_type_t.
+ */
+static const char *type_strings[] = {
+    "?",
+    "APRD",
+    "APWR",
+    "APRW",
+    "FPRD",
+    "FPWR",
+    "FPRW",
+    "BRD",
+    "BWR",
+    "BRW",
+    "LRD",
+    "LWR",
+    "LRW",
+    "ARMW",
+    "FRMW"
+};
+    
+/*****************************************************************************/
+
 /** Constructor.
  */
 void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */)
@@ -473,3 +497,14 @@
 }
 
 /*****************************************************************************/
+
+/** Returns a string describing the datagram type.
+ */
+const char *ec_datagram_type_string(
+        const ec_datagram_t *datagram /**< EtherCAT datagram. */
+        )
+{
+    return type_strings[datagram->type];
+}
+
+/*****************************************************************************/
--- a/master/datagram.h	Fri Feb 22 15:35:39 2008 +0000
+++ b/master/datagram.h	Fri Feb 22 16:03:08 2008 +0000
@@ -138,7 +138,8 @@
 int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t, uint8_t *);
 
 void ec_datagram_print_wc_error(const ec_datagram_t *);
-void ec_datagram_output_stats(ec_datagram_t *datagram);
+void ec_datagram_output_stats(ec_datagram_t *);
+const char *ec_datagram_type_string(const ec_datagram_t *);
 
 /*****************************************************************************/