Introduced ec_datagram_zero().
This commit is contained in:
parent
186185dce4
commit
64e1d6f678
2
NEWS
2
NEWS
|
|
@ -7,6 +7,8 @@ $Id$
|
|||
Changes since 1.4.0:
|
||||
|
||||
* Added VoE protocol support.
|
||||
* Separated datagram initialization from filling the payload with zeros.
|
||||
Introduced new method ec_datagram_zero() for that.
|
||||
* Added phy_read and phy_write commands to ethercat tool.
|
||||
|
||||
Changes in version 1.4.0-rc2:
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@
|
|||
|
||||
#define EC_FUNC_FOOTER \
|
||||
datagram->data_size = data_size; \
|
||||
memset(datagram->data, 0x00, data_size); \
|
||||
return 0;
|
||||
|
||||
/** \endcond */
|
||||
|
|
@ -161,6 +160,15 @@ int ec_datagram_prealloc(
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Fills the datagram payload memory with zeros.
|
||||
*/
|
||||
void ec_datagram_zero(ec_datagram_t *datagram /**< EtherCAT datagram. */)
|
||||
{
|
||||
memset(datagram->data, 0x00, datagram->data_size);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Initializes an EtherCAT APRD datagram.
|
||||
*
|
||||
* \return 0 in case of success, else < 0
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ typedef struct {
|
|||
void ec_datagram_init(ec_datagram_t *);
|
||||
void ec_datagram_clear(ec_datagram_t *);
|
||||
int ec_datagram_prealloc(ec_datagram_t *, size_t);
|
||||
void ec_datagram_zero(ec_datagram_t *);
|
||||
|
||||
int ec_datagram_aprd(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
int ec_datagram_apwr(ec_datagram_t *, uint16_t, uint16_t, size_t);
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ int ec_domain_add_datagram(
|
|||
domain->expected_working_counter = used[EC_DIR_INPUT];
|
||||
}
|
||||
|
||||
ec_datagram_zero(datagram);
|
||||
list_add_tail(&datagram->list, &domain->datagrams);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ void ec_fsm_change_state_check(ec_fsm_change_t *fsm
|
|||
|
||||
// read AL status from slave
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->spontaneous_change = 0;
|
||||
fsm->state = ec_fsm_change_state_status;
|
||||
|
|
@ -299,6 +300,7 @@ void ec_fsm_change_state_status(ec_fsm_change_t *fsm
|
|||
req_state, slave->ring_position, cur_state);
|
||||
// fetch AL status error code
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0134, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_change_state_code;
|
||||
return;
|
||||
|
|
@ -319,6 +321,7 @@ void ec_fsm_change_state_status(ec_fsm_change_t *fsm
|
|||
check_again:
|
||||
// no timeout yet. check again
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
}
|
||||
|
||||
|
|
@ -457,6 +460,7 @@ void ec_fsm_change_state_ack(ec_fsm_change_t *fsm /**< finite state machine */)
|
|||
|
||||
// read new AL status
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_change_state_check_ack;
|
||||
}
|
||||
|
|
@ -525,6 +529,7 @@ void ec_fsm_change_state_check_ack(ec_fsm_change_t *fsm
|
|||
|
||||
// reread new AL status
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0130, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ void ec_fsm_master_state_start(
|
|||
{
|
||||
fsm->idle = 1;
|
||||
ec_datagram_brd(fsm->datagram, 0x0130, 2);
|
||||
ec_datagram_zero(fsm->datagram);
|
||||
fsm->state = ec_fsm_master_state_broadcast;
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +277,7 @@ void ec_fsm_master_state_broadcast(
|
|||
fsm->slave = master->slaves;
|
||||
ec_datagram_fprd(fsm->datagram, fsm->slave->station_address,
|
||||
0x0130, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_master_state_read_state;
|
||||
} else {
|
||||
|
|
@ -356,6 +358,7 @@ int ec_fsm_master_action_process_phy(
|
|||
if (request->dir == EC_DIR_INPUT) {
|
||||
ec_datagram_fprd(fsm->datagram, request->slave->station_address,
|
||||
request->offset, request->length);
|
||||
ec_datagram_zero(fsm->datagram);
|
||||
} else {
|
||||
if (request->length > fsm->datagram->mem_size) {
|
||||
EC_ERR("Request length (%u) exceeds maximum datagram size (%u)!\n",
|
||||
|
|
@ -541,6 +544,7 @@ void ec_fsm_master_action_next_slave_state(
|
|||
fsm->idle = 1;
|
||||
ec_datagram_fprd(fsm->datagram,
|
||||
fsm->slave->station_address, 0x0130, 2);
|
||||
ec_datagram_zero(fsm->datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_master_state_read_state;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ void ec_fsm_sii_state_read_check(
|
|||
break;
|
||||
}
|
||||
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_sii_state_read_fetch;
|
||||
}
|
||||
|
|
@ -381,6 +382,7 @@ void ec_fsm_sii_state_write_check(
|
|||
|
||||
// issue check datagram
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x502, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_sii_state_write_check2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ void ec_fsm_slave_config_state_init(
|
|||
// clear FMMU configurations
|
||||
ec_datagram_fpwr(datagram, slave->station_address,
|
||||
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_config_state_clear_fmmus;
|
||||
}
|
||||
|
|
@ -295,8 +295,7 @@ void ec_fsm_slave_config_enter_mbox_sync(
|
|||
if (slave->sii.sync_count >= 2) { // mailbox configuration provided
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0800,
|
||||
EC_SYNC_PAGE_SIZE * slave->sii.sync_count);
|
||||
memset(datagram->data, 0x00,
|
||||
EC_SYNC_PAGE_SIZE * slave->sii.sync_count);
|
||||
ec_datagram_zero(datagram);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
ec_sync_page(&slave->sii.syncs[i], i,
|
||||
|
|
@ -314,7 +313,7 @@ void ec_fsm_slave_config_enter_mbox_sync(
|
|||
|
||||
ec_datagram_fpwr(datagram, slave->station_address, 0x0800,
|
||||
EC_SYNC_PAGE_SIZE * 2);
|
||||
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * 2);
|
||||
ec_datagram_zero(datagram);
|
||||
|
||||
ec_sync_init(&sync, slave);
|
||||
sync.physical_start_address = slave->sii.rx_mailbox_offset;
|
||||
|
|
@ -553,7 +552,7 @@ void ec_fsm_slave_config_enter_pdo_sync(
|
|||
ec_datagram_fpwr(datagram, slave->station_address,
|
||||
0x0800 + EC_SYNC_PAGE_SIZE * offset,
|
||||
EC_SYNC_PAGE_SIZE * num_pdo_syncs);
|
||||
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * num_pdo_syncs);
|
||||
ec_datagram_zero(datagram);
|
||||
|
||||
for (i = 0; i < num_pdo_syncs; i++) {
|
||||
sync_index = i + offset;
|
||||
|
|
@ -633,7 +632,7 @@ void ec_fsm_slave_config_enter_fmmu(
|
|||
// configure FMMUs
|
||||
ec_datagram_fpwr(datagram, slave->station_address,
|
||||
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count);
|
||||
ec_datagram_zero(datagram);
|
||||
for (i = 0; i < slave->config->used_fmmus; i++) {
|
||||
fmmu = &slave->config->fmmu_configs[i];
|
||||
if (!(sync = ec_slave_get_sync(slave, fmmu->sync_index))) {
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *fsm /**< slave state m
|
|||
|
||||
// Read AL state
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0130, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_scan_state_state;
|
||||
}
|
||||
|
|
@ -250,6 +251,7 @@ void ec_fsm_slave_scan_state_state(
|
|||
|
||||
// read base data
|
||||
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 6);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_scan_state_base;
|
||||
}
|
||||
|
|
@ -299,6 +301,7 @@ void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *fsm /**< slave state mach
|
|||
|
||||
// read data link status
|
||||
ec_datagram_fprd(datagram, slave->station_address, 0x0110, 2);
|
||||
ec_datagram_zero(datagram);
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_slave_scan_state_datalink;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ int ec_slave_mbox_prepare_check(const ec_slave_t *slave, /**< slave */
|
|||
if (ec_datagram_fprd(datagram, slave->station_address, 0x808, 8))
|
||||
return -1;
|
||||
|
||||
ec_datagram_zero(datagram);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +129,10 @@ int ec_slave_mbox_prepare_fetch(const ec_slave_t *slave, /**< slave */
|
|||
{
|
||||
if (ec_datagram_fprd(datagram, slave->station_address,
|
||||
slave->sii.tx_mailbox_offset,
|
||||
slave->sii.tx_mailbox_size)) return -1;
|
||||
slave->sii.tx_mailbox_size))
|
||||
return -1;
|
||||
|
||||
ec_datagram_zero(datagram);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue