28 #include <linux/module.h> 29 #include <linux/jiffies.h> 30 #include <linux/slab.h> 38 #define EC_SDO_REQUEST_RESPONSE_TIMEOUT 1000 59 req->
state = EC_INT_REQUEST_INIT;
126 if (size <= req->mem_size)
131 if (!(req->
data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
132 EC_ERR(
"Failed to allocate %zu bytes of SDO memory.\n", size);
152 const uint8_t *source,
160 memcpy(req->
data, source, size);
223 req->
state = EC_INT_REQUEST_QUEUED;
235 req->
state = EC_INT_REQUEST_QUEUED;
ec_request_state_t ecrt_sdo_request_state(const ec_sdo_request_t *req)
Get the current state of the SDO request.
int ecrt_sdo_request_write(ec_sdo_request_t *req)
Schedule an SDO write operation.
int ecrt_sdo_request_timeout(ec_sdo_request_t *req, uint32_t timeout)
Set the timeout for an SDO request.
uint8_t * ecrt_sdo_request_data(const ec_sdo_request_t *req)
Access to the SDO request's data.
ec_internal_request_state_t state
SDO request state.
uint32_t response_timeout
Maximum time in ms, the transfer is retried, if the slave does not respond.
size_t mem_size
Size of SDO data memory.
int ecrt_sdo_request_read(ec_sdo_request_t *req)
Schedule an SDO read operation.
uint32_t abort_code
SDO request abort code.
void ec_sdo_request_clear_data(ec_sdo_request_t *)
SDO request destructor.
int ec_sdo_request_timed_out(const ec_sdo_request_t *req)
Checks, if the timeout was exceeded.
uint8_t * data
Pointer to SDO data.
ec_direction_t dir
Direction.
void ec_sdo_request_clear(ec_sdo_request_t *req)
SDO request destructor.
int ecrt_sdo_request_index(ec_sdo_request_t *req, uint16_t index, uint8_t subindex)
Set the SDO index and subindex.
int ec_sdo_request_copy_data(ec_sdo_request_t *req, const uint8_t *source, size_t size)
Copies SDO data from an external source.
EtherCAT CANopen SDO request structure.
unsigned long jiffies_sent
Jiffies, when the upload/download request was sent.
size_t ecrt_sdo_request_data_size(const ec_sdo_request_t *req)
Returns the current SDO data size.
int ec_sdo_request_copy(ec_sdo_request_t *req, const ec_sdo_request_t *other)
Copy another SDO request.
#define EC_SDO_REQUEST_RESPONSE_TIMEOUT
Default timeout in ms to wait for SDO transfer responses.
Values read by the master.
uint8_t subindex
SDO subindex.
size_t data_size
Size of SDO data.
void ec_sdo_request_init(ec_sdo_request_t *req)
SDO request constructor.
#define EC_ERR(fmt, args...)
Convenience macro for printing EtherCAT-specific errors to syslog.
ec_request_state_t
Request state.
int ec_sdo_request_alloc(ec_sdo_request_t *req, size_t size)
Pre-allocates the data memory.
Values written by the master.
const ec_request_state_t ec_request_state_translation_table[]
Global request state type translation table.
uint32_t issue_timeout
Maximum time in ms, the processing of the request may take.
unsigned long jiffies_start
Jiffies, when the request was issued.
uint8_t complete_access
SDO shall be transferred completely.