IgH EtherCAT Master  1.5.3
fsm_coe.c File Reference

EtherCAT CoE state machines. More...

Go to the source code of this file.

Macros

#define EC_FSM_COE_DICT_TIMEOUT   1000
 Maximum time in ms to wait for responses when reading out the dictionary.
 
#define EC_COE_DOWN_REQ_HEADER_SIZE   10
 CoE download request header size.
 
#define EC_COE_DOWN_SEG_REQ_HEADER_SIZE   3
 CoE download segment request header size.
 
#define EC_COE_DOWN_SEG_MIN_DATA_SIZE   7
 Minimum size of download segment.
 
#define DEBUG_RETRIES   0
 Enable debug output for CoE retries.
 
#define DEBUG_LONG   0
 Enable warning output if transfers take too long.
 

Functions

void ec_fsm_coe_dict_start (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT START. More...
 
void ec_fsm_coe_dict_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT REQUEST. More...
 
void ec_fsm_coe_dict_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT CHECK. More...
 
void ec_fsm_coe_dict_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT RESPONSE. More...
 
void ec_fsm_coe_dict_desc_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT DESC REQUEST. More...
 
void ec_fsm_coe_dict_desc_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT DESC CHECK. More...
 
void ec_fsm_coe_dict_desc_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT DESC RESPONSE. More...
 
void ec_fsm_coe_dict_entry_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT ENTRY REQUEST. More...
 
void ec_fsm_coe_dict_entry_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT ENTRY CHECK. More...
 
void ec_fsm_coe_dict_entry_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DICT ENTRY RESPONSE. More...
 
void ec_fsm_coe_down_start (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DOWN START. More...
 
void ec_fsm_coe_down_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DOWN REQUEST. More...
 
void ec_fsm_coe_down_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DOWN CHECK. More...
 
void ec_fsm_coe_down_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DOWN RESPONSE. More...
 
void ec_fsm_coe_down_seg_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DOWN SEG CHECK. More...
 
void ec_fsm_coe_down_seg_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: DOWN SEG RESPONSE. More...
 
void ec_fsm_coe_up_start (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP START. More...
 
void ec_fsm_coe_up_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP REQUEST. More...
 
void ec_fsm_coe_up_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP CHECK. More...
 
void ec_fsm_coe_up_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP RESPONSE. More...
 
void ec_fsm_coe_up_seg_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP REQUEST. More...
 
void ec_fsm_coe_up_seg_check (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP CHECK. More...
 
void ec_fsm_coe_up_seg_response (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 CoE state: UP RESPONSE. More...
 
void ec_fsm_coe_end (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 State: END. More...
 
void ec_fsm_coe_error (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 State: ERROR. More...
 
void ec_canopen_abort_msg (const ec_slave_t *slave, uint32_t abort_code)
 Outputs an SDO abort message. More...
 
void ec_fsm_coe_init (ec_fsm_coe_t *fsm)
 Constructor. More...
 
void ec_fsm_coe_clear (ec_fsm_coe_t *fsm)
 Destructor. More...
 
void ec_fsm_coe_dictionary (ec_fsm_coe_t *fsm, ec_slave_t *slave)
 Starts reading a slaves' SDO dictionary. More...
 
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. More...
 
int ec_fsm_coe_exec (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Executes the current state of the state machine. More...
 
int ec_fsm_coe_success (const ec_fsm_coe_t *fsm)
 Returns, if the state machine terminated with success. More...
 
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. More...
 
int ec_fsm_coe_prepare_dict (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare a dictionary request. More...
 
int ec_fsm_coe_dict_prepare_desc (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare an object description request. More...
 
int ec_fsm_coe_dict_prepare_entry (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare an entry description request. More...
 
int ec_fsm_coe_prepare_down_start (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare a donwnload request. More...
 
void ec_fsm_coe_down_prepare_segment_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare a download segment request. More...
 
int ec_fsm_coe_prepare_up (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare an upload request. More...
 
void ec_fsm_coe_up_prepare_segment_request (ec_fsm_coe_t *fsm, ec_datagram_t *datagram)
 Prepare an SDO upload segment request. More...
 

Variables

const ec_code_msg_t sdo_abort_messages []
 SDO abort messages. More...
 

Detailed Description

EtherCAT CoE state machines.

Definition in file fsm_coe.c.

Function Documentation

◆ ec_fsm_coe_dict_start()

void ec_fsm_coe_dict_start ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT START.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 341 of file fsm_coe.c.

◆ ec_fsm_coe_dict_request()

void ec_fsm_coe_dict_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT REQUEST.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 373 of file fsm_coe.c.

◆ ec_fsm_coe_dict_check()

void ec_fsm_coe_dict_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 413 of file fsm_coe.c.

◆ ec_fsm_coe_dict_response()

void ec_fsm_coe_dict_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 497 of file fsm_coe.c.

◆ ec_fsm_coe_dict_desc_request()

void ec_fsm_coe_dict_desc_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT DESC REQUEST.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 652 of file fsm_coe.c.

◆ ec_fsm_coe_dict_desc_check()

void ec_fsm_coe_dict_desc_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT DESC CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 695 of file fsm_coe.c.

◆ ec_fsm_coe_dict_desc_response()

void ec_fsm_coe_dict_desc_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT DESC RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine
datagramDatagram to use.

Definition at line 782 of file fsm_coe.c.

◆ ec_fsm_coe_dict_entry_request()

void ec_fsm_coe_dict_entry_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT ENTRY REQUEST.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 917 of file fsm_coe.c.

◆ ec_fsm_coe_dict_entry_check()

void ec_fsm_coe_dict_entry_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT ENTRY CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 959 of file fsm_coe.c.

◆ ec_fsm_coe_dict_entry_response()

void ec_fsm_coe_dict_entry_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DICT ENTRY RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1016 of file fsm_coe.c.

◆ ec_fsm_coe_down_start()

void ec_fsm_coe_down_start ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DOWN START.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1290 of file fsm_coe.c.

◆ ec_fsm_coe_down_request()

void ec_fsm_coe_down_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DOWN REQUEST.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1341 of file fsm_coe.c.

◆ ec_fsm_coe_down_check()

void ec_fsm_coe_down_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DOWN CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1409 of file fsm_coe.c.

◆ ec_fsm_coe_down_response()

void ec_fsm_coe_down_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DOWN RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1533 of file fsm_coe.c.

◆ ec_fsm_coe_down_seg_check()

void ec_fsm_coe_down_seg_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DOWN SEG CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1654 of file fsm_coe.c.

◆ ec_fsm_coe_down_seg_response()

void ec_fsm_coe_down_seg_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: DOWN SEG RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine
datagramDatagram to use.

Definition at line 1711 of file fsm_coe.c.

◆ ec_fsm_coe_up_start()

void ec_fsm_coe_up_start ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP START.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1879 of file fsm_coe.c.

◆ ec_fsm_coe_up_request()

void ec_fsm_coe_up_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP REQUEST.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1911 of file fsm_coe.c.

◆ ec_fsm_coe_up_check()

void ec_fsm_coe_up_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1980 of file fsm_coe.c.

◆ ec_fsm_coe_up_response()

void ec_fsm_coe_up_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 2069 of file fsm_coe.c.

◆ ec_fsm_coe_up_seg_request()

void ec_fsm_coe_up_seg_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP REQUEST.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 2264 of file fsm_coe.c.

◆ ec_fsm_coe_up_seg_check()

void ec_fsm_coe_up_seg_check ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP CHECK.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 2307 of file fsm_coe.c.

◆ ec_fsm_coe_up_seg_response()

void ec_fsm_coe_up_seg_response ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

CoE state: UP RESPONSE.

Todo:
Timeout behavior
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 2367 of file fsm_coe.c.

◆ ec_fsm_coe_end()

void ec_fsm_coe_end ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

State: END.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 2525 of file fsm_coe.c.

◆ ec_fsm_coe_error()

void ec_fsm_coe_error ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

State: ERROR.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 2512 of file fsm_coe.c.

◆ ec_canopen_abort_msg()

void ec_canopen_abort_msg ( const ec_slave_t slave,
uint32_t  abort_code 
)

Outputs an SDO abort message.

Parameters
slaveSlave.
abort_codeAbort code to search for.

Definition at line 148 of file fsm_coe.c.

◆ ec_fsm_coe_init()

void ec_fsm_coe_init ( ec_fsm_coe_t fsm)

Constructor.

Parameters
fsmFinite state machine

Definition at line 170 of file fsm_coe.c.

◆ ec_fsm_coe_clear()

void ec_fsm_coe_clear ( ec_fsm_coe_t fsm)

Destructor.

Parameters
fsmFinite state machine

Definition at line 182 of file fsm_coe.c.

◆ ec_fsm_coe_dictionary()

void ec_fsm_coe_dictionary ( ec_fsm_coe_t fsm,
ec_slave_t slave 
)

Starts reading a slaves' SDO dictionary.

Parameters
fsmFinite state machine
slaveEtherCAT slave

Definition at line 192 of file fsm_coe.c.

◆ ec_fsm_coe_transfer()

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.

Parameters
fsmState machine.
slaveEtherCAT slave.
requestSDO request.

Definition at line 205 of file fsm_coe.c.

◆ ec_fsm_coe_exec()

int ec_fsm_coe_exec ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Executes the current state of the state machine.

Returns
1 if the datagram was used, else 0.
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 228 of file fsm_coe.c.

◆ ec_fsm_coe_success()

int ec_fsm_coe_success ( const ec_fsm_coe_t fsm)

Returns, if the state machine terminated with success.

Returns
non-zero if successful.
Parameters
fsmFinite state machine

Definition at line 262 of file fsm_coe.c.

◆ ec_fsm_coe_check_emergency()

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.

If the check is positive, the emergency request is output.

Returns
The data were an emergency request.
Parameters
fsmFinite state machine
dataCoE mailbox data.
sizeCoE mailbox data size.

Definition at line 277 of file fsm_coe.c.

◆ ec_fsm_coe_prepare_dict()

int ec_fsm_coe_prepare_dict ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare a dictionary request.

Returns
Zero on success, otherwise a negative error code.
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 315 of file fsm_coe.c.

◆ ec_fsm_coe_dict_prepare_desc()

int ec_fsm_coe_dict_prepare_desc ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare an object description request.

Returns
Zero on success, otherwise a negative error code.
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 468 of file fsm_coe.c.

◆ ec_fsm_coe_dict_prepare_entry()

int ec_fsm_coe_dict_prepare_entry ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare an entry description request.

Returns
Zero on success, otherwise a negative error code.
Parameters
fsmFinite state machine
datagramDatagram to use.

Definition at line 751 of file fsm_coe.c.

◆ ec_fsm_coe_prepare_down_start()

int ec_fsm_coe_prepare_down_start ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare a donwnload request.

Returns
Zero on success, otherwise a negative error code.
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1195 of file fsm_coe.c.

◆ ec_fsm_coe_down_prepare_segment_request()

void ec_fsm_coe_down_prepare_segment_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare a download segment request.

Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1467 of file fsm_coe.c.

◆ ec_fsm_coe_prepare_up()

int ec_fsm_coe_prepare_up ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare an upload request.

Returns
Zero on success, otherwise a negative error code.
Parameters
fsmFinite state machine.
datagramDatagram to use.

Definition at line 1842 of file fsm_coe.c.

◆ ec_fsm_coe_up_prepare_segment_request()

void ec_fsm_coe_up_prepare_segment_request ( ec_fsm_coe_t fsm,
ec_datagram_t datagram 
)

Prepare an SDO upload segment request.

Parameters
fsmFinite state machine
datagramDatagram to use.

Definition at line 2037 of file fsm_coe.c.

Variable Documentation

◆ sdo_abort_messages

const ec_code_msg_t sdo_abort_messages[]

SDO abort messages.

The "abort SDO transfer request" supplies an abort code, which can be translated to clear text. This table does the mapping of the codes and messages.

Definition at line 107 of file fsm_coe.c.