IgH EtherCAT Master  1.5.3
fsm_soe.c File Reference

EtherCAT SoE state machines. More...

Go to the source code of this file.

Macros

#define EC_SOE_SIZE   0x04
 Size of all SoE headers.
 
#define EC_SOE_HEADER_SIZE   (EC_MBOX_HEADER_SIZE + EC_SOE_SIZE)
 SoE header size.
 
#define EC_SOE_RESPONSE_TIMEOUT   1000
 SoE response timeout [ms].
 

Enumerations

enum  ec_soe_opcodes { OPCODE_READ_REQUEST = 0x01, OPCODE_READ_RESPONSE = 0x02, OPCODE_WRITE_REQUEST = 0x03, OPCODE_WRITE_RESPONSE = 0x04 }
 SoE operations. More...
 

Functions

void ec_fsm_soe_read_start (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 SoE state: READ START. More...
 
void ec_fsm_soe_read_request (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 SoE state: READ REQUEST. More...
 
void ec_fsm_soe_read_check (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 CoE state: READ CHECK. More...
 
void ec_fsm_soe_read_response (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 SoE state: READ RESPONSE. More...
 
void ec_fsm_soe_write_start (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 SoE state: WRITE START. More...
 
void ec_fsm_soe_write_request (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 SoE state: WRITE REQUEST. More...
 
void ec_fsm_soe_write_check (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 CoE state: WRITE CHECK. More...
 
void ec_fsm_soe_write_response (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 SoE state: WRITE RESPONSE. More...
 
void ec_fsm_soe_end (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 State: END. More...
 
void ec_fsm_soe_error (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 State: ERROR. More...
 
void ec_print_soe_error (const ec_slave_t *slave, uint16_t error_code)
 Outputs an SoE error code.
 
void ec_fsm_soe_init (ec_fsm_soe_t *fsm)
 Constructor. More...
 
void ec_fsm_soe_clear (ec_fsm_soe_t *fsm)
 Destructor. More...
 
void ec_fsm_soe_transfer (ec_fsm_soe_t *fsm, ec_slave_t *slave, ec_soe_request_t *request)
 Starts to transfer an IDN to/from a slave. More...
 
int ec_fsm_soe_exec (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 Executes the current state of the state machine. More...
 
int ec_fsm_soe_success (const ec_fsm_soe_t *fsm)
 Returns, if the state machine terminated with success. More...
 
void ec_fsm_soe_print_error (ec_fsm_soe_t *fsm)
 Output information about a failed SoE transfer. More...
 
int ec_fsm_soe_prepare_read (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 Prepare a read operation. More...
 
void ec_fsm_soe_write_next_fragment (ec_fsm_soe_t *fsm, ec_datagram_t *datagram)
 Write next fragment. More...
 

Variables

const ec_code_msg_t soe_error_codes []
 SoE error codes.
 

Detailed Description

EtherCAT SoE state machines.

Definition in file fsm_soe.c.

Enumeration Type Documentation

◆ ec_soe_opcodes

SoE operations.

Enumerator
OPCODE_READ_REQUEST 

Read request.

OPCODE_READ_RESPONSE 

Read response.

OPCODE_WRITE_REQUEST 

Write request.

OPCODE_WRITE_RESPONSE 

Write response.

Definition at line 44 of file fsm_soe.c.

Function Documentation

◆ ec_fsm_soe_read_start()

void ec_fsm_soe_read_start ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

SoE state: READ START.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 252 of file fsm_soe.c.

◆ ec_fsm_soe_read_request()

void ec_fsm_soe_read_request ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

SoE state: READ REQUEST.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 283 of file fsm_soe.c.

◆ ec_fsm_soe_read_check()

void ec_fsm_soe_read_check ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

CoE state: READ CHECK.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 338 of file fsm_soe.c.

◆ ec_fsm_soe_read_response()

void ec_fsm_soe_read_response ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

SoE state: READ RESPONSE.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 394 of file fsm_soe.c.

◆ ec_fsm_soe_write_start()

void ec_fsm_soe_write_start ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

SoE state: WRITE START.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 567 of file fsm_soe.c.

◆ ec_fsm_soe_write_request()

void ec_fsm_soe_write_request ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

SoE state: WRITE REQUEST.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 603 of file fsm_soe.c.

◆ ec_fsm_soe_write_check()

void ec_fsm_soe_write_check ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

CoE state: WRITE CHECK.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 663 of file fsm_soe.c.

◆ ec_fsm_soe_write_response()

void ec_fsm_soe_write_response ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

SoE state: WRITE RESPONSE.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 717 of file fsm_soe.c.

◆ ec_fsm_soe_end()

void ec_fsm_soe_end ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

State: END.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 835 of file fsm_soe.c.

◆ ec_fsm_soe_error()

void ec_fsm_soe_error ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

State: ERROR.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 824 of file fsm_soe.c.

◆ ec_fsm_soe_init()

void ec_fsm_soe_init ( ec_fsm_soe_t fsm)

Constructor.

Parameters
fsmfinite state machine

Definition at line 105 of file fsm_soe.c.

◆ ec_fsm_soe_clear()

void ec_fsm_soe_clear ( ec_fsm_soe_t fsm)

Destructor.

Parameters
fsmfinite state machine

Definition at line 118 of file fsm_soe.c.

◆ ec_fsm_soe_transfer()

void ec_fsm_soe_transfer ( ec_fsm_soe_t fsm,
ec_slave_t slave,
ec_soe_request_t request 
)

Starts to transfer an IDN to/from a slave.

Parameters
fsmState machine.
slaveEtherCAT slave.
requestSoE request.

Definition at line 128 of file fsm_soe.c.

◆ ec_fsm_soe_exec()

int ec_fsm_soe_exec ( ec_fsm_soe_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 150 of file fsm_soe.c.

◆ ec_fsm_soe_success()

int ec_fsm_soe_success ( const ec_fsm_soe_t fsm)

Returns, if the state machine terminated with success.

Returns
non-zero if successful.
Parameters
fsmFinite state machine

Definition at line 185 of file fsm_soe.c.

◆ ec_fsm_soe_print_error()

void ec_fsm_soe_print_error ( ec_fsm_soe_t fsm)

Output information about a failed SoE transfer.

Parameters
fsmFinite state machine

Definition at line 194 of file fsm_soe.c.

◆ ec_fsm_soe_prepare_read()

int ec_fsm_soe_prepare_read ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

Prepare a read operation.

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

Definition at line 217 of file fsm_soe.c.

◆ ec_fsm_soe_write_next_fragment()

void ec_fsm_soe_write_next_fragment ( ec_fsm_soe_t fsm,
ec_datagram_t datagram 
)

Write next fragment.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 520 of file fsm_soe.c.