46 #define EC_FSM_COE_DICT_TIMEOUT 1000 50 #define EC_COE_DOWN_REQ_HEADER_SIZE 10 54 #define EC_COE_DOWN_SEG_REQ_HEADER_SIZE 3 58 #define EC_COE_DOWN_SEG_MIN_DATA_SIZE 7 62 #define DEBUG_RETRIES 0 108 {0x05030000,
"Toggle bit not changed"},
109 {0x05040000,
"SDO protocol timeout"},
110 {0x05040001,
"Client/Server command specifier not valid or unknown"},
111 {0x05040005,
"Out of memory"},
112 {0x06010000,
"Unsupported access to an object"},
113 {0x06010001,
"Attempt to read a write-only object"},
114 {0x06010002,
"Attempt to write a read-only object"},
115 {0x06020000,
"This object does not exist in the object directory"},
116 {0x06040041,
"The object cannot be mapped into the PDO"},
117 {0x06040042,
"The number and length of the objects to be mapped would" 118 " exceed the PDO length"},
119 {0x06040043,
"General parameter incompatibility reason"},
120 {0x06040047,
"Gerneral internal incompatibility in device"},
121 {0x06060000,
"Access failure due to a hardware error"},
122 {0x06070010,
"Data type does not match, length of service parameter does" 124 {0x06070012,
"Data type does not match, length of service parameter too" 126 {0x06070013,
"Data type does not match, length of service parameter too" 128 {0x06090011,
"Subindex does not exist"},
129 {0x06090030,
"Value range of parameter exceeded"},
130 {0x06090031,
"Value of parameter written too high"},
131 {0x06090032,
"Value of parameter written too low"},
132 {0x06090036,
"Maximum value is less than minimum value"},
133 {0x08000000,
"General error"},
134 {0x08000020,
"Data cannot be transferred or stored to the application"},
135 {0x08000021,
"Data cannot be transferred or stored to the application" 136 " because of local control"},
137 {0x08000022,
"Data cannot be transferred or stored to the application" 138 " because of the present device state"},
139 {0x08000023,
"Object dictionary dynamic generation fails or no object" 140 " dictionary is present"},
156 if (abort_msg->
code == abort_code) {
157 EC_SLAVE_ERR(slave,
"SDO abort message 0x%08X: \"%s\".\n",
163 EC_SLAVE_ERR(slave,
"Unknown SDO abort code 0x%08X.\n", abort_code);
233 int datagram_used = 0;
240 return datagram_used;
243 fsm->
state(fsm, datagram);
254 return datagram_used;
283 if (size < 2 || ((
EC_READ_U16(data) >> 12) & 0x0F) != 0x01)
301 "Error code 0x%04X, Error register 0x%02X, data:\n",
322 EC_MBOX_TYPE_COE, 8);
324 return PTR_ERR(data);
356 " SDO information service!\n");
390 " request datagram: ");
397 EC_SLAVE_ERR(slave,
"Reception of CoE dictionary request failed: ");
427 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
435 " datagram failed: ");
441 unsigned long diff_ms =
447 " SDO dictionary list response.\n");
477 return PTR_ERR(data);
503 uint8_t *data, mbox_prot;
505 unsigned int sdo_count, i;
506 uint16_t sdo_index, fragments_left;
509 size_t index_list_offset;
519 " response datagram: ");
526 EC_SLAVE_ERR(slave,
"Reception of CoE dictionary response failed: ");
537 if (mbox_prot != EC_MBOX_TYPE_COE) {
538 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
553 EC_SLAVE_ERR(slave,
"Received corrupted SDO dictionary response" 554 " (size %zu).\n", rec_size);
561 EC_SLAVE_ERR(slave,
"SDO information error response!\n");
564 " error response:\n");
586 first_segment = list_empty(&slave->
sdo_dictionary) ? true :
false;
587 index_list_offset = first_segment ? 8 : 6;
589 if (rec_size < index_list_offset || rec_size % 2) {
590 EC_SLAVE_ERR(slave,
"Invalid data size %zu!\n", rec_size);
596 sdo_count = (rec_size - index_list_offset) / 2;
598 for (i = 0; i < sdo_count; i++) {
599 sdo_index =
EC_READ_U16(data + index_list_offset + i * 2);
601 EC_SLAVE_DBG(slave, 1,
"SDO dictionary contains index 0x0000.\n");
606 EC_SLAVE_ERR(slave,
"Failed to allocate memory for SDO!\n");
616 if (fragments_left) {
621 if (
EC_READ_U8(data + 2) & 0x80 || fragments_left) {
669 " description request datagram: ");
677 " request failed: ");
709 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
717 " datagram failed: ");
723 unsigned long diff_ms =
729 " SDO 0x%04x object description response.\n",
760 return PTR_ERR(data);
789 uint8_t *data, mbox_prot;
790 size_t rec_size, name_size;
799 EC_SLAVE_ERR(slave,
"Failed to receive CoE SDO description" 800 " response datagram: ");
808 " response failed: ");
819 if (mbox_prot != EC_MBOX_TYPE_COE) {
820 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
835 EC_SLAVE_ERR(slave,
"Received corrupted SDO description response" 836 " (size %zu).\n", rec_size);
843 EC_SLAVE_ERR(slave,
"SDO information error response while" 844 " fetching SDO 0x%04X!\n", sdo->
index);
852 " description response (size %zu).\n", rec_size);
861 EC_SLAVE_DBG(slave, 1,
"Invalid object description response while" 862 " fetching SDO 0x%04X!\n", sdo->
index);
882 name_size = rec_size - 12;
884 if (!(sdo->
name = kmalloc(name_size + 1, GFP_KERNEL))) {
890 memcpy(sdo->
name, data + 12, name_size);
891 sdo->
name[name_size] = 0;
895 EC_SLAVE_ERR(slave,
"Fragment follows (not implemented)!\n");
934 " request datagram: ");
941 EC_SLAVE_ERR(slave,
"Reception of CoE SDO entry request failed: ");
973 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
981 " datagram failed: ");
987 unsigned long diff_ms =
993 " SDO entry 0x%04x:%x description response.\n",
1023 uint8_t *data, mbox_prot;
1024 size_t rec_size, data_size;
1036 " description response datagram: ");
1044 " response failed: ");
1055 if (mbox_prot != EC_MBOX_TYPE_COE) {
1057 " 0x%02X as response.\n", mbox_prot);
1072 " description response (size %zu).\n", rec_size);
1080 " fetching SDO entry 0x%04X:%02X!\n",
1091 " description response (size %zu).\n", rec_size);
1101 EC_SLAVE_DBG(slave, 1,
"Invalid entry description response" 1102 " while fetching SDO entry 0x%04X:%02X!\n",
1113 if (rec_size < 16) {
1114 EC_SLAVE_ERR(slave,
"Invalid data size %zu!\n", rec_size);
1120 data_size = rec_size - 16;
1137 (word >> 1) & 0x0001;
1141 (word >> 4) & 0x0001;
1146 if (!(desc = kmalloc(data_size + 1, GFP_KERNEL))) {
1147 EC_SLAVE_ERR(slave,
"Failed to allocate SDO entry name!\n");
1151 memcpy(desc, data + 16, data_size);
1152 desc[data_size] = 0;
1203 uint8_t data_set_size;
1210 request->
errno = PTR_ERR(data);
1211 return PTR_ERR(data);
1220 | data_set_size << 2
1230 EC_SLAVE_DBG(slave, 1,
"Expedited download request:\n");
1238 required_data_size =
1241 if (max_data_size < required_data_size) {
1243 data_size = max_data_size;
1245 data_size = required_data_size;
1251 request->
errno = PTR_ERR(data);
1252 return PTR_ERR(data);
1271 request->
data, segment_size);
1272 fsm->
offset += segment_size;
1301 subidxstr[0] = 0x00;
1303 sprintf(subidxstr,
":%02X", request->
subindex);
1306 request->
index, subidxstr);
1312 request->
errno = EPROTONOSUPPORT;
1320 request->
errno = EOVERFLOW;
1347 unsigned long diff_ms;
1360 " request datagram: ");
1369 if (diff_ms < fsm->request->response_timeout) {
1372 " download request. Retrying after %lu ms...\n",
1384 EC_SLAVE_ERR(slave,
"Reception of CoE download request" 1385 " for SDO 0x%04x:%x failed with timeout after %lu ms: ",
1392 if (diff_ms > 200) {
1393 EC_SLAVE_WARN(slave,
"SDO 0x%04x:%x download took %lu ms.\n",
1424 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check" 1434 " datagram failed: ");
1440 unsigned long diff_ms =
1446 EC_SLAVE_ERR(slave,
"Timeout after %lu ms while waiting" 1447 " for SDO 0x%04x:%x download response.\n", diff_ms,
1474 size_t max_segment_size =
1479 uint8_t last_segment, seg_data_size, *data;
1481 if (fsm->
remaining > max_segment_size) {
1490 seg_data_size = 0x00;
1501 request->
errno = PTR_ERR(data);
1508 | (seg_data_size << 1)
1539 uint8_t *data, mbox_prot;
1549 request->
errno = EIO;
1552 " response datagram: ");
1558 request->
errno = EIO;
1560 EC_SLAVE_ERR(slave,
"Reception of CoE download response failed: ");
1567 request->
errno = PTR_ERR(data);
1572 if (mbox_prot != EC_MBOX_TYPE_COE) {
1573 request->
errno = EIO;
1575 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
1594 request->
errno = EIO;
1596 EC_SLAVE_ERR(slave,
"Received data are too small (%zu bytes):\n",
1605 request->
errno = EIO;
1608 subidxstr[0] = 0x00;
1610 sprintf(subidxstr,
":%02X", request->
subindex);
1612 EC_SLAVE_ERR(slave,
"SDO download 0x%04X%s (%zu bytes) aborted.\n",
1614 if (rec_size < 10) {
1629 EC_SLAVE_DBG(slave, 1,
"Invalid SDO download response!" 1667 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
1675 EC_SLAVE_ERR(slave,
"Reception of CoE mailbox segment check" 1676 " datagram failed: ");
1682 unsigned long diff_ms =
1688 EC_SLAVE_ERR(slave,
"Timeout while waiting for SDO download" 1689 " segment response.\n");
1717 uint8_t *data, mbox_prot;
1727 request->
errno = EIO;
1729 EC_SLAVE_ERR(slave,
"Failed to receive CoE download response" 1736 request->
errno = EIO;
1738 EC_SLAVE_ERR(slave,
"Reception of CoE download response failed: ");
1745 request->
errno = PTR_ERR(data);
1750 if (mbox_prot != EC_MBOX_TYPE_COE) {
1751 request->
errno = EIO;
1753 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
1772 request->
errno = EIO;
1774 EC_SLAVE_ERR(slave,
"Received data are too small (%zu bytes):\n",
1783 request->
errno = EIO;
1786 subidxstr[0] = 0x00;
1788 sprintf(subidxstr,
":%02X", request->
subindex);
1790 EC_SLAVE_ERR(slave,
"SDO download 0x%04X%s (%zu bytes) aborted.\n",
1792 if (rec_size < 10) {
1805 EC_SLAVE_DBG(slave, 1,
"Invalid SDO download response!" 1818 " segmented download:\n");
1820 request->
errno = EIO;
1854 request->
errno = PTR_ERR(data);
1855 return PTR_ERR(data);
1862 memset(data + 6, 0x00, 4);
1892 request->
errno = EPROTONOSUPPORT;
1917 unsigned long diff_ms;
1929 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload request: ");
1938 if (diff_ms < fsm->request->response_timeout) {
1941 " SDO upload request. Retrying after %lu ms...\n",
1953 EC_SLAVE_ERR(slave,
"Reception of CoE upload request for" 1954 " SDO 0x%04x:%x failed with timeout after %lu ms: ",
1961 if (diff_ms > 200) {
1995 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
2004 " datagram failed: ");
2010 unsigned long diff_ms =
2016 EC_SLAVE_ERR(slave,
"Timeout after %lu ms while waiting for" 2017 " SDO 0x%04x:%x upload response.\n", diff_ms,
2054 memset(data + 3, 0x00, 7);
2077 uint8_t *data, mbox_prot, rec_subindex;
2078 size_t rec_size, data_size;
2080 unsigned int expedited, size_specified;
2089 request->
errno = EIO;
2091 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload response" 2098 request->
errno = EIO;
2100 EC_SLAVE_ERR(slave,
"Reception of CoE upload response failed: ");
2107 request->
errno = PTR_ERR(data);
2117 if (mbox_prot != EC_MBOX_TYPE_COE) {
2118 request->
errno = EIO;
2121 " as response.\n", mbox_prot);
2134 request->
errno = EIO;
2136 EC_SLAVE_ERR(slave,
"Received currupted SDO upload response" 2137 " (%zu bytes)!\n", rec_size);
2144 EC_SLAVE_ERR(slave,
"SDO upload 0x%04X:%02X aborted.\n",
2146 if (rec_size >= 10) {
2152 request->
errno = EIO;
2160 " uploading SDO 0x%04X:%02X.\n",
2163 request->
errno = EIO;
2171 if (rec_index != request->
index || rec_subindex != request->
subindex) {
2172 EC_SLAVE_ERR(slave,
"Received upload response for wrong SDO" 2173 " (0x%04X:%02X, requested: 0x%04X:%02X).\n",
2174 rec_index, rec_subindex, request->
index, request->
subindex);
2188 size_specified =
EC_READ_U8(data + 2) & 0x01;
2189 if (size_specified) {
2195 if (rec_size < 6 + fsm->complete_size) {
2196 request->
errno = EIO;
2198 EC_SLAVE_ERR(slave,
"Received corrupted SDO expedited upload" 2199 " response (only %zu bytes)!\n", rec_size);
2206 request->
errno = -ret;
2211 if (rec_size < 10) {
2212 request->
errno = EIO;
2214 EC_SLAVE_ERR(slave,
"Received currupted SDO normal upload" 2215 " response (only %zu bytes)!\n", rec_size);
2220 data_size = rec_size - 10;
2225 request->
errno = -ret;
2232 request->
errno = -ret;
2239 if (data_size < fsm->complete_size) {
2240 EC_SLAVE_DBG(slave, 1,
"SDO data incomplete (%zu / %u)." 2279 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload segment" 2280 " request datagram: ");
2289 " request failed: ");
2322 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check" 2331 EC_SLAVE_ERR(slave,
"Reception of CoE mailbox check datagram" 2338 unsigned long diff_ms =
2344 EC_SLAVE_ERR(slave,
"Timeout while waiting for SDO upload" 2345 " segment response.\n");
2374 uint8_t *data, mbox_prot;
2375 size_t rec_size, data_size;
2377 unsigned int last_segment;
2385 request->
errno = EIO;
2387 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload segment" 2388 " response datagram: ");
2394 request->
errno = EIO;
2397 " response failed: ");
2404 request->
errno = PTR_ERR(data);
2414 if (mbox_prot != EC_MBOX_TYPE_COE) {
2415 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
2417 request->
errno = EIO;
2430 if (rec_size < 10) {
2432 " segment response!\n");
2434 request->
errno = EIO;
2441 EC_SLAVE_ERR(slave,
"SDO upload 0x%04X:%02X aborted.\n",
2445 request->
errno = EIO;
2453 EC_SLAVE_DBG(slave, 1,
"Invalid SDO upload segment response!\n");
2463 data_size = rec_size - 3;
2465 if (rec_size == 10) {
2466 uint8_t seg_size = (
EC_READ_U8(data + 2) & 0xE) >> 1;
2467 data_size -= seg_size;
2471 EC_SLAVE_ERR(slave,
"SDO upload 0x%04X:%02X failed: Fragment" 2472 " exceeding complete size!\n",
2474 request->
errno = EOVERFLOW;
2479 memcpy(request->
data + request->
data_size, data + 3, data_size);
2483 if (!last_segment) {
2492 EC_SLAVE_WARN(slave,
"SDO upload 0x%04X:%02X: Assembled data" 2493 " size (%zu) does not match complete size (%u)!\n",
int ec_fsm_coe_prepare_down_start(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare a donwnload request.
#define EC_FSM_RETRIES
Number of state machine retries on datagram timeout.
void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP RESPONSE.
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.
unsigned long jiffies_sent
Jiffies, when the datagram was sent.
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 ec_fsm_coe_prepare_up(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare an upload request.
void ec_fsm_coe_up_start(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP START.
uint32_t offset
Data offset during segmented download.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
Convenience macro for printing slave-specific debug messages to syslog.
void ec_fsm_coe_end(ec_fsm_coe_t *, ec_datagram_t *)
State: END.
size_t segment_size
Current segment size.
void ec_fsm_coe_dict_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT RESPONSE.
void ec_fsm_coe_error(ec_fsm_coe_t *, ec_datagram_t *)
State: ERROR.
void ec_fsm_coe_dict_entry_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT ENTRY CHECK.
uint16_t bit_length
Data size in bit.
uint32_t response_timeout
Maximum time in ms, the transfer is retried, if the slave does not respond.
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.
void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT ENTRY RESPONSE.
ec_sii_coe_details_t coe_details
CoE detail flags.
void ec_fsm_coe_down_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DOWN CHECK.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
uint32_t abort_code
SDO request abort code.
void(* state)(ec_fsm_coe_t *, ec_datagram_t *)
CoE state function.
void ec_fsm_coe_down_prepare_segment_request(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare a download segment request.
void ec_fsm_coe_up_seg_request(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP REQUEST.
uint16_t working_counter
Working counter.
struct list_head list
List item.
void ec_fsm_coe_down_seg_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DOWN SEG CHECK.
#define EC_COE_DOWN_SEG_MIN_DATA_SIZE
Minimum size of download segment.
void ec_fsm_coe_up_seg_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP CHECK.
uint8_t * data
Pointer to SDO data.
int ec_fsm_coe_success(const ec_fsm_coe_t *fsm)
Returns, if the state machine terminated with success.
#define EC_FSM_COE_DICT_TIMEOUT
Maximum time in ms to wait for responses when reading out the dictionary.
Sent (still in the queue).
#define EC_COE_DOWN_SEG_REQ_HEADER_SIZE
CoE download segment request header size.
int ec_fsm_coe_check_emergency(ec_fsm_coe_t *fsm, const uint8_t *data, size_t size)
Check if the received data are a CoE emergency request.
struct list_head list
List item.
void ec_fsm_coe_dict_entry_request(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT ENTRY REQUEST.
const char * message
Message belonging to code.
struct list_head sdo_dictionary
SDO dictionary list.
Global definitions and macros.
void ec_fsm_coe_up_request(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP REQUEST.
ec_direction_t dir
Direction.
EtherCAT master structure.
uint8_t object_code
Object code.
ec_sdo_t * sdo
current SDO
Initial state of a new datagram.
EtherCAT CoE state machines.
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.
char * description
Description.
ec_datagram_state_t state
State.
void ec_fsm_coe_dict_desc_request(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT DESC REQUEST.
ec_slave_config_t * config
Current configuration.
#define EC_WRITE_U32(DATA, VAL)
Write a 32-bit unsigned value to EtherCAT data.
void ec_fsm_coe_up_prepare_segment_request(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare an SDO upload segment request.
uint8_t enable_sdo_info
SDO information service available.
uint16_t mailbox_protocols
Supported mailbox protocols.
ec_sdo_request_t * request
SDO request.
int ec_fsm_coe_dict_prepare_desc(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare an object description request.
unsigned int debug_level
Master debug level.
void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT DESC RESPONSE.
#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.
void ec_fsm_coe_up_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP RESPONSE.
unsigned long jiffies_sent
Jiffies, when the upload/download request was sent.
uint8_t subindex
current subindex
void ec_fsm_coe_clear(ec_fsm_coe_t *fsm)
Destructor.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
ec_datagram_t * datagram
Datagram used in last step.
uint32_t remaining
Remaining bytes during segmented download.
#define EC_READ_U32(DATA)
Read a 32-bit unsigned value from EtherCAT data.
uint32_t complete_size
Used when segmenting.
int ec_fsm_coe_dict_prepare_entry(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare an entry description request.
ec_master_t * master
Master owning the slave.
unsigned long jiffies_start
CoE timestamp.
void ec_fsm_coe_dict_desc_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT DESC CHECK.
void ec_fsm_coe_dictionary(ec_fsm_coe_t *fsm, ec_slave_t *slave)
Starts reading a slaves' SDO dictionary.
void ec_fsm_coe_dict_start(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT START.
void ec_fsm_coe_down_request(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DOWN REQUEST.
void ec_canopen_abort_msg(const ec_slave_t *slave, uint32_t abort_code)
Outputs an SDO abort message.
uint16_t data_type
Data type.
void ec_fsm_coe_dict_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT CHECK.
#define EC_MBOX_HEADER_SIZE
Mailbox header size.
void ec_sdo_init(ec_sdo_t *sdo, ec_slave_t *slave, uint16_t index)
Constructor.
int ec_fsm_coe_prepare_dict(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Prepare a dictionary request.
void ec_fsm_coe_init(ec_fsm_coe_t *fsm)
Constructor.
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
uint8_t read_access[EC_SDO_ENTRY_ACCESS_COUNT]
Read access.
uint8_t subindex
SDO subindex.
struct list_head entries
List of entries.
size_t data_size
Size of SDO data.
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_coe_emerg_ring_t emerg_ring
CoE emergency ring buffer.
void ec_datagram_print_state(const ec_datagram_t *datagram)
Prints the state of a datagram.
void ec_coe_emerg_ring_push(ec_coe_emerg_ring_t *ring, const u8 *msg)
Add a new emergency message.
int ec_fsm_coe_exec(ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
Executes the current state of the state machine.
void ec_fsm_coe_dict_request(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DICT REQUEST.
void ec_fsm_coe_down_start(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DOWN START.
uint8_t max_subindex
Maximum subindex.
void ec_fsm_coe_down_seg_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DOWN SEG RESPONSE.
uint16_t configured_rx_mailbox_size
Configured receive mailbox size.
uint8_t toggle
toggle bit for segment commands
void ec_sdo_entry_init(ec_sdo_entry_t *entry, ec_sdo_t *sdo, uint8_t subindex)
Constructor.
#define EC_READ_U8(DATA)
Read an 8-bit unsigned value from EtherCAT data.
EtherCAT slave configuration.
void ec_fsm_coe_down_response(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: DOWN RESPONSE.
#define EC_COE_DOWN_REQ_HEADER_SIZE
CoE download request header size.
unsigned int retries
retries upon datagram timeout
EtherCAT slave configuration structure.
uint8_t write_access[EC_SDO_ENTRY_ACCESS_COUNT]
Write access.
void ec_fsm_coe_transfer(ec_fsm_coe_t *fsm, ec_slave_t *slave, ec_sdo_request_t *request)
Starts to transfer an SDO to/from a slave.
int ec_sdo_request_alloc(ec_sdo_request_t *req, size_t size)
Pre-allocates the data memory.
Values written by the master.
unsigned long jiffies_received
Jiffies, when the datagram was received.
ec_slave_t * slave
slave the FSM runs on
int ec_slave_mbox_check(const ec_datagram_t *datagram)
Processes a mailbox state checking datagram.
const ec_code_msg_t sdo_abort_messages[]
SDO abort messages.
uint8_t complete_access
SDO shall be transferred completely.
void ec_fsm_coe_up_check(ec_fsm_coe_t *, ec_datagram_t *)
CoE state: UP CHECK.
unsigned int has_general
General category present.
Finite state machines for the CANopen over EtherCAT protocol.