|
IgH EtherCAT Master
1.7.0
|
EtherCAT mailbox receive state machine. More...
Go to the source code of this file.
Data Structures | |
| struct | ec_fsm_mbox |
| EtherCAT mailbox receive state machine. More... | |
Typedefs | |
| typedef struct ec_fsm_mbox | ec_fsm_mbox_t |
Enumerations | |
| enum | ec_fsm_mbox_mode_t { EC_FSM_MBOX_WAIT, EC_FSM_MBOX_POLL, EC_FSM_MBOX_NOSYNC } |
| Mode of the mailbox receive state machine. More... | |
Functions | |
| void | ec_fsm_mbox_init (ec_fsm_mbox_t *) |
| Constructor. | |
| void | ec_fsm_mbox_clear (ec_fsm_mbox_t *) |
| Destructor. | |
| void | ec_fsm_mbox_receive (ec_fsm_mbox_t *, ec_slave_t *, ec_mbox_data_t *, unsigned long, unsigned long) |
| Starts waiting for a mailbox response. More... | |
| void | ec_fsm_mbox_poll (ec_fsm_mbox_t *, ec_slave_t *, ec_mbox_data_t *) |
| Starts a single mailbox check without waiting. More... | |
| void | ec_fsm_mbox_fetch_nosync (ec_fsm_mbox_t *, ec_slave_t *, ec_mbox_data_t *, unsigned long, unsigned long) |
| Starts a single mailbox fetch without a preceding check. More... | |
| int | ec_fsm_mbox_exec (ec_fsm_mbox_t *, ec_datagram_t *) |
| Executes the current state of the state machine. More... | |
| int | ec_fsm_mbox_result (const ec_fsm_mbox_t *) |
| Returns the result of the terminated state machine. More... | |
| int | ec_fsm_mbox_holds_lock (const ec_fsm_mbox_t *) |
| Checks, if the state machine holds the slave's mailbox read lock. More... | |
| void | ec_fsm_mbox_abort (ec_fsm_mbox_t *) |
| Aborts the state machine and releases the mailbox read lock, if held. | |
EtherCAT mailbox receive state machine.
Definition in file fsm_mbox.h.
| typedef struct ec_fsm_mbox ec_fsm_mbox_t |
Definition at line 47 of file fsm_mbox.h.
| enum ec_fsm_mbox_mode_t |
Mode of the mailbox receive state machine.
| Enumerator | |
|---|---|
| EC_FSM_MBOX_WAIT | Wait for a response until the timeout elapsed. |
| EC_FSM_MBOX_POLL | Check the mailbox once, do not wait. |
| EC_FSM_MBOX_NOSYNC | Fetch the mailbox once without checking it. |
Definition at line 39 of file fsm_mbox.h.
| 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.
The state machine checks the mailbox until a response for the protocol is stored in mbox_data, or the timeout elapsed.
| fsm | Finite state machine. |
| slave | EtherCAT slave. |
| mbox_data | Response buffer of the protocol. |
| jiffies_start | Reference time for the timeout, usually the time the request was sent. |
| timeout_ms | Response timeout in [ms]. |
Definition at line 102 of file fsm_mbox.c.
| 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.
If no message for the protocol is available, or another state machine reads the mailbox, the state machine fails with -EAGAIN or -EBUSY.
| fsm | Finite state machine. |
| slave | EtherCAT slave. |
| mbox_data | Response buffer of the protocol. |
Definition at line 123 of file fsm_mbox.c.
| 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.
Waits for the mailbox read lock until the timeout elapsed. If the fetched mailbox contains no message for the protocol, the state machine fails with -EAGAIN.
| fsm | Finite state machine. |
| slave | EtherCAT slave. |
| mbox_data | Response buffer of the protocol. |
| jiffies_start | Reference time for the timeout. |
| timeout_ms | Timeout in [ms]. |
Definition at line 140 of file fsm_mbox.c.
| int ec_fsm_mbox_exec | ( | ec_fsm_mbox_t * | fsm, |
| ec_datagram_t * | datagram | ||
| ) |
Executes the current state of the state machine.
Every state either uses the datagram, or marks it as unused.
| fsm | Finite state machine. |
| datagram | Datagram to use. |
Definition at line 161 of file fsm_mbox.c.
| int ec_fsm_mbox_result | ( | const ec_fsm_mbox_t * | fsm | ) |
Returns the result of the terminated state machine.
| 0 | A message for the protocol is available in the response buffer. |
| -EIO | Mailbox check or fetch failed. |
| -ETIMEDOUT | No response within the timeout. |
| -EAGAIN | No message for the protocol (poll and nosync mode). |
| -EBUSY | Another state machine reads the mailbox (poll mode). |
| fsm | Finite state machine. |
Definition at line 195 of file fsm_mbox.c.
| int ec_fsm_mbox_holds_lock | ( | const ec_fsm_mbox_t * | fsm | ) |
Checks, if the state machine holds the slave's mailbox read lock.
| fsm | Finite state machine. |
Definition at line 208 of file fsm_mbox.c.