88 unsigned int timeout_ms =
218 EC_SLAVE_ERR(slave,
"Failed to receive state datagram: ");
233 EC_SLAVE_ERR(slave,
"Failed to set state %s: ", state_str);
249 EC_SLAVE_ERR(slave,
"Failed to set state %s: ", state_str);
275 unsigned int timeout_ms;
282 EC_SLAVE_ERR(slave,
"Failed to receive state checking datagram: ");
291 EC_SLAVE_ERR(slave,
"Failed to check state %s: ", req_state);
330 EC_SLAVE_ERR(slave,
"Failed to set %s state, slave refused state" 331 " change (%s).\n", req_state, cur_state);
341 timeout_ms * HZ / 1000) {
346 EC_SLAVE_ERR(slave,
"Timeout after %u ms while setting state %s.\n",
347 timeout_ms, state_str);
383 {0x0000,
"No error"},
384 {0x0001,
"Unspecified error"},
385 {0x0002,
"No Memory"},
386 {0x0011,
"Invalid requested state change"},
387 {0x0012,
"Unknown requested state"},
388 {0x0013,
"Bootstrap not supported"},
389 {0x0014,
"No valid firmware"},
390 {0x0015,
"Invalid mailbox configuration"},
391 {0x0016,
"Invalid mailbox configuration"},
392 {0x0017,
"Invalid sync manager configuration"},
393 {0x0018,
"No valid inputs available"},
394 {0x0019,
"No valid outputs"},
395 {0x001A,
"Synchronization error"},
396 {0x001B,
"Sync manager watchdog"},
397 {0x001C,
"Invalid sync manager types"},
398 {0x001D,
"Invalid output configuration"},
399 {0x001E,
"Invalid input configuration"},
400 {0x001F,
"Invalid watchdog configuration"},
401 {0x0020,
"Slave needs cold start"},
402 {0x0021,
"Slave needs INIT"},
403 {0x0022,
"Slave needs PREOP"},
404 {0x0023,
"Slave needs SAFEOP"},
405 {0x0024,
"Invalid Input Mapping"},
406 {0x0025,
"Invalid Output Mapping"},
407 {0x0026,
"Inconsistent Settings"},
408 {0x0027,
"Freerun not supported"},
409 {0x0028,
"Synchronization not supported"},
410 {0x0029,
"Freerun needs 3 Buffer Mode"},
411 {0x002A,
"Background Watchdog"},
412 {0x002B,
"No Valid Inputs and Outputs"},
413 {0x002C,
"Fatal Sync Error"},
414 {0x002D,
"No Sync Error"},
415 {0x0030,
"Invalid DC SYNCH configuration"},
416 {0x0031,
"Invalid DC latch configuration"},
417 {0x0032,
"PLL error"},
418 {0x0033,
"DC Sync IO Error"},
419 {0x0034,
"DC Sync Timeout Error"},
420 {0x0035,
"DC Invalid Sync Cycle Time"},
421 {0x0036,
"DC Sync0 Cycle Time"},
422 {0x0037,
"DC Sync1 Cycle Time"},
429 {0x0050,
"EEPROM No Access"},
430 {0x0051,
"EEPROM Error"},
431 {0x0060,
"Slave Restarted Locally"},
455 " AL status code datagram: ");
462 " datagram failed: ");
467 if (al_msg->
code != code) {
475 if (al_msg->
code == 0xffff) {
504 EC_SLAVE_ERR(slave,
"Failed to receive state ack datagram: ");
511 EC_SLAVE_ERR(slave,
"Reception of state ack datagram failed: ");
536 unsigned int timeout_ms;
543 EC_SLAVE_ERR(slave,
"Failed to receive state ack check datagram: ");
550 EC_SLAVE_ERR(slave,
"Reception of state ack check datagram failed: ");
577 timeout_ms * HZ / 1000) {
582 EC_SLAVE_ERR(slave,
"Timeout after %u ms while acknowledging" 583 " state %s.\n", timeout_ms, state_str);
#define EC_FSM_RETRIES
Number of state machine retries on datagram timeout.
unsigned long jiffies_sent
Jiffies, when the datagram was sent.
uint8_t spontaneous_change
spontaneous state change detected
unsigned int ec_slave_config_al_timeout(const ec_slave_config_t *sc, ec_slave_state_t from, ec_slave_state_t to)
Return an AL state timeout.
OP (mailbox communication and input/output update)
EtherCAT state change FSM.
size_t ec_state_string(uint8_t, char *, uint8_t)
Prints slave states in clear text.
uint8_t take_time
take sending timestamp
ec_slave_state_t current_state
Current application state.
#define EC_SLAVE_WARN(slave, fmt, args...)
Convenience macro for printing slave-specific warnings to syslog.
Bootstrap state (mailbox communication, firmware update)
void ec_fsm_change_start(ec_fsm_change_t *fsm, ec_slave_t *slave, ec_slave_state_t state)
Starts the change state machine.
uint16_t working_counter
Working counter.
unsigned int ec_fsm_change_timeout_ms(const ec_fsm_change_t *)
Get timeout in ms.
void ec_fsm_change_state_end(ec_fsm_change_t *)
State: END.
Acknowledge/Error bit (no actual state)
uint16_t station_address
Configured station address.
const char * message
Message belonging to code.
Global definitions and macros.
ec_datagram_t * datagram
datagram used in the state machine
EtherCAT master structure.
SAFEOP (mailbox communication and input update)
void ec_fsm_change_state_error(ec_fsm_change_t *)
State: ERROR.
only state acknowledgement
void ec_datagram_zero(ec_datagram_t *datagram)
Fills the datagram payload memory with zeros.
ec_datagram_state_t state
State.
ec_slave_config_t * config
Current configuration.
unsigned long jiffies_start
change timer
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
void(* state)(ec_fsm_change_t *)
slave state change state function
void ec_datagram_print_wc_error(const ec_datagram_t *datagram)
Evaluates the working counter of a single-cast datagram.
int ec_fsm_change_exec(ec_fsm_change_t *fsm)
Executes the current state of the state machine.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
void ec_fsm_change_state_start(ec_fsm_change_t *)
Change state: START.
void ec_fsm_change_clear(ec_fsm_change_t *fsm)
Destructor.
int ec_datagram_fpwr(ec_datagram_t *datagram, uint16_t configured_address, uint16_t mem_address, size_t data_size)
Initializes an EtherCAT FPWR datagram.
ec_fsm_change_mode_t mode
full state change, or ack only.
ec_slave_state_t
State of an EtherCAT slave.
void ec_fsm_change_state_check_ack(ec_fsm_change_t *)
Change state: CHECK ACK.
int ec_datagram_fprd(ec_datagram_t *datagram, uint16_t configured_address, uint16_t mem_address, size_t data_size)
Initializes an EtherCAT FPRD datagram.
void ec_fsm_change_state_status(ec_fsm_change_t *)
Change state: STATUS.
#define EC_SLAVE_INFO(slave, fmt, args...)
Convenience macro for printing slave-specific information to syslog.
void ec_fsm_change_init(ec_fsm_change_t *fsm, ec_datagram_t *datagram)
Constructor.
void ec_fsm_change_state_ack(ec_fsm_change_t *)
Change state: ACK.
const ec_code_msg_t al_status_messages[]
Application layer status messages.
INIT state (no mailbox communication, no IO)
#define EC_READ_U16(DATA)
Read a 16-bit unsigned value from EtherCAT data.
ec_slave_state_t requested_state
input: state
void ec_datagram_print_state(const ec_datagram_t *datagram)
Prints the state of a datagram.
ec_slave_t * slave
slave the FSM runs on
#define EC_STATE_STRING_SIZE
Minimum size of a buffer used with ec_state_string().
void ec_fsm_change_ack(ec_fsm_change_t *fsm, ec_slave_t *slave)
Starts the change state machine to only acknowlegde a slave's state.
uint8_t * data
Datagram payload.
#define EC_READ_U8(DATA)
Read an 8-bit unsigned value from EtherCAT data.
void ec_fsm_change_state_code(ec_fsm_change_t *)
Change state: CODE.
EtherCAT slave configuration structure.
void ec_fsm_change_state_check(ec_fsm_change_t *)
Change state: CHECK.
PREOP state (mailbox communication, no IO)
void ec_fsm_change_state_start_code(ec_fsm_change_t *)
Enter reading AL status code.
ec_slave_state_t old_state
prior slave state
unsigned int retries
retries upon datagram timeout
unsigned int error_flag
Stop processing after an error.
unsigned long jiffies_received
Jiffies, when the datagram was received.
EtherCAT state change FSM.
int ec_fsm_change_success(ec_fsm_change_t *fsm)
Returns, if the state machine terminated with success.