Improved error reporting to the MsgTxt additional field
This commit is contained in:
@ -5,6 +5,10 @@ USAGE... Motor driver support for the PSI EL734 controller.
|
||||
Mark Koennecke
|
||||
February 2013
|
||||
|
||||
Updated to have an MsgTxt field through SINQAxis, error handling
|
||||
|
||||
Mark Koennecke, May, August 2017
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@ -134,18 +138,22 @@ void EL734Controller::switchRemote()
|
||||
* \param[out] reply The controllers reply
|
||||
*/
|
||||
|
||||
asynStatus EL734Controller::transactController(char command[COMLEN], char reply[COMLEN])
|
||||
asynStatus EL734Controller::transactController(int axisNo,char command[COMLEN], char reply[COMLEN])
|
||||
{
|
||||
asynStatus status;
|
||||
size_t in, out, i;
|
||||
int reason;
|
||||
char myReply[COMLEN];
|
||||
char myReply[COMLEN], errTxt[256];
|
||||
SINQAxis *axis = getAxis(axisNo);
|
||||
|
||||
pasynOctetSyncIO->flush(pasynUserController_);
|
||||
|
||||
status = pasynOctetSyncIO->writeRead(pasynUserController_, command, strlen(command),
|
||||
reply,COMLEN, 1.,&out,&in,&reason);
|
||||
if(status != asynSuccess){
|
||||
if(axis!= NULL){
|
||||
axis->updateMsgTxtFromDriver("Lost connection to motor controller");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -174,13 +182,25 @@ asynStatus EL734Controller::transactController(char command[COMLEN], char reply[
|
||||
myReply[i] = (char)tolower((int)reply[i]);
|
||||
}
|
||||
if(strstr(myReply,"?cmd") != NULL){
|
||||
errlogSevPrintf(errlogMajor, "Bad command %s", command);
|
||||
snprintf(errTxt,sizeof(errTxt), "Bad command %s at axis %d", command, axisNo);
|
||||
errlogSevPrintf(errlogMajor, errTxt);
|
||||
if(axis!= NULL){
|
||||
axis->updateMsgTxtFromDriver(errTxt);
|
||||
}
|
||||
return asynError;
|
||||
} else if(strstr(myReply,"?par") != NULL){
|
||||
errlogSevPrintf(errlogMajor, "Bad parameter in command %s", command);
|
||||
snprintf(errTxt,sizeof(errTxt), "Bad parameter in command %s", command);
|
||||
errlogSevPrintf(errlogMajor, errTxt);
|
||||
if(axis!= NULL){
|
||||
axis->updateMsgTxtFromDriver(errTxt);
|
||||
}
|
||||
return asynError;
|
||||
} else if(strstr(myReply,"?rng") != NULL){
|
||||
errlogSevPrintf(errlogMajor, "Parameter out of range in command %s", command);
|
||||
snprintf(errTxt,sizeof(errTxt), "Parameter out of range in command %s", command);
|
||||
errlogSevPrintf(errlogMajor, errTxt);
|
||||
if(axis!= NULL){
|
||||
axis->updateMsgTxtFromDriver(errTxt);
|
||||
}
|
||||
return asynError;
|
||||
}
|
||||
|
||||
@ -234,10 +254,7 @@ asynStatus EL734Axis::move(double position, int relative, double minVelocity, do
|
||||
oredMSR = 0;
|
||||
homing = 0;
|
||||
sprintf(command, "p %d %.3f", axisNo_, position/1000.);
|
||||
status = pC_->transactController(command,reply);
|
||||
if(status == asynError){
|
||||
updateMsgTxtFromDriver(reply);
|
||||
}
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
next_poll = -1;
|
||||
return status;
|
||||
}
|
||||
@ -253,11 +270,8 @@ asynStatus EL734Axis::home(double minVelocity, double maxVelocity, double accele
|
||||
sprintf(command, "R %d", axisNo_);
|
||||
homing = 1;
|
||||
next_poll= -1;
|
||||
status = pC_->transactController(command,reply);
|
||||
if(status == asynError){
|
||||
updateMsgTxtFromDriver(reply);
|
||||
}
|
||||
return status;
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
return status;
|
||||
}
|
||||
|
||||
asynStatus EL734Axis::moveVelocity(double minVelocity, double maxVelocity, double acceleration)
|
||||
@ -278,10 +292,7 @@ asynStatus EL734Axis::moveVelocity(double minVelocity, double maxVelocity, doubl
|
||||
/* This is a negative move */
|
||||
sprintf(command, "FB %d", axisNo_);
|
||||
}
|
||||
status = pC_->transactController(command,reply);
|
||||
if(status == asynError){
|
||||
updateMsgTxtFromDriver(reply);
|
||||
}
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
next_poll = -1;
|
||||
return status;
|
||||
}
|
||||
@ -293,7 +304,7 @@ asynStatus EL734Axis::stop(double acceleration )
|
||||
char command[COMLEN], reply[COMLEN];
|
||||
|
||||
sprintf(command, "S %d", axisNo_);
|
||||
status = pC_->transactController(command,reply);
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
errlogPrintf("Sent STOP on Axis %d\n", axisNo_);
|
||||
updateMsgTxtFromDriver("Axis interrupted");
|
||||
|
||||
@ -307,10 +318,7 @@ asynStatus EL734Axis::setPosition(double position)
|
||||
char command[COMLEN], reply[COMLEN];
|
||||
|
||||
sprintf(command, "P %d %f", axisNo_, position/1000.);
|
||||
status = pC_->transactController(command,reply);
|
||||
if(status == asynError){
|
||||
updateMsgTxtFromDriver(reply);
|
||||
}
|
||||
status = pC_->transactController(axisNo_,command,reply);
|
||||
next_poll = -1;
|
||||
|
||||
return status;
|
||||
@ -336,9 +344,9 @@ asynStatus EL734Axis::setClosedLoop(bool closedLoop)
|
||||
* \param[out] moving A flag that is set indicating that the axis is moving (true) or done (false). */
|
||||
asynStatus EL734Axis::poll(bool *moving)
|
||||
{
|
||||
int msr;
|
||||
int msr, count;
|
||||
asynStatus comStatus;
|
||||
char command[COMLEN], reply[COMLEN];
|
||||
char command[COMLEN], reply[COMLEN], errTxt[256];
|
||||
int driverError = 0;
|
||||
|
||||
|
||||
@ -350,10 +358,9 @@ asynStatus EL734Axis::poll(bool *moving)
|
||||
|
||||
// Read the current motor position
|
||||
sprintf(command,"u %d", axisNo_);
|
||||
comStatus = pC_->transactController(command,reply);
|
||||
comStatus = pC_->transactController(axisNo_,command,reply);
|
||||
if(comStatus == asynError){
|
||||
updateMsgTxtFromDriver(reply);
|
||||
driverError = 1;
|
||||
driverError = 1;
|
||||
}
|
||||
if(comStatus) goto skip;
|
||||
if(strstr(reply,"*ES") != NULL){
|
||||
@ -369,7 +376,14 @@ asynStatus EL734Axis::poll(bool *moving)
|
||||
updateMsgTxtFromDriver(NULL);
|
||||
goto skip;
|
||||
}
|
||||
sscanf(reply,"%lf", &position);
|
||||
count = sscanf(reply,"%lf", &position);
|
||||
if(count != 1) {
|
||||
snprintf(errTxt,sizeof(errTxt),"Bad reply %s when reading position for %d", reply, axisNo_);
|
||||
updateMsgTxtFromDriver(errTxt);
|
||||
comStatus = asynError;
|
||||
driverError =1;
|
||||
goto skip;
|
||||
}
|
||||
//errlogPrintf("Axis %d, reply %s, position %lf\n", axisNo_, reply, position);
|
||||
setDoubleParam(pC_->motorPosition_, position*1000);
|
||||
//setDoubleParam(pC_->motorEncoderPosition_, position);
|
||||
@ -377,7 +391,7 @@ asynStatus EL734Axis::poll(bool *moving)
|
||||
|
||||
// Read the moving status of this motor
|
||||
sprintf(command,"msr %d",axisNo_);
|
||||
comStatus = pC_->transactController(command,reply);
|
||||
comStatus = pC_->transactController(axisNo_,command,reply);
|
||||
if(comStatus) goto skip;
|
||||
sscanf(reply,"%x",&msr);
|
||||
// errlogPrintf("Axis %d, reply %s, msr %d, position = %lf\n",
|
||||
|
@ -53,7 +53,7 @@ friend class EL734Axis;
|
||||
private:
|
||||
asynUser *pasynUserController_;
|
||||
|
||||
asynStatus transactController(char command[COMLEN], char reply[COMLEN]);
|
||||
asynStatus transactController(int axis, char command[COMLEN], char reply[COMLEN]);
|
||||
|
||||
void switchRemote();
|
||||
|
||||
|
@ -16,8 +16,9 @@ class epicsShareClass SINQAxis : public asynMotorAxis
|
||||
asynStatus setStringParam(int function, const char *value);
|
||||
|
||||
friend class SINQController;
|
||||
protected:
|
||||
void updateMsgTxtFromDriver(const char *value);
|
||||
|
||||
protected:
|
||||
private:
|
||||
SINQController *pC_;
|
||||
|
||||
|
Reference in New Issue
Block a user