Skip to content
Snippets Groups Projects
Commit dc850123 authored by Florian Pose's avatar Florian Pose
Browse files

Introduced ec_datagram_type_string().

parent 9ba9d576
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,30 @@ ...@@ -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. /** Constructor.
*/ */
void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */) void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */)
...@@ -473,3 +497,14 @@ void ec_datagram_output_stats( ...@@ -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];
}
/*****************************************************************************/
...@@ -138,7 +138,8 @@ int ec_datagram_lwr(ec_datagram_t *, uint32_t, size_t, uint8_t *); ...@@ -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 *); 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_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 *);
/*****************************************************************************/ /*****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment