Changed the datatypes of the shift times in ecrt_slave_config_dc()

to int32_t to correctly display negative shift times.
This commit is contained in:
Florian Pose 2012-11-29 10:15:40 +01:00
parent 075ac4aee8
commit 7b435e5e84
5 changed files with 19 additions and 15 deletions

View File

@ -64,6 +64,8 @@
* ecrt_master_reference_clock_time() and the feature flag
* EC_HAVE_REF_CLOCK_TIME to have the possibility to synchronize the master
* clock to the reference clock.
* - Changed the datatypes of the shift times in ecrt_slave_config_dc() to
* int32_t to correctly display negative shift times.
*
* Changes in version 1.5:
*
@ -1266,14 +1268,16 @@ int ecrt_slave_config_reg_pdo_entry(
* The AssignActivate word is vendor-specific and can be taken from the XML
* device description file (Device -> Dc -> AssignActivate). Set this to zero,
* if the slave shall be operated without distributed clocks (default).
*
* \attention The \a sync1_shift time is ignored.
*/
void ecrt_slave_config_dc(
ec_slave_config_t *sc, /**< Slave configuration. */
uint16_t assign_activate, /**< AssignActivate word. */
uint32_t sync0_cycle, /**< SYNC0 cycle time [ns]. */
uint32_t sync0_shift, /**< SYNC0 shift time [ns]. */
int32_t sync0_shift, /**< SYNC0 shift time [ns]. */
uint32_t sync1_cycle, /**< SYNC1 cycle time [ns]. */
uint32_t sync1_shift /**< SYNC1 shift time [ns]. */
int32_t sync1_shift /**< SYNC1 shift time [ns]. */
);
/** Add an SDO configuration.

View File

@ -306,8 +306,8 @@ int ecrt_slave_config_reg_pdo_entry(
/*****************************************************************************/
void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
uint32_t sync0_cycle_time, int32_t sync0_shift_time,
uint32_t sync1_cycle_time, int32_t sync1_shift_time)
{
ec_ioctl_config_t data;
int ret;
@ -321,7 +321,7 @@ void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
ret = ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data);
if (EC_IOCTL_IS_ERROR(ret)) {
fprintf(stderr, "Failed to set assign_activate word: %s\n",
fprintf(stderr, "Failed to set DC parameters: %s\n",
strerror(EC_IOCTL_ERRNO(ret)));
}
}

View File

@ -1305,7 +1305,7 @@ void ec_fsm_slave_config_state_dc_sync_check(
EC_SLAVE_DBG(slave, 1, " app_time=%llu\n", master->app_time);
EC_SLAVE_DBG(slave, 1, " start_time=%llu\n", start_time);
EC_SLAVE_DBG(slave, 1, " cycle_time=%u\n", sync0->cycle_time);
EC_SLAVE_DBG(slave, 1, " shift_time=%u\n", sync0->shift_time);
EC_SLAVE_DBG(slave, 1, " shift_time=%i\n", sync0->shift_time);
EC_SLAVE_DBG(slave, 1, " remainder=%u\n", remainder);
EC_SLAVE_DBG(slave, 1, " start=%llu\n", start);
start_time = start;

View File

@ -182,7 +182,7 @@ typedef enum {
*/
typedef struct {
uint32_t cycle_time; /**< Cycle time [ns]. */
uint32_t shift_time; /**< Shift time [ns]. */
int32_t shift_time; /**< Shift time [ns]. */
} ec_sync_signal_t;
/** Access states for SDO entries.

View File

@ -79,10 +79,10 @@ void ec_slave_config_init(
sc->used_fmmus = 0;
sc->dc_assign_activate = 0x0000;
sc->dc_sync[0].cycle_time = 0x00000000;
sc->dc_sync[1].cycle_time = 0x00000000;
sc->dc_sync[0].shift_time = 0x00000000;
sc->dc_sync[1].shift_time = 0x00000000;
sc->dc_sync[0].cycle_time = 0U;
sc->dc_sync[1].cycle_time = 0;
sc->dc_sync[0].shift_time = 0U;
sc->dc_sync[1].shift_time = 0;
INIT_LIST_HEAD(&sc->sdo_configs);
INIT_LIST_HEAD(&sc->sdo_requests);
@ -771,12 +771,12 @@ int ecrt_slave_config_reg_pdo_entry(
/*****************************************************************************/
void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
uint32_t sync0_cycle_time, int32_t sync0_shift_time,
uint32_t sync1_cycle_time, int32_t sync1_shift_time)
{
EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, assign_activate = 0x%04X,"
" sync0_cycle = %u, sync0_shift = %u,"
" sync1_cycle = %u, sync1_shift = %u\n",
" sync0_cycle = %u, sync0_shift = %i,"
" sync1_cycle = %u, sync1_shift = %i\n",
__func__, sc, assign_activate, sync0_cycle_time, sync0_shift_time,
sync1_cycle_time, sync1_shift_time);