diff --git a/documentation/motor_release.html b/documentation/motor_release.html index 3c9ebc93..3f17806e 100644 --- a/documentation/motor_release.html +++ b/documentation/motor_release.html @@ -48,6 +48,13 @@ set the limit mode to "Hard".
+OMS Asyn
++ Flush OMS MAXv response buffer more than once (Thanks to Mitch D'Ewart). + Allow up to 10 axes for current MAXnet cards. Increased read buffer length for + MAXnet cards. +
+Micos MoCo
Bug fix for protection against NULL *parms pointer from motor record.
diff --git a/motorApp/OmsAsynSrc/omsBaseAxis.cpp b/motorApp/OmsAsynSrc/omsBaseAxis.cpp
index a1aa6433..2ddf7b74 100644
--- a/motorApp/OmsAsynSrc/omsBaseAxis.cpp
+++ b/motorApp/OmsAsynSrc/omsBaseAxis.cpp
@@ -48,7 +48,11 @@ asynStatus omsBaseAxis::move(double position, int relative, double min_velocity,
else
rela = 0;
- pos = (epicsInt32) (position + 0.5);
+ if ( position < 0.0)
+ pos = (epicsInt32) (position - 0.5);
+ else
+ pos = (epicsInt32) (position + 0.5);
+
if (abs(pos) > 67000000){
asynPrint(pasynUser_, ASYN_TRACE_ERROR,
"%s:%s:%s axis %d position out of range %f\n",
@@ -167,7 +171,7 @@ asynStatus omsBaseAxis::stop(double acceleration )
asynPrint(pasynUser_, ASYN_TRACE_FLOW,
"%s:%s: port %s, set axis %d to stop with accel=%f\n",
- driverName, functionName, pC_->portName, axisNo_, axisNo_, acceleration );
+ driverName, functionName, pC_->portName, axisNo_, acceleration );
return status;
}
diff --git a/motorApp/OmsAsynSrc/omsBaseController.cpp b/motorApp/OmsAsynSrc/omsBaseController.cpp
index c8d901aa..a2a66a3b 100644
--- a/motorApp/OmsAsynSrc/omsBaseController.cpp
+++ b/motorApp/OmsAsynSrc/omsBaseController.cpp
@@ -37,7 +37,7 @@ static const char *driverName = "omsBaseDriver";
#ifdef __GNUG__
#ifdef DEBUG
- #define Debug(l, f, args...) {if (l <= motorOMSBASEdebug) \
+ #define Debug(l, f, args...) {if (l & motorOMSBASEdebug) \
errlogPrintf(f, ## args);}
#else
#define Debug(l, f, args...)
@@ -77,6 +77,9 @@ omsBaseController::omsBaseController(const char *portName, int maxAxes, int prio
++omsTotalControllerNumber;
sanityCounter = 0;
+ fwMajor = 0;
+ fwMinor = 0;
+ fwRevision = 0;
useWatchdog = false;
enabled = true;
numAxes = maxAxes;
@@ -134,8 +137,8 @@ void omsBaseController::report(FILE *fp, int level)
double velocity, position, encoderPosition;
int haveEncoder=0;
- fprintf(fp, "Oms %s motor driver %s, numAxes=%d\n",
- controllerType, portName, numAxes);
+ fprintf(fp, "Oms %s motor driver %s, numAxes=%d; Firmware: %d.%d.%d\n",
+ controllerType, portName, numAxes, fwMajor, fwMinor, fwRevision);
for (axis=0; axis < numAxes; axis++) {
omsBaseAxis *pAxis = pAxes[axis];
@@ -228,7 +231,7 @@ asynStatus omsBaseController::readInt32(asynUser *pasynUser, epicsInt32 *value)
int function = pasynUser->reason;
asynStatus status = asynSuccess;
omsBaseAxis *pAxis = getAxis(pasynUser);
- static const char *functionName = "readInt32";
+// static const char *functionName = "readInt32";
static char outputBuffer[8];
if (!pAxis) return asynError;
@@ -268,7 +271,7 @@ asynStatus omsBaseController::writeInt32(asynUser *pasynUser, epicsInt32 value)
if (function == motorDeferMoves_)
{
asynPrint(pasynUser, ASYN_TRACE_ERROR,
- "%s:%s:%s Deferred Move: not yet implemented %s\n",
+ "%s:%s:%s Deferred Move: not yet implemented\n",
driverName, functionName, portName);
}
else if (function == motorClosedLoop_)
@@ -449,7 +452,7 @@ asynStatus omsBaseController::Init(const char* initString, int multiple){
char *p, *tokSave;
int totalAxes;
- char axisChrArr[OMS_MAX_AXES] = {'X','Y','Z','T','U','V','R','S'};
+ char axisChrArr[OMS_MAX_AXES] = {'X','Y','Z','T','U','V','R','S','W','K'};
char outputBuffer[10];
epicsInt32 axisPosArr[OMS_MAX_AXES];
@@ -459,6 +462,9 @@ asynStatus omsBaseController::Init(const char* initString, int multiple){
/* Stop all axes */
sendOnlyLock("AM SA;");
+ /* wait before sending init commands */
+ epicsThreadSleep(0.5);
+
/* send InitString */
if ((initString != NULL) && (strlen(initString) > 0)) {
if (multiple){
@@ -473,9 +479,10 @@ asynStatus omsBaseController::Init(const char* initString, int multiple){
sendOnlyLock(initString);
}
}
+ /* Some init commands (like "LT") need some time to process */
+ epicsThreadSleep(0.5);
/* get Positions of all axes */
- inputBuffer[0] = '\0';
sendReceiveLock((char*) "AA RP;", inputBuffer, sizeof(inputBuffer));
if (numAxes > OMS_MAX_AXES) {
@@ -508,7 +515,7 @@ asynStatus omsBaseController::Init(const char* initString, int multiple){
pAxis->setIntegerParam(motorStatusCommsError_, 0);
/* Determine if encoder is present and if mode is stepper or servo. */
- if (firmwareMin(1,1,30))
+ if (firmwareMin(1,30,0))
strcpy(outputBuffer,"A? PS?");
else
strcpy(outputBuffer,"A? ?PS");
@@ -532,7 +539,7 @@ asynStatus omsBaseController::Init(const char* initString, int multiple){
/* Determine limit true state high or low */
/* CAUTION you need firmware version 1.30 or higher to do this */
- if (firmwareMin(1,1,30))
+ if (firmwareMin(1,30,0))
strcpy(outputBuffer,"A? LT?");
else
strcpy(outputBuffer,"A? ?LS");
@@ -611,14 +618,14 @@ void omsBaseController::omsPoller()
if (loopBreakCount > 10){
errlogPrintf("%s:%s:%s: Error: %d consecutive unsuccessful attempts to read from motor card\n"
, driverName, functionName, this->portName, loopBreakCount);
- loopBreakCount = 0;
+ break;
}
epicsTimeGetCurrent(&loopStart);
retry_count = 0;
while ((getAxesPositions(axisPosArr) != asynSuccess) && (retry_count < 5)){
- epicsThreadSleepQuantum();
+ epicsThreadSleep(0.1);
++retry_count;
}
if (retry_count > 4){
@@ -635,9 +642,9 @@ void omsBaseController::omsPoller()
}
/* read all axis status values and reset done-field
- * MDNN,MDNN,PNLN,PNNN,PNLN,PNNN,PNNN,PNNN*/
+ * MDNN,MDNN,PNLN,PNNN,PNLN,PNNN,PNNN,PNNN */
if (getAxesStatus(statusBuffer, sizeof(statusBuffer), &moveDone) != asynSuccess){
- Debug(1, "%s:%s:%s: error reading axes status\n", driverName, functionName, this->portName);
+ Debug(1, "%s:%s:%s: error reading axes status\n", driverName, functionName, this->portName);
++loopBreakCount;
continue;
}
@@ -668,24 +675,18 @@ void omsBaseController::omsPoller()
Debug(1,"%s:%s:%s: Error reading encoder status buffer >%s<\n", driverName, functionName, this->portName, encStatusBuffer);
}
- /* read all limits */
- if (moveDone || (anyMoving == 0))
- haveLimits = true;
- else
- haveLimits = false;
+ haveLimits = true;
limitFlags =0;
- if (haveLimits){
- if ((sendReceiveLock((char*) "AM;QL;", pollInputBuffer, sizeof(pollInputBuffer)) == asynSuccess)){
- if (1 != sscanf(pollInputBuffer, "%x", &limitFlags)){
- Debug(1,"%s:%s:%s: error converting limits: %s\n", driverName, functionName, this->portName, pollInputBuffer);
- haveLimits = false;
- }
- }
- else {
- haveLimits = false;
- Debug(1,"%s:%s:%s: error reading limits %s\n", driverName, functionName, this->portName, pollInputBuffer);
- }
- }
+ if ((sendReceiveLock((char*) "AM;QL;", pollInputBuffer, sizeof(pollInputBuffer)) == asynSuccess)){
+ if (1 != sscanf(pollInputBuffer, "%x", &limitFlags)){
+ Debug(1,"%s:%s:%s: error converting limits: %s\n", driverName, functionName, this->portName, pollInputBuffer);
+ haveLimits = false;
+ }
+ }
+ else {
+ haveLimits = false;
+ Debug(1,"%s:%s:%s: error reading limits %s\n", driverName, functionName, this->portName, pollInputBuffer);
+ }
if (enabled) watchdogOK();
anyMoving = 0;
@@ -715,33 +716,42 @@ void omsBaseController::omsPoller()
/* check the done flag or current velocity */
if (statusBuffer[i*STATUSSTRINGLEN + 1] == 'D'){
- Debug(3, "%s:%s:%s: found Done Flag axis %d\n", driverName, functionName, portName, i);
+ Debug(8, "%s:%s:%s: found Done Flag axis %d\n", driverName, functionName, portName, i);
pAxis->setIntegerParam(motorStatusProblem_, 0);
pAxis->moveDelay=0;
pAxis->setIntegerParam(motorStatusDone_, 1);
pAxis->setIntegerParam(motorStatusMoving_, 0);
if (pAxis->homing) pAxis->homing = 0;
- Debug(1, "%s:%s:%s: done axis %d \n", driverName, functionName,
- this->portName, i );
}
else if (haveVeloArray && (veloArr[i] == 0)){
- /* keep a small delay here, to make sure that a motorAxisDone cycle is performed
- even if the motor is on hard limits */
getIntegerParam(pAxis->axisNo_, motorStatusMoving_, &axisMoving);
if (axisMoving){
- pAxis->moveDelay++ ;
- if (pAxis->moveDelay >= 5) {
- Debug(4, "%s:%s:%s: setting Problem Flag axis %d\n", driverName, functionName, portName, i);
+ if (statusBuffer[i*STATUSSTRINGLEN + 2] == 'L'){
+ pAxis->setIntegerParam(motorStatusProblem_, 0);
+ pAxis->moveDelay=0;
pAxis->setIntegerParam(motorStatusDone_, 1);
pAxis->setIntegerParam(motorStatusMoving_, 0);
- pAxis->setIntegerParam(motorStatusProblem_, 1);
- pAxis->moveDelay = 0;
if (pAxis->homing) pAxis->homing = 0;
- Debug(1, "%s:%s:%s: stop axis %d, moveDelay count %d\n", driverName, functionName,
- this->portName, i, pAxis->moveDelay );
+ if (statusBuffer[i*STATUSSTRINGLEN + 2] == 'P')
+ pAxis->setIntegerParam(motorStatusHighLimit_, 1);
+ else
+ pAxis->setIntegerParam(motorStatusLowLimit_, 1);
+ }
+ else {
+ pAxis->moveDelay++ ;
+ if (pAxis->moveDelay >= 5) {
+ Debug(4, "%s:%s:%s: setting Problem Flag axis %d\n", driverName, functionName, portName, i);
+ pAxis->setIntegerParam(motorStatusDone_, 1);
+ pAxis->setIntegerParam(motorStatusMoving_, 0);
+ pAxis->setIntegerParam(motorStatusProblem_, 1);
+ pAxis->moveDelay = 0;
+ if (pAxis->homing) pAxis->homing = 0;
+ Debug(1, "%s:%s:%s: stop axis %d, moveDelay count %d\n", driverName, functionName,
+ this->portName, i, pAxis->moveDelay );
+ }
+ Debug(2, "%s:%s:%s: moveDelay axis %d, count %d\n", driverName, functionName,
+ this->portName, i, pAxis->moveDelay );
}
- Debug(2, "%s:%s:%s: moveDelay axis %d, count %d\n", driverName, functionName,
- this->portName, i, pAxis->moveDelay );
}
}
else {
@@ -756,11 +766,13 @@ void omsBaseController::omsPoller()
/* check limits */
if (haveLimits){
- if (((limitFlags & (1 << i)) > 0) ^ (pAxis->getLimitInvert()))
- pAxis->setIntegerParam(motorStatusLowLimit_, 1);
+ int limitOffset = 0;
+ if (i > 7) limitOffset = 8; // same as limitOffset = 16 ; i -= 8
+ if (((limitFlags & (1 << (i+limitOffset))) > 0) ^ (pAxis->getLimitInvert()))
+ pAxis->setIntegerParam(motorStatusLowLimit_, 1);
else
pAxis->setIntegerParam(motorStatusLowLimit_, 0);
- if (((limitFlags & (1 << (i+8))) > 0) ^ (pAxis->getLimitInvert()))
+ if (((limitFlags & (1 << (i+limitOffset+8))) > 0) ^ (pAxis->getLimitInvert()))
pAxis->setIntegerParam(motorStatusHighLimit_, 1);
else
pAxis->setIntegerParam(motorStatusHighLimit_, 0);
@@ -810,7 +822,7 @@ void omsBaseController::omsPoller()
waiting may be interrupted by pollEvent or interrupt messages*/
epicsTimeGetCurrent(&now);
timeToWait = timeout - epicsTimeDiffInSeconds(&now, &loopStart);
- Debug(5, "%s:%s:%s: poller loop: waiting %f s\n", driverName, functionName, this->portName, timeToWait);
+ Debug(16, "%s:%s:%s: poller loop: waiting %f s\n", driverName, functionName, this->portName, timeToWait);
if (waitInterruptible(timeToWait) == epicsEventWaitOK) {
fastPolls = forcedFastPolls;
}
@@ -959,6 +971,7 @@ asynStatus omsBaseController::sendOnlyLock(const char *outputBuff)
asynStatus omsBaseController::sendReceiveLock(const char *outputBuff, char *inputBuff, unsigned int inputSize)
{
asynStatus status;
+ if (inputSize > 0) inputBuff[0] = '\0';
baseMutex->lock();
status = sendReceive(outputBuff, inputBuff, inputSize);
baseMutex->unlock();
diff --git a/motorApp/OmsAsynSrc/omsBaseController.h b/motorApp/OmsAsynSrc/omsBaseController.h
index 2fa166fe..79a7c08d 100644
--- a/motorApp/OmsAsynSrc/omsBaseController.h
+++ b/motorApp/OmsAsynSrc/omsBaseController.h
@@ -27,7 +27,7 @@ HeadURL: $URL$
#include "omsBaseAxis.h"
#include