Change to latest sinqMotor version

This commit is contained in:
2025-05-23 09:25:58 +02:00
parent a11d10cb6c
commit a758db1211
3 changed files with 34 additions and 25 deletions

View File

@ -93,8 +93,8 @@ turboPmacAxis::turboPmacAxis(turboPmacController *pC, int axisNo,
} }
// Default values for the watchdog timeout mechanism // Default values for the watchdog timeout mechanism
offsetMovTimeout_ = 30; // seconds setOffsetMovTimeout(30.0); // seconds
scaleMovTimeout_ = 2.0; setScaleMovTimeout(2.0);
} }
turboPmacAxis::~turboPmacAxis(void) { turboPmacAxis::~turboPmacAxis(void) {
@ -166,7 +166,7 @@ asynStatus turboPmacAxis::init() {
&motorVmax, &motorVelocity, &motorAccel, &acoDelay); &motorVmax, &motorVelocity, &motorAccel, &acoDelay);
// The acoDelay is given in milliseconds -> Convert to seconds, rounded up // The acoDelay is given in milliseconds -> Convert to seconds, rounded up
offsetMovTimeout_ = std::ceil(acoDelay / 1000.0); setOffsetMovTimeout(std::ceil(acoDelay / 1000.0));
// The PMAC electronic specifies the acceleration in m/s^2. Since we // The PMAC electronic specifies the acceleration in m/s^2. Since we
// otherwise work with the base length mm, the acceleration is converted // otherwise work with the base length mm, the acceleration is converted
@ -1005,6 +1005,10 @@ asynStatus turboPmacAxis::stop(double acceleration) {
} }
} }
// Reset the driver to idle state and move out of the handshake wait loop,
// if we're currently inside it.
waitForHandshake_ = false;
return rw_status; return rw_status;
} }
@ -1039,6 +1043,10 @@ asynStatus turboPmacAxis::doReset() {
} }
} }
// Reset the driver to idle state and move out of the handshake wait loop,
// if we're currently inside it.
waitForHandshake_ = false;
return rw_status; return rw_status;
} }

View File

