Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE

This commit is contained in:
Florian Pose 2006-10-17 14:15:48 +00:00
parent 9f751d8e72
commit 3dc90146fd
4 changed files with 14 additions and 6 deletions

View File

@ -475,7 +475,7 @@ void ec_fsm_master_broadcast(ec_fsm_t *fsm /**< finite state machine */)
}
if (states_change) {
char states[25];
char states[EC_STATE_STRING_SIZE];
ec_state_string(fsm->master_slave_states, states);
EC_INFO("Slave states: %s.\n", states);
}
@ -555,7 +555,7 @@ void ec_fsm_master_action_process_states(ec_fsm_t *fsm
{
ec_master_t *master = fsm->master;
ec_slave_t *slave;
char old_state[25], new_state[25];
char old_state[EC_STATE_STRING_SIZE], new_state[EC_STATE_STRING_SIZE];
// check if any slaves are not in the state, they're supposed to be
list_for_each_entry(slave, &master->slaves, list) {
@ -690,7 +690,7 @@ void ec_fsm_master_read_states(ec_fsm_t *fsm /**< finite state machine */)
// slave responded
new_state = EC_READ_U8(datagram->data);
if (!slave->online) { // slave was offline before
char cur_state[25];
char cur_state[EC_STATE_STRING_SIZE];
slave->online = 1;
slave->error_flag = 0; // clear error flag
slave->current_state = new_state;
@ -698,7 +698,7 @@ void ec_fsm_master_read_states(ec_fsm_t *fsm /**< finite state machine */)
EC_INFO("Slave %i: online (%s).\n", slave->ring_position, cur_state);
}
else if (new_state != slave->current_state) {
char old_state[25], cur_state[25];
char old_state[EC_STATE_STRING_SIZE], cur_state[EC_STATE_STRING_SIZE];
ec_state_string(slave->current_state, old_state);
ec_state_string(new_state, cur_state);
EC_INFO("Slave %i: %s -> %s.\n",

View File

@ -77,6 +77,9 @@
/** datagram timeout in microseconds */
#define EC_IO_TIMEOUT 500
/** minimum size of a buffer used with ec_state_string() */
#define EC_STATE_STRING_SIZE 30
/******************************************************************************
* EtherCAT protocol
*****************************************************************************/

View File

@ -233,7 +233,8 @@ void ec_print_data_diff(const uint8_t *d1, /**< first data */
*/
size_t ec_state_string(uint8_t states, /**< slave states */
char *buffer /**< target buffer (min. 25 bytes) */
char *buffer /**< target buffer
(min. EC_STATE_STRING_SIZE bytes) */
)
{
off_t off = 0;
@ -262,6 +263,10 @@ size_t ec_state_string(uint8_t states, /**< slave states */
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, "ERR");
}
return off;
}

View File

@ -781,7 +781,7 @@ ssize_t ec_store_slave_attribute(struct kobject *kobj, /**< slave's kobject */
ec_slave_t *slave = container_of(kobj, ec_slave_t, kobj);
if (attr == &attr_state) {
char state[25];
char state[EC_STATE_STRING_SIZE];
if (!strcmp(buffer, "INIT\n"))
slave->requested_state = EC_SLAVE_STATE_INIT;
else if (!strcmp(buffer, "PREOP\n"))