AL status code reading after failed state transition.
This commit is contained in:
parent
d3ecd483fa
commit
03ae7f543b
|
|
@ -23,18 +23,7 @@ int ec_slave_fetch_sdo_entries(ec_slave_t *, ec_sdo_t *, uint8_t);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
SDO Abort Code Messages
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t code;
|
||||
const char *message;
|
||||
}
|
||||
ec_sdo_abort_message_t;
|
||||
|
||||
const ec_sdo_abort_message_t sdo_abort_messages[];
|
||||
const ec_code_msg_t sdo_abort_messages[];
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -462,7 +451,7 @@ int ec_slave_fetch_sdo_entries(ec_slave_t *slave, /**< EtherCAT-Slave */
|
|||
|
||||
void ec_canopen_abort_msg(uint32_t abort_code)
|
||||
{
|
||||
const ec_sdo_abort_message_t *abort_msg;
|
||||
const ec_code_msg_t *abort_msg;
|
||||
|
||||
for (abort_msg = sdo_abort_messages; abort_msg->code; abort_msg++) {
|
||||
if (abort_msg->code == abort_code) {
|
||||
|
|
@ -477,7 +466,7 @@ void ec_canopen_abort_msg(uint32_t abort_code)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
const ec_sdo_abort_message_t sdo_abort_messages[] = {
|
||||
const ec_code_msg_t sdo_abort_messages[] = {
|
||||
{0x05030000, "Toggle bit not changed"},
|
||||
{0x05040000, "SDO protocol timeout"},
|
||||
{0x05040001, "Client/Server command specifier not valid or unknown"},
|
||||
|
|
|
|||
|
|
@ -50,6 +50,22 @@ extern void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Code - Message Pair.
|
||||
|
||||
Some EtherCAT commands support reading a status code to display a certain
|
||||
message. This type allows to map a code to a message string.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t code; /**< Code */
|
||||
const char *message; /**< Message belonging to \a code */
|
||||
}
|
||||
ec_code_msg_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/* Emacs-Konfiguration
|
||||
|
|
|
|||
|
|
@ -807,8 +807,7 @@ int ecrt_master_activate(ec_master_t *master /**< EtherCAT-Master */)
|
|||
}
|
||||
|
||||
// Slaves aktivieren
|
||||
for (i = 0; i < master->slave_count; i++)
|
||||
{
|
||||
for (i = 0; i < master->slave_count; i++) {
|
||||
slave = master->slaves + i;
|
||||
|
||||
// Change state to INIT
|
||||
|
|
@ -852,8 +851,7 @@ int ecrt_master_activate(ec_master_t *master /**< EtherCAT-Master */)
|
|||
|
||||
// Known slave type, take type's SM information
|
||||
if (type) {
|
||||
for (j = 0; type->sync_managers[j] && j < EC_MAX_SYNC; j++)
|
||||
{
|
||||
for (j = 0; type->sync_managers[j] && j < EC_MAX_SYNC; j++) {
|
||||
sync = type->sync_managers[j];
|
||||
if (ec_command_npwr(command, slave->station_address,
|
||||
0x0800 + j * EC_SYNC_SIZE, EC_SYNC_SIZE))
|
||||
|
|
@ -936,8 +934,7 @@ int ecrt_master_activate(ec_master_t *master /**< EtherCAT-Master */)
|
|||
}
|
||||
|
||||
// Set FMMUs
|
||||
for (j = 0; j < slave->fmmu_count; j++)
|
||||
{
|
||||
for (j = 0; j < slave->fmmu_count; j++) {
|
||||
fmmu = &slave->fmmus[j];
|
||||
if (ec_command_npwr(command, slave->station_address,
|
||||
0x0600 + j * EC_FMMU_SIZE, EC_FMMU_SIZE))
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
const ec_code_msg_t al_status_messages[];
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Slave-Konstruktor.
|
||||
*/
|
||||
|
|
@ -762,8 +766,8 @@ void ec_slave_state_ack(ec_slave_t *slave,
|
|||
}
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_WARN("Failed to check state acknowledgement 0x%02X on slave %i"
|
||||
" - Timeout!\n", state,slave->ring_position);
|
||||
EC_WARN("Failed to acknowledge state 0x%02X on slave %i"
|
||||
" - Timeout!\n", state, slave->ring_position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -771,6 +775,43 @@ void ec_slave_state_ack(ec_slave_t *slave,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Reads the AL status code of a slave and displays it.
|
||||
|
||||
If the AL status code is not supported, or if no error occurred (both
|
||||
resulting in code=0), nothing is displayed.
|
||||
*/
|
||||
|
||||
void ec_slave_read_al_status_code(ec_slave_t *slave /**< EtherCAT-Slave */)
|
||||
{
|
||||
ec_command_t *command;
|
||||
uint16_t code;
|
||||
const ec_code_msg_t *al_msg;
|
||||
|
||||
command = &slave->master->simple_command;
|
||||
|
||||
if (ec_command_nprd(command, slave->station_address, 0x0134, 2)) return;
|
||||
if (unlikely(ec_master_simple_io(slave->master, command))) {
|
||||
EC_WARN("Failed to read AL status code on slave %i!\n",
|
||||
slave->ring_position);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(code = EC_READ_U16(command->data))) return;
|
||||
|
||||
for (al_msg = al_status_messages; al_msg->code; al_msg++) {
|
||||
if (al_msg->code == code) {
|
||||
EC_ERR("AL status message 0x%04X: \"%s\".\n",
|
||||
al_msg->code, al_msg->message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EC_ERR("Unknown AL status code 0x%04X.\n", code);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Ändert den Zustand eines Slaves.
|
||||
|
||||
|
|
@ -791,7 +832,7 @@ int ec_slave_state_change(ec_slave_t *slave,
|
|||
if (ec_command_npwr(command, slave->station_address, 0x0120, 2)) return -1;
|
||||
EC_WRITE_U16(command->data, state);
|
||||
if (unlikely(ec_master_simple_io(slave->master, command))) {
|
||||
EC_ERR("Failed to set state %02X on slave %i!\n",
|
||||
EC_ERR("Failed to set state 0x%02X on slave %i!\n",
|
||||
state, slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -806,7 +847,7 @@ int ec_slave_state_change(ec_slave_t *slave,
|
|||
if (ec_command_nprd(command, slave->station_address, 0x0130, 2))
|
||||
return -1;
|
||||
if (unlikely(ec_master_simple_io(slave->master, command))) {
|
||||
EC_ERR("Failed to check state %02X on slave %i!\n",
|
||||
EC_ERR("Failed to check state 0x%02X on slave %i!\n",
|
||||
state, slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -814,10 +855,12 @@ int ec_slave_state_change(ec_slave_t *slave,
|
|||
end = get_cycles();
|
||||
|
||||
if (unlikely(EC_READ_U8(command->data) & 0x10)) { // State change error
|
||||
EC_ERR("Could not set state %02X - Slave %i refused state change"
|
||||
" (code %02X)!\n", state, slave->ring_position,
|
||||
EC_ERR("Failed to set state 0x%02X - Slave %i refused state change"
|
||||
" (code 0x%02X)!\n", state, slave->ring_position,
|
||||
EC_READ_U8(command->data));
|
||||
ec_slave_state_ack(slave, EC_READ_U8(command->data) & 0x0F);
|
||||
state = EC_READ_U8(command->data) & 0x0F;
|
||||
ec_slave_read_al_status_code(slave);
|
||||
ec_slave_state_ack(slave, state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -827,7 +870,7 @@ int ec_slave_state_change(ec_slave_t *slave,
|
|||
}
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("Could not check state %02X of slave %i - Timeout!\n",
|
||||
EC_ERR("Failed to check state 0x%02X of slave %i - Timeout!\n",
|
||||
state, slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1101,6 +1144,28 @@ int ecrt_slave_write_alias(ec_slave_t *slave, /** EtherCAT-Slave */
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
const ec_code_msg_t al_status_messages[] = {
|
||||
{0x0001, "Unspecified error"},
|
||||
{0x0011, "Invalud requested state change"},
|
||||
{0x0012, "Unknown requested state"},
|
||||
{0x0013, "Bootstrap not supported"},
|
||||
{0x0014, "No valid firmware"},
|
||||
{0x0015, "Invalid mailbox configuration"},
|
||||
{0x0016, "Invalid mailbox configuration"},
|
||||
{0x0017, "Invalid sync manager configuration"},
|
||||
{0x0018, "No valid inputs available"},
|
||||
{0x0019, "No valid outputs"},
|
||||
{0x001A, "Synchronisation error"},
|
||||
{0x001B, "Sync manager watchdog"},
|
||||
{0x0020, "Slave needs cold start"},
|
||||
{0x0021, "Slave needs INIT"},
|
||||
{0x0022, "Slave needs PREOP"},
|
||||
{0x0023, "Slave needs SAVEOP"},
|
||||
{}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
EXPORT_SYMBOL(ecrt_slave_write_alias);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
Loading…
Reference in New Issue