From 43ccf1309b5bf4a0d9d5c4437fa5ac01f7dcbc10 Mon Sep 17 00:00:00 2001 From: jsullivan-anl Date: Fri, 22 Sep 2006 16:33:59 +0000 Subject: [PATCH] bug fix - various bug fixes input eos was not getting reset after motor_init change input eos on STA command from to '>' change go command for 8750 compatability --- motorApp/NewFocusSrc/devPMNC87xx.cc | 30 ++++++++++++++-------- motorApp/NewFocusSrc/drvPMNC87xx.cc | 39 +++++++++++++++++------------ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/motorApp/NewFocusSrc/devPMNC87xx.cc b/motorApp/NewFocusSrc/devPMNC87xx.cc index c6beec41..c3c87856 100644 --- a/motorApp/NewFocusSrc/devPMNC87xx.cc +++ b/motorApp/NewFocusSrc/devPMNC87xx.cc @@ -232,12 +232,12 @@ STATIC RTN_STATUS PMNC87xx_build_trans(motor_cmnd command, double *parms, struct { case MOVE_ABS: if (dType == PMD8753) - sprintf(buff, "REL A%d=%d G", drive, intval-motor_info->position); + sprintf(buff, "REL A%d=%d", drive, intval-motor_info->position); else - sprintf(buff, "ABS A%d=%d G", drive, intval); + sprintf(buff, "ABS A%d=%d", drive, intval); break; case MOVE_REL: - sprintf(buff, "REL A%d=%d G", drive, intval); + sprintf(buff, "REL A%d=%d", drive, intval); break; case HOME_FOR: // if (dType == PMD8751) @@ -260,6 +260,8 @@ STATIC RTN_STATUS PMNC87xx_build_trans(motor_cmnd command, double *parms, struct /* Setting local driver position because the controller cannot be set */ sprintf(buff, "CHL A%d=%d", drive, motor); motor_info->position = intval; + motor_info->encoder_position = intval; + cntrl->last_position[axis] = 0; // Used to accumulate position history } else if (dType == PMD8751) { @@ -308,8 +310,7 @@ STATIC RTN_STATUS PMNC87xx_build_trans(motor_cmnd command, double *parms, struct sprintf(buff, "ACC A%d %d=%d", drive, motor, intval); break; case GO: - // GO included in motion commands - fake command to get response - sprintf(buff, "CHL %d", drive); + sprintf(buff, "GO A%d", drive); break; case SET_ENC_RATIO: trans->state = IDLE_STATE; /* No command sent to the controller. */ @@ -328,9 +329,9 @@ STATIC RTN_STATUS PMNC87xx_build_trans(motor_cmnd command, double *parms, struct if (dType == PMD8753) { if (intval >= 0) - sprintf(buff, "FOR A%d=%d G", drive, intval); + sprintf(buff, "FOR A%d=%d", drive, intval); else - sprintf(buff, "REV A%d=%d G", drive, abs(intval)); + sprintf(buff, "REV A%d=%d", drive, abs(intval)); } else if (dType == PMD8751) { @@ -347,13 +348,22 @@ STATIC RTN_STATUS PMNC87xx_build_trans(motor_cmnd command, double *parms, struct // because the 8751 does not indicate motion with (FOR and REV) // ** BUG? ** if (intval >= 0) - sprintf(buff, "REL A%d=1000000 G",drive); + sprintf(buff, "REL A%d=1000000",drive); else - sprintf(buff, "REL A%d=-1000000 G",drive); - } + sprintf(buff, "REL A%d=-1000000",drive); + } else + { sendMsg = false; + break; + } + strcpy(motor_call->message, buff); + rtnval = motor_end_trans_com(mr, drvtabptr); + rtnval = (RTN_STATUS) motor_start_trans_com(mr, PMNC87xx_cards); + motor_call->type = PMNC87xx_table[command]; + + sprintf(buff, "GO A%d", drive); break; case SET_PGAIN: case SET_IGAIN: diff --git a/motorApp/NewFocusSrc/drvPMNC87xx.cc b/motorApp/NewFocusSrc/drvPMNC87xx.cc index 38798deb..56414af8 100644 --- a/motorApp/NewFocusSrc/drvPMNC87xx.cc +++ b/motorApp/NewFocusSrc/drvPMNC87xx.cc @@ -318,7 +318,8 @@ STATIC int set_status(int card, int signal) sprintf(buff, READ_STATUS, driverID); pStr = cntrl->status_string[driverID]; /* STATUS command does not return a prompt - bug? */ - recvRtn = send_recv_mess(card, buff, pStr, NL_EOS); + // recvRtn = send_recv_mess(card, buff, pStr, NL_EOS); + recvRtn = send_recv_mess(card, buff, pStr, NULL); CHECKRTN; Debug(2, "set_status(): Status_string=%s\n", pStr); if (sscanf(pStr, "A%d=0x%x",&recvDriver, &recvStatus) == 2) @@ -558,6 +559,10 @@ STATIC int send_recv_mess(int card, char const *send_com, char *recv_com, char c status = pasynOctetSyncIO->writeRead(cntrl->pasynUser, send_com, size, recv_com, BUFF_SIZE-1, PMNC_TIMEOUT, &nwrite, &nread, &eomReason); + if (eos) + // Reset EOS to default + pasynOctetSyncIO->setInputEos(cntrl->pasynUser,PROMPT_EOS,strlen(PROMPT_EOS)); + if (status != asynSuccess) { Debug(3, "send_recv_mess(): ERROR - staus =%d, nread = %d\n", (int) status, nread); @@ -565,13 +570,7 @@ STATIC int send_recv_mess(int card, char const *send_com, char *recv_com, char c return(MESS_ERR); } - if (eos) - // Reset EOS to default - pasynOctetSyncIO->setInputEos(cntrl->pasynUser,PROMPT_EOS,strlen(PROMPT_EOS)); - - Debug(2, "send_recv_mess(): recv message = \"%s\"\n", recv_com); - return(nread); } @@ -669,6 +668,7 @@ STATIC int recv_mess(int card, char *com, int flag) int flush = 1; size_t nread = 0; int eomReason; + int rtnValue; asynStatus status; /* Check that card exists */ @@ -690,18 +690,23 @@ STATIC int recv_mess(int card, char *com, int flag) status = pasynOctetSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, timeout, &nread, &eomReason); - if (status != asynSuccess) - { - com[0] = '\0'; - return(MESS_ERR); - } - if (flag == 0) // Reset EOS to '\n' pasynOctetSyncIO->setInputEos(cntrl->pasynUser,PROMPT_EOS,strlen(PROMPT_EOS)); - Debug(2, "recv_mess(): message = \"%s\"\n", com); - return (nread); + if (status != asynSuccess) + { + com[0] = '\0'; + rtnValue = MESS_ERR; + Debug(3, "recv_mess(): ERROR - staus =%d, nread = %d\n", (int) status, nread); + } + else + { + Debug(2, "recv_mess(): message = \"%s\"\n", com); + rtnValue = nread; + } + + return (rtnValue); } @@ -837,7 +842,7 @@ STATIC int motor_init() // Resetting the controller loses the ethernet connection - bad idea - if (NULL) + if (false) { /* Reset Controller: takes > 5 sec */ send_recv_mess(card_index, INIT_ALL, nobuff, NULL); @@ -957,6 +962,8 @@ STATIC int motor_init() motor_info->no_motion_count = 0; motor_info->encoder_position = 0; motor_info->position = 0; + cntrl->last_position[motor_index] = 0; /* Used to accumulate position on 8753 drivers */ + /* Encoder Enable */ motor_info->encoder_present = YES;