IgH EtherCAT Master  1.6.2
fsm_foe.c File Reference

EtherCAT FoE state machines. More...

Go to the source code of this file.

Macros

#define EC_FSM_FOE_TIMEOUT   3000
 Maximum time in ms to wait for responses when reading out the dictionary.
 
#define EC_FOE_HEADER_SIZE   6
 Size of the FoE header.
 

Enumerations

enum  {
  EC_FOE_OPCODE_RRQ = 1, EC_FOE_OPCODE_WRQ = 2, EC_FOE_OPCODE_DATA = 3, EC_FOE_OPCODE_ACK = 4,
  EC_FOE_OPCODE_ERR = 5, EC_FOE_OPCODE_BUSY = 6
}
 FoE OpCodes. More...
 

Functions

int ec_foe_prepare_data_send (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Sends a file or the next fragment. More...
 
int ec_foe_prepare_wrq_send (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Prepare a write request (WRQ) with filename. More...
 
int ec_foe_prepare_rrq_send (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Prepare a read request (RRQ) with filename. More...
 
int ec_foe_prepare_send_ack (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Prepare to send an acknowledge. More...
 
void ec_foe_set_tx_error (ec_fsm_foe_t *fsm, uint32_t errorcode)
 Set an error code and go to the send error state. More...
 
void ec_foe_set_rx_error (ec_fsm_foe_t *fsm, uint32_t errorcode)
 Set an error code and go to the receive error state. More...
 
void ec_fsm_foe_end (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 State: END. More...
 
void ec_fsm_foe_error (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 State: ERROR. More...
 
void ec_fsm_foe_state_wrq_sent (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 State: WRQ SENT. More...
 
void ec_fsm_foe_state_rrq_sent (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 State: RRQ SENT. More...
 
void ec_fsm_foe_state_ack_check (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Check for acknowledge. More...
 
void ec_fsm_foe_state_ack_read (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Acknowledge a read operation. More...
 
void ec_fsm_foe_state_data_sent (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 State: WRQ SENT. More...
 
void ec_fsm_foe_state_data_check (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Check for data. More...
 
void ec_fsm_foe_state_data_read (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Start reading data. More...
 
void ec_fsm_foe_state_sent_ack (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Sent an acknowledge. More...
 
void ec_fsm_foe_write_start (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Initializes the FoE write state machine. More...
 
void ec_fsm_foe_read_start (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Starting state for read operations. More...
 
void ec_fsm_foe_init (ec_fsm_foe_t *fsm)
 Constructor. More...
 
void ec_fsm_foe_clear (ec_fsm_foe_t *fsm)
 Destructor. More...
 
int ec_fsm_foe_exec (ec_fsm_foe_t *fsm, ec_datagram_t *datagram)
 Executes the current state of the state machine. More...
 
int ec_fsm_foe_success (const ec_fsm_foe_t *fsm)
 Returns, if the state machine terminated with success. More...
 
void ec_fsm_foe_transfer (ec_fsm_foe_t *fsm, ec_slave_t *slave, ec_foe_request_t *request)
 Prepares an FoE transfer. More...
 

Detailed Description

EtherCAT FoE state machines.

Definition in file fsm_foe.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

FoE OpCodes.

Enumerator
EC_FOE_OPCODE_RRQ 

Read request.

EC_FOE_OPCODE_WRQ 

Write request.

EC_FOE_OPCODE_DATA 

Data.

EC_FOE_OPCODE_ACK 

Acknowledge.

EC_FOE_OPCODE_ERR 

Error.

EC_FOE_OPCODE_BUSY 

Busy.

Definition at line 54 of file fsm_foe.c.

Function Documentation

◆ ec_foe_prepare_data_send()

int ec_foe_prepare_data_send ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Sends a file or the next fragment.

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

Definition at line 224 of file fsm_foe.c.

◆ ec_foe_prepare_wrq_send()

int ec_foe_prepare_wrq_send ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Prepare a write request (WRQ) with filename.

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

Definition at line 265 of file fsm_foe.c.

◆ ec_foe_prepare_rrq_send()

int ec_foe_prepare_rrq_send ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Prepare a read request (RRQ) with filename.

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

Definition at line 542 of file fsm_foe.c.

◆ ec_foe_prepare_send_ack()

int ec_foe_prepare_send_ack ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Prepare to send an acknowledge.

Returns
Zero on success, otherwise a negative error code.
Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 576 of file fsm_foe.c.

◆ ec_foe_set_tx_error()

void ec_foe_set_tx_error ( ec_fsm_foe_t fsm,
uint32_t  errorcode 
)

Set an error code and go to the send error state.

Parameters
fsmFoE statemachine.
errorcodeFoE error code.

Definition at line 893 of file fsm_foe.c.

◆ ec_foe_set_rx_error()

void ec_foe_set_rx_error ( ec_fsm_foe_t fsm,
uint32_t  errorcode 
)

Set an error code and go to the receive error state.

Parameters
fsmFoE statemachine.
errorcodeFoE error code.

Definition at line 906 of file fsm_foe.c.

◆ ec_fsm_foe_end()

void ec_fsm_foe_end ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

State: END.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 208 of file fsm_foe.c.

◆ ec_fsm_foe_error()

void ec_fsm_foe_error ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

State: ERROR.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 194 of file fsm_foe.c.

◆ ec_fsm_foe_state_wrq_sent()

void ec_fsm_foe_state_wrq_sent ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

State: WRQ SENT.

Checks is the previous transmit datagram succeded and sends the next fragment, if necessary.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 464 of file fsm_foe.c.

◆ ec_fsm_foe_state_rrq_sent()

void ec_fsm_foe_state_rrq_sent ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

State: RRQ SENT.

Checks is the previous transmit datagram succeeded and sends the next fragment, if necessary.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 602 of file fsm_foe.c.

◆ ec_fsm_foe_state_ack_check()

void ec_fsm_foe_state_ack_check ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Check for acknowledge.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 332 of file fsm_foe.c.

◆ ec_fsm_foe_state_ack_read()

void ec_fsm_foe_state_ack_read ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Acknowledge a read operation.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 384 of file fsm_foe.c.

◆ ec_fsm_foe_state_data_sent()

void ec_fsm_foe_state_data_sent ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

State: WRQ SENT.

Checks is the previous transmit datagram succeded and sends the next fragment, if necessary.

Parameters
fsmFoe statemachine.
datagramDatagram to use.

Definition at line 505 of file fsm_foe.c.

◆ ec_fsm_foe_state_data_check()

void ec_fsm_foe_state_data_check ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Check for data.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 673 of file fsm_foe.c.

◆ ec_fsm_foe_state_data_read()

void ec_fsm_foe_state_data_read ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Start reading data.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 723 of file fsm_foe.c.

◆ ec_fsm_foe_state_sent_ack()

void ec_fsm_foe_state_sent_ack ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Sent an acknowledge.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 847 of file fsm_foe.c.

◆ ec_fsm_foe_write_start()

void ec_fsm_foe_write_start ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Initializes the FoE write state machine.

Parameters
fsmfinite state machine
datagramDatagram to use.

Definition at line 298 of file fsm_foe.c.

◆ ec_fsm_foe_read_start()

void ec_fsm_foe_read_start ( ec_fsm_foe_t fsm,
ec_datagram_t datagram 
)

Starting state for read operations.

Parameters
fsmFoE statemachine.
datagramDatagram to use.

Definition at line 640 of file fsm_foe.c.

◆ ec_fsm_foe_init()

void ec_fsm_foe_init ( ec_fsm_foe_t fsm)

Constructor.

Parameters
fsmfinite state machine

Definition at line 95 of file fsm_foe.c.

◆ ec_fsm_foe_clear()

void ec_fsm_foe_clear ( ec_fsm_foe_t fsm)

Destructor.

Parameters
fsmfinite state machine

Definition at line 107 of file fsm_foe.c.

◆ ec_fsm_foe_exec()

int ec_fsm_foe_exec ( ec_fsm_foe_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 117 of file fsm_foe.c.

◆ ec_fsm_foe_success()

int ec_fsm_foe_success ( const ec_fsm_foe_t fsm)

Returns, if the state machine terminated with success.

Returns
non-zero if successful.
Parameters
fsmFinite state machine

Definition at line 151 of file fsm_foe.c.

◆ ec_fsm_foe_transfer()

void ec_fsm_foe_transfer ( ec_fsm_foe_t fsm,
ec_slave_t slave,
ec_foe_request_t request 
)

Prepares an FoE transfer.

Parameters
fsmState machine.
slaveEtherCAT slave.
requestSdo request.

Definition at line 160 of file fsm_foe.c.