From cd80f567fe37eeb8f142ce842d97b636a611a9fb Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 10 Jul 2014 13:13:57 +1000 Subject: [PATCH] Only do the rotary_bits if the previous counts is valid This saves decrementing it the first time through because it is in the fourth quadrant and the initial value (zero) is in the first. --- site_ansto/motor_dmc2280.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 4640a517..08db73c6 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -270,6 +270,7 @@ struct __MoDriv { int rotary_count; /**< count of rotations */ char ao_id[256]; bool legacy_fsm; /**< flag for legacy_fsm new code */ + bool status_valid; /**< flag for status has been set from controller */ bool doStats; /**< flag to request stats collection */ double S_x; double S_y; @@ -1800,7 +1801,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) { self->currSteps = iSteps; if (self->bias_bits > 0) iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1); - if (self->rotary_bits > 0) { + if (self->rotary_bits > 0 && self->status_valid) { int shift = 2; int mask = (1 << shift) - 1; int old_bits = (self->currCounts >> (self->rotary_bits - shift)) & mask; @@ -1848,6 +1849,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) { else self->stopCode = 1; } + self->status_valid = true; return 1; }