IgH EtherCAT Master  1.6.2
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_canopen_abort_msg (const ec_slave_t *slave, uint32_t abort_code)
 Outputs an SDO abort message. More...
 
int ec_fsm_coe_check_emergency (const 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...
 
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_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...
 

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_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 153 of file fsm_coe.c.

◆ ec_fsm_coe_check_emergency()

int ec_fsm_coe_check_emergency ( const 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 282 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 320 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 473 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 756 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 1200 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 1472 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 1847 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 2042 of file fsm_coe.c.

◆ 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 346 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 378 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 418 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 502 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 657 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 700 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 787 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 922 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 964 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 1021 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 1295 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 1346 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 1414 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 1538 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 1659 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 1716 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 1884 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 1916 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 1985 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 2074 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 2269 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 2312 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 2372 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 2530 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 2517 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 175 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 187 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 197 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 210 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 233 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 267 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 112 of file fsm_coe.c.