37 #include <linux/slab.h> 38 #include <linux/delay.h> 63 return ERR_PTR(-EPROTONOSUPPORT);
69 EC_SLAVE_ERR(slave,
"Data size (%zu) does not fit in mailbox (%u)!\n",
71 return ERR_PTR(-EOVERFLOW);
148 {0x00000001,
"MBXERR_SYNTAX"},
149 {0x00000002,
"MBXERR_UNSUPPORTEDPROTOCOL"},
150 {0x00000003,
"MBXERR_INVAILDCHANNEL"},
151 {0x00000004,
"MBXERR_SERVICENOTSUPPORTED"},
152 {0x00000005,
"MBXERR_INVALIDHEADER"},
153 {0x00000006,
"MBXERR_SIZETOOSHORT"},
154 {0x00000007,
"MBXERR_NOMOREMEMORY"},
155 {0x00000008,
"MBXERR_INVALIDSIZE"},
176 EC_SLAVE_ERR(slave,
"Corrupt mailbox response received!\n");
178 return ERR_PTR(-EPROTO);
188 EC_SLAVE_ERR(slave,
"Mailbox error response received - ");
191 if (mbox_msg->
code != code)
193 printk(KERN_CONT
"Code 0x%04X: \"%s\".\n",
198 if (!mbox_msg->
code) {
199 printk(KERN_CONT
"Unknown error reply code 0x%04X.\n", code);
205 return ERR_PTR(-EPROTO);
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.
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.
uint16_t configured_tx_mailbox_size
Configured send mailbox size.
uint16_t configured_tx_mailbox_offset
Configured send mailbox offset.
int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, ec_datagram_t *datagram)
Prepares a datagram to fetch mailbox data.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
uint16_t station_address
Configured station address.
const char * message
Message belonging to code.
EtherCAT master structure.
void ec_datagram_zero(ec_datagram_t *datagram)
Fills the datagram payload memory with zeros.
uint16_t mailbox_protocols
Supported mailbox protocols.
unsigned int debug_level
Master debug level.
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
uint16_t configured_rx_mailbox_offset
Configured receive mailbox offset.
ec_master_t * master
Master owning the slave.
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.
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.
EtherCAT datagram structure.
const ec_code_msg_t mbox_error_messages[]
Mailbox error codes.
#define EC_MBOX_HEADER_SIZE
Mailbox header size.
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
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.
uint16_t configured_rx_mailbox_size
Configured receive mailbox size.
uint8_t * data
Datagram payload.
#define EC_READ_U8(DATA)
Read an 8-bit unsigned value from EtherCAT data.
int ec_slave_mbox_check(const ec_datagram_t *datagram)
Processes a mailbox state checking datagram.