Introduced ec_datagram_type_string().

This commit is contained in:
Florian Pose
2008-02-22 16:03:08 +00:00
parent 39f4da4d4f
commit 1bb9697a15
2 changed files with 37 additions and 1 deletions

View File

@@ -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 @@ void ec_datagram_output_stats(
}
/*****************************************************************************/
/** 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];
}
/*****************************************************************************/

View File

@@ -138,7 +138,8 @@ int ec_datagram_lwr(ec_datagram_t *, uint32_t, size_t, uint8_t *);
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 *);
/*****************************************************************************/