--- a/master/module.c Mon Jan 19 12:36:18 2009 +0000
+++ b/master/module.c Mon Jan 19 14:46:55 2009 +0000
@@ -357,8 +357,9 @@
/** Prints slave states in clear text.
*/
size_t ec_state_string(uint8_t states, /**< slave states */
- char *buffer /**< target buffer
+ char *buffer, /**< target buffer
(min. EC_STATE_STRING_SIZE bytes) */
+ uint8_t multi /**< Show multi-state mask. */
)
{
off_t off = 0;
@@ -369,24 +370,42 @@
return off;
}
- if (states & EC_SLAVE_STATE_INIT) {
- off += sprintf(buffer + off, "INIT");
+ if (multi) { // multiple slaves
+ if (states & EC_SLAVE_STATE_INIT) {
+ off += sprintf(buffer + off, "INIT");
+ first = 0;
+ }
+ if (states & EC_SLAVE_STATE_PREOP) {
+ if (!first) off += sprintf(buffer + off, ", ");
+ off += sprintf(buffer + off, "PREOP");
+ first = 0;
+ }
+ if (states & EC_SLAVE_STATE_SAFEOP) {
+ if (!first) off += sprintf(buffer + off, ", ");
+ off += sprintf(buffer + off, "SAFEOP");
+ first = 0;
+ }
+ if (states & EC_SLAVE_STATE_OP) {
+ if (!first) off += sprintf(buffer + off, ", ");
+ off += sprintf(buffer + off, "OP");
+ }
+ } else { // single slave
+ if ((states & EC_SLAVE_STATE_MASK) == EC_SLAVE_STATE_INIT) {
+ off += sprintf(buffer + off, "INIT");
+ } else if ((states & EC_SLAVE_STATE_MASK) == EC_SLAVE_STATE_PREOP) {
+ off += sprintf(buffer + off, "PREOP");
+ } else if ((states & EC_SLAVE_STATE_MASK) == EC_SLAVE_STATE_BOOT) {
+ off += sprintf(buffer + off, "BOOT");
+ } else if ((states & EC_SLAVE_STATE_MASK) == EC_SLAVE_STATE_SAFEOP) {
+ off += sprintf(buffer + off, "SAFEOP");
+ } else if ((states & EC_SLAVE_STATE_MASK) == EC_SLAVE_STATE_OP) {
+ off += sprintf(buffer + off, "OP");
+ } else {
+ off += sprintf(buffer + off, "(invalid)");
+ }
first = 0;
}
- if (states & EC_SLAVE_STATE_PREOP) {
- if (!first) off += sprintf(buffer + off, ", ");
- off += sprintf(buffer + off, "PREOP");
- first = 0;
- }
- if (states & EC_SLAVE_STATE_SAFEOP) {
- if (!first) off += sprintf(buffer + off, ", ");
- off += sprintf(buffer + off, "SAFEOP");
- first = 0;
- }
- if (states & EC_SLAVE_STATE_OP) {
- if (!first) off += sprintf(buffer + off, ", ");
- off += sprintf(buffer + off, "OP");
- }
+
if (states & EC_SLAVE_STATE_ACK_ERR) {
if (!first) off += sprintf(buffer + off, " + ");
off += sprintf(buffer + off, "ERROR");