28 #include <linux/module.h> 37 #define EC_VOE_HEADER_SIZE 6 41 #define EC_VOE_RESPONSE_TIMEOUT 500 116 uint16_t vendor_type)
126 uint32_t *vendor_id, uint16_t *vendor_type)
211 EC_SLAVE_DBG(slave, 0,
"Writing %zu bytes of VoE data.\n",
255 EC_SLAVE_ERR(slave,
"Failed to receive VoE write request datagram: ");
262 unsigned long diff_ms =
266 " VoE write request. Retrying after %lu ms...\n",
274 EC_SLAVE_ERR(slave,
"Reception of VoE write request failed: ");
325 EC_SLAVE_ERR(slave,
"Failed to receive VoE mailbox check datagram: ");
334 " datagram failed: ");
340 unsigned long diff_ms =
345 EC_SLAVE_ERR(slave,
"Timeout while waiting for VoE data.\n");
369 uint8_t *data, mbox_prot;
378 EC_SLAVE_ERR(slave,
"Failed to receive VoE read datagram: ");
386 EC_SLAVE_ERR(slave,
"Reception of VoE read response failed: ");
398 if (mbox_prot != EC_MBOX_TYPE_VOE) {
402 " as response.\n", mbox_prot);
411 " incomplete (%zu bytes)!\n", rec_size);
460 uint8_t *data, mbox_prot;
469 EC_SLAVE_ERR(slave,
"Failed to receive VoE read datagram: ");
477 EC_SLAVE_DBG(slave, 1,
"Slave did not send VoE data.\n");
484 EC_SLAVE_WARN(slave,
"Reception of VoE read response failed: ");
490 &mbox_prot, &rec_size))) {
496 if (mbox_prot != EC_MBOX_TYPE_VOE) {
500 " as response.\n", mbox_prot);
509 " 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.
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.
int ecrt_voe_handler_read(ec_voe_handler_t *voe)
Start a VoE read operation.
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.
int ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size)
Start a VoE write operation.
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.
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.
int 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.
#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.
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 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.
uint8_t * ecrt_voe_handler_data(const ec_voe_handler_t *voe)
Access to the VoE handler's data.
void ec_datagram_init(ec_datagram_t *datagram)
Constructor.
int 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.
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.
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe)
Returns the current data size.
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe)
Execute the handler.
void ec_voe_handler_state_error(ec_voe_handler_t *)
Failure termination state function.
EtherCAT slave configuration.
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.
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.
int ecrt_voe_handler_read_nosync(ec_voe_handler_t *voe)
Start a VoE read operation without querying the sync manager status.
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.