49 #define SII_TIMEOUT 20 100 uint16_t word_offset,
118 uint16_t word_offset,
119 const uint16_t *value,
127 memcpy(fsm->
value, value, 2);
262 "Failed to receive SII check/fetch datagram: ");
270 "Reception of SII check/fetch datagram failed: ");
282 " reading from SII word 0x%04x.\n", fsm->
word_offset);
291 unsigned long diff_ms =
309 memcpy(fsm->
value, datagram->
data + 6, 4);
332 memset(datagram->
data + 4, 0x00, 2);
333 memcpy(datagram->
data + 6, fsm->
value, 2);
394 unsigned long diff_ms;
402 "Failed to receive SII write check datagram: ");
410 "Reception of SII write check datagram failed: ");
#define EC_FSM_RETRIES
Number of state machine retries on datagram timeout.
uint16_t ring_position
Ring position.
unsigned long jiffies_sent
Jiffies, when the datagram was sent.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
Convenience macro for printing slave-specific debug messages to syslog.
void ec_fsm_sii_state_end(ec_fsm_sii_t *)
State: END.
#define SII_TIMEOUT
Read/write timeout [ms].
void ec_fsm_sii_state_error(ec_fsm_sii_t *)
State: ERROR.
void ec_fsm_sii_state_start_reading(ec_fsm_sii_t *)
SII state: START READING.
unsigned long jiffies_start
Start timestamp.
Slave information interface FSM.
ec_fsm_sii_addressing_t
SII access addressing mode.
uint16_t word_offset
input: word offset in SII
void ec_fsm_sii_write(ec_fsm_sii_t *fsm, ec_slave_t *slave, uint16_t word_offset, const uint16_t *value, ec_fsm_sii_addressing_t mode)
Initializes the SII write state machine.
#define EC_WRITE_U8(DATA, VAL)
Write an 8-bit unsigned value to EtherCAT data.
#define SII_INHIBIT
Time before evaluating answer at writing [ms].
uint16_t working_counter
Working counter.
void ec_fsm_sii_init(ec_fsm_sii_t *fsm, ec_datagram_t *datagram)
Constructor.
uint16_t station_address
Configured station address.
int ec_datagram_aprd(ec_datagram_t *datagram, uint16_t ring_position, uint16_t mem_address, size_t data_size)
Initializes an EtherCAT APRD datagram.
Global definitions and macros.
EtherCAT master structure.
unsigned int retries
retries upon datagram timeout
int ec_datagram_apwr(ec_datagram_t *datagram, uint16_t ring_position, uint16_t mem_address, size_t data_size)
Initializes an EtherCAT APWR datagram.
void ec_datagram_zero(ec_datagram_t *datagram)
Fills the datagram payload memory with zeros.
void(* state)(ec_fsm_sii_t *)
SII state function.
ec_datagram_state_t state
State.
Use configured addresses.
#define EC_SLAVE_ERR(slave, fmt, args...)
Convenience macro for printing slave-specific errors to syslog.
void ec_fsm_sii_state_write_check(ec_fsm_sii_t *)
SII state: WRITE CHECK.
void ec_datagram_print_wc_error(const ec_datagram_t *datagram)
Evaluates the working counter of a single-cast datagram.
#define EC_WRITE_U16(DATA, VAL)
Write a 16-bit unsigned value to EtherCAT data.
int ec_datagram_fpwr(ec_datagram_t *datagram, uint16_t configured_address, uint16_t mem_address, size_t data_size)
Initializes an EtherCAT FPWR datagram.
int ec_datagram_fprd(ec_datagram_t *datagram, uint16_t configured_address, uint16_t mem_address, size_t data_size)
Initializes an EtherCAT FPRD datagram.
uint8_t check_once_more
one more try after timeout
void ec_fsm_sii_read(ec_fsm_sii_t *fsm, ec_slave_t *slave, uint16_t word_offset, ec_fsm_sii_addressing_t mode)
Initializes the SII read state machine.
void ec_print_data(const uint8_t *, size_t)
Outputs frame contents for debugging purposes.
void ec_fsm_sii_clear(ec_fsm_sii_t *fsm)
Destructor.
EtherCAT slave information interface FSM structure.
int ec_fsm_sii_exec(ec_fsm_sii_t *fsm)
Executes the SII state machine.
int ec_fsm_sii_success(ec_fsm_sii_t *fsm)
Returns, if the master startup state machine terminated with success.
void ec_datagram_print_state(const ec_datagram_t *datagram)
Prints the state of a datagram.
ec_slave_t * slave
slave the FSM runs on
uint8_t * data
Datagram payload.
void ec_fsm_sii_state_start_writing(ec_fsm_sii_t *)
SII state: START WRITING.
#define EC_READ_U8(DATA)
Read an 8-bit unsigned value from EtherCAT data.
ec_fsm_sii_addressing_t mode
reading via APRD or NPRD
void ec_fsm_sii_state_read_fetch(ec_fsm_sii_t *)
SII state: READ FETCH.
void ec_fsm_sii_state_read_check(ec_fsm_sii_t *)
SII state: READ CHECK.
void ec_fsm_sii_state_write_check2(ec_fsm_sii_t *)
SII state: WRITE CHECK 2.
Use auto-increment addressing.
ec_datagram_t * datagram
datagram used in the state machine
unsigned long jiffies_received
Jiffies, when the datagram was received.
uint8_t value[4]
raw SII value (32bit)