45 #define EC_AL_STATE_CHANGE_TIMEOUT 5 185 EC_SLAVE_ERR(slave,
"Failed to receive state datagram: ");
200 EC_SLAVE_ERR(slave,
"Failed to set state %s: ", state_str);
216 EC_SLAVE_ERR(slave,
"Failed to set state %s: ", state_str);
248 EC_SLAVE_ERR(slave,
"Failed to receive state checking datagram: ");
257 EC_SLAVE_ERR(slave,
"Failed to check state %s: ", req_state);
296 EC_SLAVE_ERR(slave,
"Failed to set %s state, slave refused state" 297 " change (%s).\n", req_state, cur_state);
311 EC_SLAVE_ERR(slave,
"Timeout while setting state %s.\n", state_str);
347 {0x0000,
"No error"},
348 {0x0001,
"Unspecified error"},
349 {0x0002,
"No Memory"},
350 {0x0011,
"Invalid requested state change"},
351 {0x0012,
"Unknown requested state"},
352 {0x0013,
"Bootstrap not supported"},
353 {0x0014,
"No valid firmware"},
354 {0x0015,
"Invalid mailbox configuration"},
355 {0x0016,
"Invalid mailbox configuration"},
356 {0x0017,
"Invalid sync manager configuration"},
357 {0x0018,
"No valid inputs available"},
358 {0x0019,
"No valid outputs"},
359 {0x001A,
"Synchronization error"},
360 {0x001B,
"Sync manager watchdog"},
361 {0x001C,
"Invalid sync manager types"},
362 {0x001D,
"Invalid output configuration"},
363 {0x001E,
"Invalid input configuration"},
364 {0x001F,
"Invalid watchdog configuration"},
365 {0x0020,
"Slave needs cold start"},
366 {0x0021,
"Slave needs INIT"},
367 {0x0022,
"Slave needs PREOP"},
368 {0x0023,
"Slave needs SAFEOP"},
369 {0x0024,
"Invalid Input Mapping"},
370 {0x0025,
"Invalid Output Mapping"},
371 {0x0026,
"Inconsistent Settings"},
372 {0x0027,
"Freerun not supported"},
373 {0x0028,
"Synchronization not supported"},
374 {0x0029,
"Freerun needs 3 Buffer Mode"},
375 {0x002A,
"Background Watchdog"},
376 {0x002B,
"No Valid Inputs and Outputs"},
377 {0x002C,
"Fatal Sync Error"},
378 {0x002D,
"No Sync Error"},
379 {0x0030,
"Invalid DC SYNCH configuration"},
380 {0x0031,
"Invalid DC latch configuration"},
381 {0x0032,
"PLL error"},
382 {0x0033,
"DC Sync IO Error"},
383 {0x0034,
"DC Sync Timeout Error"},
384 {0x0035,
"DC Invalid Sync Cycle Time"},
385 {0x0036,
"DC Sync0 Cycle Time"},
386 {0x0037,
"DC Sync1 Cycle Time"},
393 {0x0050,
"EEPROM No Access"},
394 {0x0051,
"EEPROM Error"},
395 {0x0060,
"Slave Restarted Locally"},
419 " AL status code datagram: ");
426 " datagram failed: ");
431 if (al_msg->
code != code) {
439 if (al_msg->
code == 0xffff) {
468 EC_SLAVE_ERR(slave,
"Failed to receive state ack datagram: ");
475 EC_SLAVE_ERR(slave,
"Reception of state ack datagram failed: ");
506 EC_SLAVE_ERR(slave,
"Failed to receive state ack check datagram: ");
513 EC_SLAVE_ERR(slave,
"Reception of state ack check datagram failed: ");
544 EC_SLAVE_ERR(slave,
"Timeout while acknowledging state %s.\n",
#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
#define EC_AL_STATE_CHANGE_TIMEOUT
Timeout while waiting for AL state change [s].
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.
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.
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.
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.
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.
#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.
void ec_fsm_change_state_check(ec_fsm_change_t *)
Change state: CHECK.
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.