29 #include <linux/slab.h> 30 #include <linux/delay.h> 55 return ERR_PTR(-EPROTONOSUPPORT);
61 EC_SLAVE_ERR(slave,
"Data size (%zu) does not fit in mailbox (%u)!\n",
63 return ERR_PTR(-ENOBUFS);
140 {0x00000001,
"MBXERR_SYNTAX"},
141 {0x00000002,
"MBXERR_UNSUPPORTEDPROTOCOL"},
142 {0x00000003,
"MBXERR_INVAILDCHANNEL"},
143 {0x00000004,
"MBXERR_SERVICENOTSUPPORTED"},
144 {0x00000005,
"MBXERR_INVALIDHEADER"},
145 {0x00000006,
"MBXERR_SIZETOOSHORT"},
146 {0x00000007,
"MBXERR_NOMOREMEMORY"},
147 {0x00000008,
"MBXERR_INVALIDSIZE"},
168 EC_SLAVE_ERR(slave,
"Corrupt mailbox response received!\n");
170 return ERR_PTR(-EPROTO);
180 EC_SLAVE_ERR(slave,
"Mailbox error response received - ");
183 if (mbox_msg->
code != code)
185 printk(KERN_CONT
"Code 0x%04X: \"%s\".\n",
190 if (!mbox_msg->
code) {
191 printk(KERN_CONT
"Unknown error reply code 0x%04X.\n", code);
197 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.