36 #include <linux/module.h> 45 #define EC_VOE_HEADER_SIZE 6 49 #define EC_VOE_RESPONSE_TIMEOUT 500 124 uint16_t vendor_type)
133 uint32_t *vendor_id, uint16_t *vendor_type)
214 EC_SLAVE_DBG(slave, 0,
"Writing %zu bytes of VoE data.\n",
258 EC_SLAVE_ERR(slave,
"Failed to receive VoE write request datagram: ");
265 unsigned long diff_ms =
269 " VoE write request. Retrying after %lu ms...\n",
277 EC_SLAVE_ERR(slave,
"Reception of VoE write request failed: ");
328 EC_SLAVE_ERR(slave,
"Failed to receive VoE mailbox check datagram: ");
337 " datagram failed: ");
343 unsigned long diff_ms =
348 EC_SLAVE_ERR(slave,
"Timeout while waiting for VoE data.\n");
372 uint8_t *data, mbox_prot;
381 EC_SLAVE_ERR(slave,
"Failed to receive VoE read datagram: ");
389 EC_SLAVE_ERR(slave,
"Reception of VoE read response failed: ");
401 if (mbox_prot != EC_MBOX_TYPE_VOE) {
405 " as response.\n", mbox_prot);
414 " incomplete (%zu bytes)!\n", rec_size);
463 uint8_t *data, mbox_prot;
472 EC_SLAVE_ERR(slave,
"Failed to receive VoE read datagram: ");
480 EC_SLAVE_DBG(slave, 1,
"Slave did not send VoE data.\n");
487 EC_SLAVE_WARN(slave,
"Reception of VoE read response failed: ");
493 &mbox_prot, &rec_size))) {
499 if (mbox_prot != EC_MBOX_TYPE_VOE) {
503 " as response.\n", mbox_prot);
512 " incomplete (%zu bytes)!\n", rec_size);
#define EC_FSM_RETRIES
Number of state machine retries on datagram timeout.
uint8_t * ec_slave_mbox_prepare_send(const ec_slave_t *slave, ec_datagram_t *datagram, uint8_t type, size_t size)
Prepares a mailbox-send datagram.
void ec_voe_handler_state_read_nosync_start(ec_voe_handler_t *)
Start reading VoE data without sending a sync message before.
ec_sii_t sii
Extracted SII data.
void ecrt_voe_handler_received_header(const ec_voe_handler_t *voe, uint32_t *vendor_id, uint16_t *vendor_type)
Reads the header data of a received VoE message.
uint8_t * ec_slave_mbox_fetch(const ec_slave_t *slave, const ec_datagram_t *datagram, uint8_t *type, size_t *size)
Processes received mailbox data.
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe)
Returns the current data size.
void ec_voe_handler_state_read_check(ec_voe_handler_t *)
Check for new data in the mailbox.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
Convenience macro for printing slave-specific debug messages to syslog.
ec_datagram_t datagram
State machine datagram.
size_t ec_voe_handler_mem_size(const ec_voe_handler_t *voe)
Get usable memory size.
#define EC_VOE_HEADER_SIZE
VoE header size.
int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram to fetch mailbox data.
#define EC_SLAVE_WARN(slave, fmt, args...)
Convenience macro for printing slave-specific warnings to syslog.
ec_master_t * master
Master owning the slave configuration.
uint16_t working_counter
Working counter.
#define EC_VOE_RESPONSE_TIMEOUT
VoE response timeout in [ms].
uint16_t vendor_type
Vendor type for the header.
void ecrt_voe_handler_read(ec_voe_handler_t *voe)
Start a VoE read operation.
void ecrt_voe_handler_read_nosync(ec_voe_handler_t *voe)
Start a VoE read operation without querying the sync manager status.
EtherCAT master structure.
uint32_t vendor_id
Vendor ID for the header.
ec_datagram_state_t state
State.
void(* state)(ec_voe_handler_t *)
State function.
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
ec_internal_request_state_t request_state
Handler state.
uint16_t mailbox_protocols
Supported mailbox protocols.
size_t data_size
Size of VoE data.
unsigned int debug_level
Master debug level.
#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.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
#define EC_CONFIG_DBG(sc, level, fmt, args...)
Convenience macro for printing configuration-specific debug messages to syslog.
void ec_voe_handler_state_read_response(ec_voe_handler_t *)
Read the pending mailbox data.
#define EC_READ_U32(DATA)
Read a 32-bit unsigned value from EtherCAT data.
unsigned long jiffies_start
Timestamp for timeout calculation.
Vendor specific over EtherCAT handler.
ec_master_t * master
Master owning the slave.
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe)
Execute the handler.
void ec_master_queue_datagram(ec_master_t *master, ec_datagram_t *datagram)
Places a datagram in the datagram queue.
Values read by the master.
int ec_voe_handler_init(ec_voe_handler_t *voe, ec_slave_config_t *sc, size_t size)
VoE handler constructor.
ec_slave_t * slave
Slave pointer.
void ec_voe_handler_state_write_start(ec_voe_handler_t *)
Start writing VoE data.
#define EC_MBOX_HEADER_SIZE
Mailbox header size.
void ec_voe_handler_state_write_response(ec_voe_handler_t *)
Wait for the mailbox response.
void ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size)
Start a VoE write operation.
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
int ec_datagram_prealloc(ec_datagram_t *datagram, size_t size)
Allocates internal payload memory.
void ec_voe_handler_state_read_start(ec_voe_handler_t *)
Start reading VoE data.
unsigned int retries
retries upon datagram timeout
int ec_slave_mbox_prepare_check(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram for checking the mailbox state.
#define EC_READ_U16(DATA)
Read a 16-bit unsigned value from EtherCAT data.
ec_direction_t dir
Direction.
void ec_datagram_print_state(const ec_datagram_t *datagram)
Prints the state of a datagram.
Vendor specific over EtherCAT protocol handler.
void ec_datagram_init(ec_datagram_t *datagram)
Constructor.
void ec_voe_handler_state_read_nosync_response(ec_voe_handler_t *)
Read the pending mailbox data without sending a sync message before.
uint8_t * data
Datagram payload.
void ec_voe_handler_state_error(ec_voe_handler_t *)
Failure termination state function.
EtherCAT slave configuration.
void ecrt_voe_handler_send_header(ec_voe_handler_t *voe, uint32_t vendor_id, uint16_t vendor_type)
Sets the VoE header for future send operations.
EtherCAT slave configuration structure.
size_t mem_size
Datagram data memory size.
ec_request_state_t
Request state.
ec_slave_config_t * config
Parent slave configuration.
Values written by the master.
const ec_request_state_t ec_request_state_translation_table[]
Global request state type translation table.
uint8_t * ecrt_voe_handler_data(ec_voe_handler_t *voe)
Access to the VoE handler's data.
unsigned long jiffies_received
Jiffies, when the datagram was received.
int ec_slave_mbox_check(const ec_datagram_t *datagram)
Processes a mailbox state checking datagram.
void ec_voe_handler_clear(ec_voe_handler_t *voe)
VoE handler destructor.
void ec_datagram_clear(ec_datagram_t *datagram)
Destructor.
void ec_voe_handler_state_end(ec_voe_handler_t *)
Successful termination state function.