@ -55,7 +55,7 @@ turboPmacController::turboPmacController(const char *portName,
// Maximum allowed number of subsequent timeouts before the user is // Maximum allowed number of subsequent timeouts before the user is
// informed. // informed.
maxSubsequentTimeouts_ = 10; setMaxSubsequentTimeouts(10);
// ========================================================================= // =========================================================================
// Create additional parameter library entries // Create additional parameter library entries
@ -100,7 +100,7 @@ turboPmacController::turboPmacController(const char *portName,
const char *message_from_device = const char *message_from_device =
"\006"; // Hex-code for ACK (acknowledge) -> Each message from the MCU "\006"; // Hex-code for ACK (acknowledge) -> Each message from the MCU
// is terminated by this value // is terminated by this value
status = pasynOctetSyncIO->setInputEos(pasynOctetSyncIOipPort_, status = pasynOctetSyncIO->setInputEos(pasynOctetSyncIOipPort(),
message_from_device, message_from_device,
strlen(message_from_device)); strlen(message_from_device));
if (status != asynSuccess) { if (status != asynSuccess) {
@ -109,7 +109,7 @@ turboPmacController::turboPmacController(const char *portName,
"(setting input EOS failed with %s).\nTerminating IOC", "(setting input EOS failed with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__, portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status)); stringifyAsynStatus(status));
pasynOctetSyncIO->disconnect(pasynOctetSyncIOipPort_); pasynOctetSyncIO->disconnect(pasynOctetSyncIOipPort());
exit(-1); exit(-1);
} }
@ -121,7 +121,7 @@ turboPmacController::turboPmacController(const char *portName,
"with %s).\nTerminating IOC", "with %s).\nTerminating IOC",
portName, __PRETTY_FUNCTION__, __LINE__, portName, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status)); stringifyAsynStatus(status));
pasynOctetSyncIO->disconnect(pasynOctetSyncIOipPort_); pasynOctetSyncIO->disconnect(pasynOctetSyncIOipPort());
exit(-1); exit(-1);
} }
@ -222,13 +222,13 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
if (status == asynTimeout) { if (status == asynTimeout) {
if (msgPrintControl_.shouldBePrinted(comKey, true, pasynUser())) { if (getMsgPrintControl().shouldBePrinted(comKey, true, pasynUser())) {
asynPrint( asynPrint(
this->pasynUser(), ASYN_TRACE_ERROR, this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nTimeout while " "Controller \"%s\", axis %d => %s, line %d\nTimeout while "
"writing to the controller. Retrying ...%s\n", "writing to the controller. Retrying ...%s\n",
portName, axisNo, __PRETTY_FUNCTION__, __LINE__, portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
msgPrintControl_.getSuffix()); getMsgPrintControl().getSuffix());
} }
timeoutStatus = checkComTimeoutWatchdog(axisNo, drvMessageText, timeoutStatus = checkComTimeoutWatchdog(axisNo, drvMessageText,
@ -239,7 +239,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
checkMaxSubsequentTimeouts(timeoutCounter, axis); checkMaxSubsequentTimeouts(timeoutCounter, axis);
timeoutCounter += 1; timeoutCounter += 1;
if (maxSubsequentTimeoutsExceeded_) { if (maxSubsequentTimeoutsExceeded()) {
break; break;
} }
@ -255,16 +255,16 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
} }
} }
} else if (status != asynSuccess) { } else if (status != asynSuccess) {
if (msgPrintControl_.shouldBePrinted(comKey, true, pasynUser())) { if (getMsgPrintControl().shouldBePrinted(comKey, true, pasynUser())) {
asynPrint( asynPrint(
this->pasynUser(), ASYN_TRACE_ERROR, this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nError %s while " "Controller \"%s\", axis %d => %s, line %d\nError %s while "
"writing to the controller.%s\n", "writing to the controller.%s\n",
portName, axisNo, __PRETTY_FUNCTION__, __LINE__, portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
stringifyAsynStatus(status), msgPrintControl_.getSuffix()); stringifyAsynStatus(status), getMsgPrintControl().getSuffix());
} }
} else { } else {
msgPrintControl_.resetCount(comKey, pasynUser()); getMsgPrintControl().resetCount(comKey, pasynUser());
} }
if (timeoutStatus == asynError) { if (timeoutStatus == asynError) {
@ -301,16 +301,17 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
"string detected\"). Please call the support.", "string detected\"). Please call the support.",
reasonStringified); reasonStringified);
if (msgPrintControl_.shouldBePrinted(terminateKey, true, pasynUser())) { if (getMsgPrintControl().shouldBePrinted(terminateKey, true,
pasynUser())) {
asynPrint(this->pasynUser(), ASYN_TRACE_ERROR, asynPrint(this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nMessage " "Controller \"%s\", axis %d => %s, line %d\nMessage "
"terminated due to reason %s.%s\n", "terminated due to reason %s.%s\n",
portName, axisNo, __PRETTY_FUNCTION__, __LINE__, portName, axisNo, __PRETTY_FUNCTION__, __LINE__,
reasonStringified, msgPrintControl_.getSuffix()); reasonStringified, getMsgPrintControl().getSuffix());
} }
} else { } else {
msgPrintControl_.resetCount(terminateKey, pasynUser()); getMsgPrintControl().resetCount(terminateKey, pasynUser());
} }
/* /*
@ -327,15 +328,15 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
if (numExpectedResponses != numReceivedResponses) { if (numExpectedResponses != numReceivedResponses) {
adjustResponseForPrint(modResponse, response, MAXBUF_); adjustResponseForPrint(modResponse, response, MAXBUF_);
if (msgPrintControl_.shouldBePrinted(numResponsesKey, true, if (getMsgPrintControl().shouldBePrinted(numResponsesKey, true,
pasynUser())) { pasynUser())) {
asynPrint( asynPrint(
this->pasynUser(), ASYN_TRACE_ERROR, this->pasynUser(), ASYN_TRACE_ERROR,
"Controller \"%s\", axis %d => %s, line %d\nUnexpected " "Controller \"%s\", axis %d => %s, line %d\nUnexpected "
"response '%s' (carriage returns are replaced with spaces) " "response '%s' (carriage returns are replaced with spaces) "
"for command %s.%s\n", "for command %s.%s\n",
portName, axisNo, __PRETTY_FUNCTION__, __LINE__, modResponse, portName, axisNo, __PRETTY_FUNCTION__, __LINE__, modResponse,
command, msgPrintControl_.getSuffix()); command, getMsgPrintControl().getSuffix());
} }
snprintf(drvMessageText, sizeof(drvMessageText), snprintf(drvMessageText, sizeof(drvMessageText),
@ -345,7 +346,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
modResponse, command); modResponse, command);
status = asynError; status = asynError;
} else { } else {
msgPrintControl_.resetCount(numResponsesKey, pasynUser()); getMsgPrintControl().resetCount(numResponsesKey, pasynUser());
} }
// Create custom error messages for different failure modes, if no error // Create custom error messages for different failure modes, if no error
@ -384,15 +385,15 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
paramLibStatus = paramLibStatus =
getIntegerParam(axisNo, motorStatusProblem_, &motorStatusProblem); getIntegerParam(axisNo, motorStatusProblem_, &motorStatusProblem);
if (paramLibStatus != asynSuccess) { if (paramLibStatus != asynSuccess) {
return paramLibAccessFailed(paramLibStatus, "motorStatusProblem_", return paramLibAccessFailed(paramLibStatus, "motorStatusProblem",
axisNo, __PRETTY_FUNCTION__, __LINE__); axisNo, __PRETTY_FUNCTION__, __LINE__);
} }
if (motorStatusProblem == 0) { if (motorStatusProblem == 0) {
paramLibStatus = paramLibStatus =
axis->setStringParam(motorMessageText_, drvMessageText); axis->setStringParam(motorMessageText(), drvMessageText);
if (paramLibStatus != asynSuccess) { if (paramLibStatus != asynSuccess) {
return paramLibAccessFailed(paramLibStatus, "motorMessageText_", return paramLibAccessFailed(paramLibStatus, "motorMessageText",
axisNo, __PRETTY_FUNCTION__, axisNo, __PRETTY_FUNCTION__,
__LINE__); __LINE__);
} }
@ -407,7 +408,7 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
paramLibStatus = axis->setIntegerParam(motorStatusProblem_, 1); paramLibStatus = axis->setIntegerParam(motorStatusProblem_, 1);
if (paramLibStatus != asynSuccess) { if (paramLibStatus != asynSuccess) {
return paramLibAccessFailed(paramLibStatus, return paramLibAccessFailed(paramLibStatus,
"motorStatusCommsError_", axisNo, "motorStatusCommsError", axisNo,
__PRETTY_FUNCTION__, __LINE__); __PRETTY_FUNCTION__, __LINE__);
} }
} }