From 16564011a6b5ff0886d4b14588adecaad77b5946 Mon Sep 17 00:00:00 2001 From: smathis Date: Wed, 19 Mar 2025 15:06:45 +0100 Subject: [PATCH] Added stop and error reset function for masterMacs --- Makefile | 2 +- src/masterMacsAxis.cpp | 24 +++++++++++++++++++++++- src/masterMacsAxis.h | 26 +++++++++++++++++--------- src/masterMacsController.cpp | 9 ++++++--- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 7dd9222..fa60d1a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ REQUIRED+=sinqMotor motorBase_VERSION=7.2.2 # Specify the version of sinqMotor we want to build against -sinqMotor_VERSION=mathis_s +sinqMotor_VERSION=0.9.0 # These headers allow to depend on this library for derived drivers. HEADERS += src/masterMacsAxis.h diff --git a/src/masterMacsAxis.cpp b/src/masterMacsAxis.cpp index b282abd..8516120 100644 --- a/src/masterMacsAxis.cpp +++ b/src/masterMacsAxis.cpp @@ -593,7 +593,7 @@ asynStatus masterMacsAxis::doPoll(bool *moving) { keyError, true, pC_->asynUserSelf())) { asynPrint(pC_->asynUserSelf(), ASYN_TRACE_ERROR, "Controller \"%s\", axis %d => %s, line " - "%d\n%s.%s\n", + "%d\n%s%s\n", pC_->portName, axisNo_, __PRETTY_FUNCTION__, __LINE__, shellMessage, pC_->getMsgPrintControl().getSuffix()); @@ -894,6 +894,28 @@ asynStatus masterMacsAxis::stop(double acceleration) { return rw_status; } +asynStatus masterMacsAxis::reset() { + // Status of read-write-operations of ASCII commands to the controller + asynStatus rw_status = asynSuccess; + + // Status of parameter library operations + asynStatus pl_status = asynSuccess; + + // ========================================================================= + + rw_status = pC_->write(axisNo_, 17, ""); + if (rw_status != asynSuccess) { + pl_status = setIntegerParam(pC_->motorStatusProblem(), true); + if (pl_status != asynSuccess) { + return pC_->paramLibAccessFailed(pl_status, "motorStatusProblem_", + axisNo_, __PRETTY_FUNCTION__, + __LINE__); + } + } + + return rw_status; +} + /* Home the axis. On absolute encoder systems, this is a no-op */ diff --git a/src/masterMacsAxis.h b/src/masterMacsAxis.h index 1fa0182..98c55cb 100644 --- a/src/masterMacsAxis.h +++ b/src/masterMacsAxis.h @@ -24,15 +24,6 @@ class masterMacsAxis : public sinqAxis { */ virtual ~masterMacsAxis(); - /** - * @brief Implementation of the `stop` function from asynMotorAxis - * - * @param acceleration Acceleration ACCEL from the motor record. This - * value is currently not used. - * @return asynStatus - */ - asynStatus stop(double acceleration); - /** * @brief Implementation of the `doHome` function from sinqAxis. The * parameters are described in the documentation of `sinqAxis::doHome`. @@ -69,6 +60,23 @@ class masterMacsAxis : public sinqAxis { asynStatus doMove(double position, int relative, double min_velocity, double max_velocity, double acceleration); + /** + * @brief Implementation of the `stop` function from asynMotorAxis + * + * @param acceleration Acceleration ACCEL from the motor record. This + * value is currently not used. + * @return asynStatus + */ + asynStatus stop(double acceleration); + + /** + * @brief Reset the axis error + * + * @param on + * @return asynStatus + */ + asynStatus reset(); + /** * @brief Readout of some values from the controller at IOC startup * diff --git a/src/masterMacsController.cpp b/src/masterMacsController.cpp index 43dacf1..6d18652 100644 --- a/src/masterMacsController.cpp +++ b/src/masterMacsController.cpp @@ -162,12 +162,15 @@ asynStatus masterMacsController::writeRead(int axisNo, int tcpCmd, return asynError; } - // TODO: CR at the end if (isRead) { snprintf(fullCommand, MAXBUF_ - 1, "%dR%02d\x0D", axisNo, tcpCmd); } else { - snprintf(fullCommand, MAXBUF_ - 1, "%dS%02d=%s\x0D", axisNo, tcpCmd, - payload); + if (strlen(payload) == 0) { + snprintf(fullCommand, MAXBUF_ - 1, "%dS%02d\x0D", axisNo, tcpCmd); + } else { + snprintf(fullCommand, MAXBUF_ - 1, "%dS%02d=%s\x0D", axisNo, tcpCmd, + payload); + } } // Calculate the command length