38 #define EC_FSM_COE_DICT_TIMEOUT 1000 42 #define EC_COE_DOWN_REQ_HEADER_SIZE 10 46 #define EC_COE_DOWN_SEG_REQ_HEADER_SIZE 3 50 #define EC_COE_DOWN_SEG_MIN_DATA_SIZE 7 54 #define DEBUG_RETRIES 0 113 {0x05030000,
"Toggle bit not changed"},
114 {0x05040000,
"SDO protocol timeout"},
115 {0x05040001,
"Client/Server command specifier not valid or unknown"},
116 {0x05040005,
"Out of memory"},
117 {0x06010000,
"Unsupported access to an object"},
118 {0x06010001,
"Attempt to read a write-only object"},
119 {0x06010002,
"Attempt to write a read-only object"},
120 {0x06020000,
"This object does not exist in the object directory"},
121 {0x06040041,
"The object cannot be mapped into the PDO"},
122 {0x06040042,
"The number and length of the objects to be mapped would" 123 " exceed the PDO length"},
124 {0x06040043,
"General parameter incompatibility reason"},
125 {0x06040047,
"Gerneral internal incompatibility in device"},
126 {0x06060000,
"Access failure due to a hardware error"},
127 {0x06070010,
"Data type does not match, length of service parameter does" 129 {0x06070012,
"Data type does not match, length of service parameter too" 131 {0x06070013,
"Data type does not match, length of service parameter too" 133 {0x06090011,
"Subindex does not exist"},
134 {0x06090030,
"Value range of parameter exceeded"},
135 {0x06090031,
"Value of parameter written too high"},
136 {0x06090032,
"Value of parameter written too low"},
137 {0x06090036,
"Maximum value is less than minimum value"},
138 {0x08000000,
"General error"},
139 {0x08000020,
"Data cannot be transferred or stored to the application"},
140 {0x08000021,
"Data cannot be transferred or stored to the application" 141 " because of local control"},
142 {0x08000022,
"Data cannot be transferred or stored to the application" 143 " because of the present device state"},
144 {0x08000023,
"Object dictionary dynamic generation fails or no object" 145 " dictionary is present"},
161 if (abort_msg->
code == abort_code) {
162 EC_SLAVE_ERR(slave,
"SDO abort message 0x%08X: \"%s\".\n",
168 EC_SLAVE_ERR(slave,
"Unknown SDO abort code 0x%08X.\n", abort_code);
238 int datagram_used = 0;
245 return datagram_used;
248 fsm->
state(fsm, datagram);
259 return datagram_used;
288 if (size < 2 || ((
EC_READ_U16(data) >> 12) & 0x0F) != 0x01)
306 "Error code 0x%04X, Error register 0x%02X, data:\n",
327 EC_MBOX_TYPE_COE, 8);
329 return PTR_ERR(data);
361 " SDO information service!\n");
395 " request datagram: ");
402 EC_SLAVE_ERR(slave,
"Reception of CoE dictionary request failed: ");
432 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
440 " datagram failed: ");
446 unsigned long diff_ms =
452 " SDO dictionary list response.\n");
482 return PTR_ERR(data);
508 uint8_t *data, mbox_prot;
510 unsigned int sdo_count, i;
511 uint16_t sdo_index, fragments_left;
514 size_t index_list_offset;
524 " response datagram: ");
531 EC_SLAVE_ERR(slave,
"Reception of CoE dictionary response failed: ");
542 if (mbox_prot != EC_MBOX_TYPE_COE) {
543 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
558 EC_SLAVE_ERR(slave,
"Received corrupted SDO dictionary response" 559 " (size %zu).\n", rec_size);
566 EC_SLAVE_ERR(slave,
"SDO information error response!\n");
569 " error response:\n");
591 first_segment = list_empty(&slave->
sdo_dictionary) ? true :
false;
592 index_list_offset = first_segment ? 8 : 6;
594 if (rec_size < index_list_offset || rec_size % 2) {
595 EC_SLAVE_ERR(slave,
"Invalid data size %zu!\n", rec_size);
601 sdo_count = (rec_size - index_list_offset) / 2;
603 for (i = 0; i < sdo_count; i++) {
604 sdo_index =
EC_READ_U16(data + index_list_offset + i * 2);
606 EC_SLAVE_DBG(slave, 1,
"SDO dictionary contains index 0x0000.\n");
611 EC_SLAVE_ERR(slave,
"Failed to allocate memory for SDO!\n");
621 if (fragments_left) {
626 if (
EC_READ_U8(data + 2) & 0x80 || fragments_left) {
674 " description request datagram: ");
682 " request failed: ");
714 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
722 " datagram failed: ");
728 unsigned long diff_ms =
734 " SDO 0x%04x object description response.\n",
765 return PTR_ERR(data);
794 uint8_t *data, mbox_prot;
795 size_t rec_size, name_size;
804 EC_SLAVE_ERR(slave,
"Failed to receive CoE SDO description" 805 " response datagram: ");
813 " response failed: ");
824 if (mbox_prot != EC_MBOX_TYPE_COE) {
825 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
840 EC_SLAVE_ERR(slave,
"Received corrupted SDO description response" 841 " (size %zu).\n", rec_size);
848 EC_SLAVE_ERR(slave,
"SDO information error response while" 849 " fetching SDO 0x%04X!\n", sdo->
index);
857 " description response (size %zu).\n", rec_size);
866 EC_SLAVE_DBG(slave, 1,
"Invalid object description response while" 867 " fetching SDO 0x%04X!\n", sdo->
index);
887 name_size = rec_size - 12;
889 if (!(sdo->
name = kmalloc(name_size + 1, GFP_KERNEL))) {
895 memcpy(sdo->
name, data + 12, name_size);
896 sdo->
name[name_size] = 0;
900 EC_SLAVE_ERR(slave,
"Fragment follows (not implemented)!\n");
939 " request datagram: ");
946 EC_SLAVE_ERR(slave,
"Reception of CoE SDO entry request failed: ");
978 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
986 " datagram failed: ");
992 unsigned long diff_ms =
998 " SDO entry 0x%04x:%x description response.\n",
1028 uint8_t *data, mbox_prot;
1029 size_t rec_size, data_size;
1041 " description response datagram: ");
1049 " response failed: ");
1060 if (mbox_prot != EC_MBOX_TYPE_COE) {
1062 " 0x%02X as response.\n", mbox_prot);
1077 " description response (size %zu).\n", rec_size);
1085 " fetching SDO entry 0x%04X:%02X!\n",
1096 " description response (size %zu).\n", rec_size);
1106 EC_SLAVE_DBG(slave, 1,
"Invalid entry description response" 1107 " while fetching SDO entry 0x%04X:%02X!\n",
1118 if (rec_size < 16) {
1119 EC_SLAVE_ERR(slave,
"Invalid data size %zu!\n", rec_size);
1125 data_size = rec_size - 16;
1142 (word >> 1) & 0x0001;
1146 (word >> 4) & 0x0001;
1151 if (!(desc = kmalloc(data_size + 1, GFP_KERNEL))) {
1152 EC_SLAVE_ERR(slave,
"Failed to allocate SDO entry name!\n");
1156 memcpy(desc, data + 16, data_size);
1157 desc[data_size] = 0;
1208 uint8_t data_set_size;
1215 request->
errno = PTR_ERR(data);
1216 return PTR_ERR(data);
1225 | data_set_size << 2
1235 EC_SLAVE_DBG(slave, 1,
"Expedited download request:\n");
1243 required_data_size =
1246 if (max_data_size < required_data_size) {
1248 data_size = max_data_size;
1250 data_size = required_data_size;
1256 request->
errno = PTR_ERR(data);
1257 return PTR_ERR(data);
1276 request->
data, segment_size);
1277 fsm->
offset += segment_size;
1306 subidxstr[0] = 0x00;
1308 sprintf(subidxstr,
":%02X", request->
subindex);
1311 request->
index, subidxstr);
1317 request->
errno = EPROTONOSUPPORT;
1325 request->
errno = ENOBUFS;
1352 unsigned long diff_ms;
1365 " request datagram: ");
1374 if (diff_ms < fsm->request->response_timeout) {
1377 " download request. Retrying after %lu ms...\n",
1389 EC_SLAVE_ERR(slave,
"Reception of CoE download request" 1390 " for SDO 0x%04x:%x failed with timeout after %lu ms: ",
1397 if (diff_ms > 200) {
1398 EC_SLAVE_WARN(slave,
"SDO 0x%04x:%x download took %lu ms.\n",
1429 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check" 1439 " datagram failed: ");
1445 unsigned long diff_ms =
1451 EC_SLAVE_ERR(slave,
"Timeout after %lu ms while waiting" 1452 " for SDO 0x%04x:%x download response.\n", diff_ms,
1479 size_t max_segment_size =
1484 uint8_t last_segment, seg_data_size, *data;
1486 if (fsm->
remaining > max_segment_size) {
1495 seg_data_size = 0x00;
1506 request->
errno = PTR_ERR(data);
1513 | (seg_data_size << 1)
1544 uint8_t *data, mbox_prot;
1554 request->
errno = EIO;
1557 " response datagram: ");
1563 request->
errno = EIO;
1565 EC_SLAVE_ERR(slave,
"Reception of CoE download response failed: ");
1572 request->
errno = PTR_ERR(data);
1577 if (mbox_prot != EC_MBOX_TYPE_COE) {
1578 request->
errno = EIO;
1580 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
1599 request->
errno = EIO;
1601 EC_SLAVE_ERR(slave,
"Received data are too small (%zu bytes):\n",
1610 request->
errno = EIO;
1613 subidxstr[0] = 0x00;
1615 sprintf(subidxstr,
":%02X", request->
subindex);
1617 EC_SLAVE_ERR(slave,
"SDO download 0x%04X%s (%zu bytes) aborted.\n",
1619 if (rec_size < 10) {
1634 EC_SLAVE_DBG(slave, 1,
"Invalid SDO download response!" 1672 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
1680 EC_SLAVE_ERR(slave,
"Reception of CoE mailbox segment check" 1681 " datagram failed: ");
1687 unsigned long diff_ms =
1693 EC_SLAVE_ERR(slave,
"Timeout while waiting for SDO download" 1694 " segment response.\n");
1722 uint8_t *data, mbox_prot;
1732 request->
errno = EIO;
1734 EC_SLAVE_ERR(slave,
"Failed to receive CoE download response" 1741 request->
errno = EIO;
1743 EC_SLAVE_ERR(slave,
"Reception of CoE download response failed: ");
1750 request->
errno = PTR_ERR(data);
1755 if (mbox_prot != EC_MBOX_TYPE_COE) {
1756 request->
errno = EIO;
1758 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
1777 request->
errno = EIO;
1779 EC_SLAVE_ERR(slave,
"Received data are too small (%zu bytes):\n",
1788 request->
errno = EIO;
1791 subidxstr[0] = 0x00;
1793 sprintf(subidxstr,
":%02X", request->
subindex);
1795 EC_SLAVE_ERR(slave,
"SDO download 0x%04X%s (%zu bytes) aborted.\n",
1797 if (rec_size < 10) {
1810 EC_SLAVE_DBG(slave, 1,
"Invalid SDO download response!" 1823 " segmented download:\n");
1825 request->
errno = EIO;
1859 request->
errno = PTR_ERR(data);
1860 return PTR_ERR(data);
1867 memset(data + 6, 0x00, 4);
1897 request->
errno = EPROTONOSUPPORT;
1922 unsigned long diff_ms;
1934 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload request: ");
1943 if (diff_ms < fsm->request->response_timeout) {
1946 " SDO upload request. Retrying after %lu ms...\n",
1958 EC_SLAVE_ERR(slave,
"Reception of CoE upload request for" 1959 " SDO 0x%04x:%x failed with timeout after %lu ms: ",
1966 if (diff_ms > 200) {
2000 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check datagram: ");
2009 " datagram failed: ");
2015 unsigned long diff_ms =
2021 EC_SLAVE_ERR(slave,
"Timeout after %lu ms while waiting for" 2022 " SDO 0x%04x:%x upload response.\n", diff_ms,
2059 memset(data + 3, 0x00, 7);
2082 uint8_t *data, mbox_prot, rec_subindex;
2083 size_t rec_size, data_size;
2085 unsigned int expedited, size_specified;
2094 request->
errno = EIO;
2096 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload response" 2103 request->
errno = EIO;
2105 EC_SLAVE_ERR(slave,
"Reception of CoE upload response failed: ");
2112 request->
errno = PTR_ERR(data);
2122 if (mbox_prot != EC_MBOX_TYPE_COE) {
2123 request->
errno = EIO;
2126 " as response.\n", mbox_prot);
2139 request->
errno = EIO;
2141 EC_SLAVE_ERR(slave,
"Received currupted SDO upload response" 2142 " (%zu bytes)!\n", rec_size);
2149 EC_SLAVE_ERR(slave,
"SDO upload 0x%04X:%02X aborted.\n",
2151 if (rec_size >= 10) {
2157 request->
errno = EIO;
2165 " uploading SDO 0x%04X:%02X.\n",
2168 request->
errno = EIO;
2176 if (rec_index != request->
index || rec_subindex != request->
subindex) {
2177 EC_SLAVE_ERR(slave,
"Received upload response for wrong SDO" 2178 " (0x%04X:%02X, requested: 0x%04X:%02X).\n",
2179 rec_index, rec_subindex, request->
index, request->
subindex);
2193 size_specified =
EC_READ_U8(data + 2) & 0x01;
2194 if (size_specified) {
2200 if (rec_size < 6 + fsm->complete_size) {
2201 request->
errno = EIO;
2203 EC_SLAVE_ERR(slave,
"Received corrupted SDO expedited upload" 2204 " response (only %zu bytes)!\n", rec_size);
2211 request->
errno = -ret;
2216 if (rec_size < 10) {
2217 request->
errno = EIO;
2219 EC_SLAVE_ERR(slave,
"Received currupted SDO normal upload" 2220 " response (only %zu bytes)!\n", rec_size);
2225 data_size = rec_size - 10;
2230 request->
errno = -ret;
2237 request->
errno = -ret;
2244 if (data_size < fsm->complete_size) {
2245 EC_SLAVE_DBG(slave, 1,
"SDO data incomplete (%zu / %u)." 2284 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload segment" 2285 " request datagram: ");
2294 " request failed: ");
2327 EC_SLAVE_ERR(slave,
"Failed to receive CoE mailbox check" 2336 EC_SLAVE_ERR(slave,
"Reception of CoE mailbox check datagram" 2343 unsigned long diff_ms =
2349 EC_SLAVE_ERR(slave,
"Timeout while waiting for SDO upload" 2350 " segment response.\n");
2379 uint8_t *data, mbox_prot;
2380 size_t rec_size, data_size;
2382 unsigned int last_segment;
2390 request->
errno = EIO;
2392 EC_SLAVE_ERR(slave,
"Failed to receive CoE upload segment" 2393 " response datagram: ");
2399 request->
errno = EIO;
2402 " response failed: ");
2409 request->
errno = PTR_ERR(data);
2419 if (mbox_prot != EC_MBOX_TYPE_COE) {
2420 EC_SLAVE_ERR(slave,
"Received mailbox protocol 0x%02X as response.\n",
2422 request->
errno = EIO;
2435 if (rec_size < 10) {
2437 " segment response!\n");
2439 request->
errno = EIO;
2446 EC_SLAVE_ERR(slave,
"SDO upload 0x%04X:%02X aborted.\n",
2450 request->
errno = EIO;
2458 EC_SLAVE_DBG(slave, 1,
"Invalid SDO upload segment response!\n");
2468 data_size = rec_size - 3;
2470 if (rec_size == 10) {
2471 uint8_t seg_size = (
EC_READ_U8(data + 2) & 0xE) >> 1;
2472 data_size -= seg_size;
2476 EC_SLAVE_ERR(slave,
"SDO upload 0x%04X:%02X failed: Fragment" 2477 " exceeding complete size!\n",
2479 request->
errno = ENOBUFS;
2484 memcpy(request->
data + request->
data_size, data + 3, data_size);
2488 if (!last_segment) {
2497 EC_SLAVE_WARN(slave,
"SDO upload 0x%04X:%02X: Assembled data" 2498 " size (%zu) does not match complete size (%u)!\n",
int ec_fsm_coe_prepare_down_start(ec_fsm_coe_t *, ec_datagram_t *)
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 *, ec_datagram_t *)
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 *, ec_datagram_t *)
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.
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.
int ec_fsm_coe_check_emergency(const ec_fsm_coe_t *, const uint8_t *, size_t)
Check if the received data are a CoE emergency request.
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 *, ec_datagram_t *)
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 *, ec_datagram_t *)
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 *, ec_datagram_t *)
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 *, uint32_t)
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 *, ec_datagram_t *)
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.