From 6e5c0730e3553dd784c75c7c14d9b76ad4865408 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 11 Jul 2013 17:10:05 +1000 Subject: [PATCH] Improve debug printing --- site_ansto/motor_dmc2280.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 3086f384..64bf630d 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -679,6 +679,12 @@ static int motCreep(pDMC2280Driv self, double target) { if (self->debug) { char line[CMDLEN]; + snprintf(line, CMDLEN, "CREEP: Motor=%s, preseek=%d, creep_val=%d, cur_steps=%d", + self->name, self->preseek, self->creep_val, self->currSteps); + SICSLogWrite(line, eStatus); + snprintf(line, CMDLEN, "CREEP: Motor=%s, fPreseek=%f, fTarget=%f, target=%f, tgt_steps=%d", + self->name, self->fPreseek, self->fTarget, target, target_steps); + SICSLogWrite(line, eStatus); snprintf(line, CMDLEN, "CREEP: cur=%d, target=%d, offset=%d, new=%d", self->currSteps, target_steps, offset, self->currSteps + offset); SICSLogWrite(line, eStatus); @@ -2593,17 +2599,33 @@ static void DMCState_Moving(pDMC2280Driv self, pEvtEvent event) { } else if (self->preseek) { absolute = motCreep(self, target); + if (self->debug) { + char line[CMDLEN]; + snprintf(line, CMDLEN, "Motor=%s unchanged direction: " + "preseek=%d, fPreseek=%f, steps=%d, creep_val=%d", + self->name, + self->preseek, + self->fPreseek, + absolute - self->currSteps, + self->creep_val); + SICSLogWrite(line, eStatus); + } } else { /* change of direction, reset motion check */ - if (self->debug) { - char line[CMDLEN]; - snprintf(line, CMDLEN, "Motor=%s changed direction", - self->name); - SICSLogWrite(line, eStatus); - } set_lastMotion(self, self->currSteps, self->currCounts); absolute = motCreep(self, target); + if (self->debug) { + char line[CMDLEN]; + snprintf(line, CMDLEN, "Motor=%s changed direction: " + "preseek=%d, fPreseek=%f, steps=%d, creep_val=%d", + self->name, + self->preseek, + self->fPreseek, + absolute - self->currSteps, + self->creep_val); + SICSLogWrite(line, eStatus); + } } } else