mirror of
https://github.com/Binary-Coalescence/motorDSM.git
synced 2025-08-04 21:55:40 -05:00
Added method to parse and print out controller return strings.
This commit is contained in:
@@ -140,6 +140,37 @@ void MD90Axis::report(FILE *fp, int level)
|
||||
asynMotorAxis::report(fp, level);
|
||||
}
|
||||
|
||||
/** Print out message if the motor controller returns a non-zero error code
|
||||
* \param[in] functionName The function originating the call
|
||||
* \param[in] reply Reply message returned from motor controller
|
||||
*/
|
||||
asynStatus MD90Axis::parseReply(const char *functionName, const char *reply)
|
||||
{
|
||||
int replyStatus;
|
||||
char replyString[256];
|
||||
int replyValue;
|
||||
asynStatus comStatus;
|
||||
|
||||
comStatus = asynSuccess;
|
||||
|
||||
if (reply[0] == '\0') {
|
||||
comStatus = asynError;
|
||||
replyStatus = -1;
|
||||
} else if ( strcmp(reply, "Unrecognized command.") == 0 ) {
|
||||
replyStatus = 6;
|
||||
} else {
|
||||
sscanf(reply, "%d: %[^:]: %d", &replyStatus, replyString, &replyValue);
|
||||
}
|
||||
|
||||
if (replyStatus != 0) {
|
||||
asynPrint(pasynUser_, ASYN_TRACE_ERROR,
|
||||
"%s: %s\n",
|
||||
functionName, reply);
|
||||
}
|
||||
|
||||
return comStatus;
|
||||
}
|
||||
|
||||
/** Acceleration currently unsupported with MD-90 controller
|
||||
* \param[in] acceleration The accelerations to ramp up to max velocity
|
||||
* \param[in] velocity Motor velocity in steps / sec
|
||||
@@ -165,7 +196,7 @@ asynStatus MD90Axis::sendAccelAndVelocity(double acceleration, double velocity)
|
||||
asynStatus MD90Axis::move(double position, int relative, double minVelocity, double maxVelocity, double acceleration)
|
||||
{
|
||||
asynStatus status;
|
||||
// static const char *functionName = "MD90Axis::move";
|
||||
static const char *functionName = "MD90Axis::move";
|
||||
|
||||
status = sendAccelAndVelocity(acceleration, maxVelocity);
|
||||
|
||||
@@ -177,6 +208,9 @@ asynStatus MD90Axis::move(double position, int relative, double minVelocity, dou
|
||||
sprintf(pC_->outString_, "CLM %d", NINT(position));
|
||||
}
|
||||
status = pC_->writeReadController();
|
||||
if (!status) {
|
||||
status = parseReply(functionName, pC_->inString_);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@ private:
|
||||
MD90Controller *pC_; /**< Pointer to the asynMotorController to which this axis belongs.
|
||||
* Abbreviated because it is used very frequently */
|
||||
asynStatus sendAccelAndVelocity(double accel, double velocity);
|
||||
asynStatus parseReply(const char *functionName, const char *reply);
|
||||
|
||||
friend class MD90Controller;
|
||||
};
|
||||
|
Reference in New Issue
Block a user