80 unsigned long jiffies_start,
81 unsigned long timeout_ms
106 unsigned long jiffies_start,
109 unsigned long timeout_ms
113 jiffies_start, timeout_ms);
144 unsigned long jiffies_start,
145 unsigned long timeout_ms
149 jiffies_start, timeout_ms);
171 fsm->
state(fsm, datagram);
357 " datagram failed: ");
447 " datagram failed: ");
464 fsm->
state(fsm, datagram);
#define EC_FSM_RETRIES
Number of state machine retries on datagram timeout.
void ec_fsm_mbox_state_start(ec_fsm_mbox_t *, ec_datagram_t *)
State: START.
ec_fsm_mbox_mode_t mode
Receive mode.
static void ec_fsm_mbox_fail(ec_fsm_mbox_t *fsm, ec_datagram_t *datagram, int result)
Releases the mailbox read lock and terminates with an error.
ec_datagram_t * datagram
Datagram used in the last step.
EtherCAT mailbox receive state machine.
unsigned long jiffies_start
Reference time for the timeout.
Fetch the mailbox once without checking it.
int ec_fsm_mbox_exec(ec_fsm_mbox_t *fsm, ec_datagram_t *datagram)
Executes the current state of the state machine.
EtherCAT slave structure.
void ec_fsm_mbox_receive(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data, unsigned long jiffies_start, unsigned long timeout_ms)
Starts waiting for a mailbox response.
int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram to fetch mailbox data.
EtherCAT mailbox response data.
Not used by its state machine in this cycle and not to be queued.
ec_fsm_mbox_mode_t
Mode of the mailbox receive state machine.
static void ec_fsm_mbox_start(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data, ec_fsm_mbox_mode_t mode, unsigned long jiffies_start, unsigned long timeout_ms)
Starts the state machine in the given mode.
uint16_t working_counter
Working counter.
Wait for a response until the timeout elapsed.
unsigned int retries
Retries upon datagram timeout.
void ec_fsm_mbox_fetch_nosync(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data, unsigned long jiffies_start, unsigned long timeout_ms)
Starts a single mailbox fetch without a preceding check.
Global definitions and macros.
EtherCAT master structure.
void ec_slave_mbox_take_error(ec_mbox_data_t *mbox_data, const ec_datagram_t *datagram)
Takes over a mailbox error response from a mailbox fetch datagram.
void(* state)(ec_fsm_mbox_t *, ec_datagram_t *)
State function.
static int ec_fsm_mbox_timed_out(const ec_fsm_mbox_t *fsm, unsigned long now)
Checks, if the timeout elapsed.
int ec_fsm_mbox_result(const ec_fsm_mbox_t *fsm)
Returns the result of the terminated state machine.
ec_datagram_state_t state
State.
void ec_fsm_mbox_abort(ec_fsm_mbox_t *fsm)
Aborts the state machine and releases the mailbox read lock, if held.
ec_mbox_data_t * mbox_data
Response buffer of the protocol.
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
void ec_datagram_print_wc_error(const ec_datagram_t *datagram)
Evaluates the working counter of a single-cast datagram.
EtherCAT mailbox receive state machine.
void ec_fsm_mbox_state_check(ec_fsm_mbox_t *, ec_datagram_t *)
State: CHECK.
unsigned long timeout_ms
Response timeout in [ms].
static int ec_fsm_mbox_data_available(const ec_fsm_mbox_t *fsm)
Checks, if a message for the protocol is available.
int ec_read_mbox_locked(ec_slave_t *slave)
Return the current mailbox lock status and lock it if not locked.
void ec_read_mbox_lock_clear(ec_slave_t *slave)
Clears the mailbox lock.
int ec_slave_mbox_prepare_check(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram for checking the mailbox state.
void ec_datagram_print_state(const ec_datagram_t *datagram)
Prints the state of a datagram.
void ec_fsm_mbox_state_end(ec_fsm_mbox_t *, ec_datagram_t *)
State: END.
Check the mailbox once, do not wait.
void ec_fsm_mbox_init(ec_fsm_mbox_t *fsm)
Constructor.
void ec_fsm_mbox_state_fetch(ec_fsm_mbox_t *, ec_datagram_t *)
State: FETCH.
ec_slave_t * slave
Slave the FSM runs on.
int ec_fsm_mbox_holds_lock(const ec_fsm_mbox_t *fsm)
Checks, if the state machine holds the slave's mailbox read lock.
void ec_fsm_mbox_poll(ec_fsm_mbox_t *fsm, ec_slave_t *slave, ec_mbox_data_t *mbox_data)
Starts a single mailbox check without waiting.
void ec_fsm_mbox_state_error(ec_fsm_mbox_t *, ec_datagram_t *)
State: ERROR.
int result
Zero on success, otherwise a negative error code.
unsigned long jiffies_received
Jiffies, when the datagram was received.
size_t payload_size
Size of the mailbox response payload data.
int ec_slave_mbox_check(const ec_datagram_t *datagram)
Processes a mailbox state checking datagram.
void ec_fsm_mbox_clear(ec_fsm_mbox_t *fsm)
Destructor.