Commit b2195fc0 authored by Jean-Claude BAU's avatar Jean-Claude BAU

Bug fix: Error in servo calculation for negative delay asymmetry

- Problem was coming from the interval to pico conversion when  the
interval is negative.
- fix also issue in wrs_ajust_in_progress
parent 98746394
......@@ -178,7 +178,17 @@ TimeInterval picos_to_interval(int64_t picos)
int64_t interval_to_picos(TimeInterval interval)
{
return (((interval * (int64_t)1000) + TIME_INTERVAL_ROUNDING_VALUE) >> TIME_INTERVAL_FRACBITS);
int neg;
int64_t picos;
if ( interval < 0 ) {
neg=1;
interval=-interval;
} else
neg=0;
picos=(((interval * (int64_t)1000) + TIME_INTERVAL_ROUNDING_VALUE) >> TIME_INTERVAL_FRACBITS);
return neg ? -picos : picos;
}
/*
......
......@@ -268,8 +268,7 @@ int pp_servo_calculate_delays(struct pp_instance *ppi) {
}
/* delayMS = meanDelay + delayAsym */
delayMS_ps = meanDelay_ps + interval_to_picos(ppi->portDS->delayAsymmetry);
picos_to_pp_time(delayMS_ps, &SRV(ppi)->delayMS);
picos_to_pp_time(delayMS_ps, &servo->delayMS);
/* Calculate offsetFromMaster : t1-t2+meanDelay+delayAsym=t1-t2+delayMS */
servo->offsetFromMaster = servo->t1;
pp_time_sub(&servo->offsetFromMaster, &servo->t2);
......
......@@ -96,6 +96,8 @@ int wrs_adjust_phase(int32_t phase_ps)
return rval;
}
/* return a value > 0 if an adjustment is in progress */
/* return -1 in case of error */
int wrs_adjust_in_progress(void)
{
hexp_pps_params_t p;
......@@ -104,12 +106,11 @@ int wrs_adjust_in_progress(void)
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_pps_cmd,
&rval, HEXP_PPSG_CMD_POLL, &p);
if ((ret < 0) || rval) {
if (ret < 0) {
COMM_ERR_MSG(NULL);
return 0;
return -1;
}
return 1;
return rval ;
}
int wrs_enable_ptracker(struct pp_instance *ppi)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment