@@ -39,7 +39,7 @@ static const char *driverName = "nf874xMotorDriver";
3939 * \param[in] idlePollPeriod The time between polls when no axis is moving
4040 */
4141nf874xController::nf874xController (const char *portName, const char *nf874xPortName, int numAxes,
42- double movingPollPeriod, double idlePollPeriod)
42+ double movingPollPeriod, double idlePollPeriod, double writeOnlyDelay )
4343 // : asynMotorController(portName, numAxes, NUM_nf874x_PARAMS,
4444 : asynMotorController(portName, numAxes+1 , NUM_nf874x_PARAMS,
4545 asynUInt32DigitalMask,
@@ -51,7 +51,12 @@ nf874xController::nf874xController(const char *portName, const char *nf874xPortN
5151 int axis;
5252 asynStatus status;
5353 static const char *functionName = " nf874xController" ;
54-
54+
55+ writeOnlyDelay_ = writeOnlyDelay;
56+ asynPrint (this ->pasynUserSelf , ASYN_TRACE_ERROR ,
57+ " %s:%s: nf874x write-only delay (ms): %lf\n " ,
58+ driverName, functionName, writeOnlyDelay_);
59+
5560 /* Connect to nf874x controller */
5661 status = pasynOctetSyncIO->connect (nf874xPortName, 0 , &pasynUserController_, NULL );
5762 if (status) {
@@ -97,11 +102,12 @@ nf874xController::nf874xController(const char *portName, const char *nf874xPortN
97102 * \param[in] numAxes The number of axes that this controller supports.
98103 * \param[in] movingPollPeriod The time in ms between polls when any axis is moving
99104 * \param[in] idlePollPeriod The time in ms between polls when no axis is moving
105+ * \param[in] writeOnlyDelay The time in ms to sleep before sending a write-only command
100106 */
101107extern " C" int nf874xCreateController (const char *portName, const char *nf874xPortName, int numAxes,
102- int movingPollPeriod, int idlePollPeriod)
108+ int movingPollPeriod, int idlePollPeriod, int writeOnlyDelay )
103109{
104- new nf874xController (portName, nf874xPortName, numAxes, movingPollPeriod/1000 ., idlePollPeriod/1000 .);
110+ new nf874xController (portName, nf874xPortName, numAxes, movingPollPeriod/1000 ., idlePollPeriod/1000 ., writeOnlyDelay/ 1000 . );
105111 return (asynSuccess);
106112}
107113
@@ -137,6 +143,12 @@ nf874xAxis* nf874xController::getAxis(int axisNo)
137143 return static_cast <nf874xAxis*>(asynMotorController::getAxis (axisNo));
138144}
139145
146+ /* * Writes a string to the controller after a delay */
147+ asynStatus nf874xController::writeController ()
148+ {
149+ epicsThreadSleep (writeOnlyDelay_);
150+ return asynMotorController::writeController ();
151+ }
140152
141153/* * Called when asyn clients call pasynInt32->write().
142154 * Extracts the function and axis number from pasynUser.
@@ -461,6 +473,7 @@ asynStatus nf874xAxis::poll(bool *moving)
461473{
462474 int done;
463475 asynStatus comStatus;
476+ static const char *functionName = " poll" ;
464477
465478 // Returned poll values will include the controller id in the response if it was
466479 // supplied as part of the axis name. Skip past the '>' before interpreting the result.
@@ -545,6 +558,13 @@ asynStatus nf874xAxis::poll(bool *moving)
545558 }
546559
547560 skip:
561+
562+ if (comStatus) {
563+ asynPrint (pasynUser_, ASYN_TRACE_ERROR ,
564+ " %s:%s: error, comStatus=%d\n " ,
565+ driverName, functionName, comStatus);
566+ }
567+
548568 setIntegerParam (pC_->motorStatusProblem_ , comStatus ? 1 : 0 );
549569 callParamCallbacks ();
550570 return comStatus ? asynError : asynSuccess;
@@ -598,15 +618,17 @@ static const iocshArg nf874xCreateControllerArg1 = {"nf874x port name", iocshArg
598618static const iocshArg nf874xCreateControllerArg2 = {" Number of axes" , iocshArgInt};
599619static const iocshArg nf874xCreateControllerArg3 = {" Moving poll period (ms)" , iocshArgInt};
600620static const iocshArg nf874xCreateControllerArg4 = {" Idle poll period (ms)" , iocshArgInt};
621+ static const iocshArg nf874xCreateControllerArg5 = {" Write-only delay (ms)" , iocshArgInt};
601622static const iocshArg * const nf874xCreateControllerArgs[] = {&nf874xCreateControllerArg0,
602623 &nf874xCreateControllerArg1,
603624 &nf874xCreateControllerArg2,
604625 &nf874xCreateControllerArg3,
605- &nf874xCreateControllerArg4};
606- static const iocshFuncDef nf874xCreateControllerDef = {" nf874xCreateController" , 5 , nf874xCreateControllerArgs};
626+ &nf874xCreateControllerArg4,
627+ &nf874xCreateControllerArg5};
628+ static const iocshFuncDef nf874xCreateControllerDef = {" nf874xCreateController" , 6 , nf874xCreateControllerArgs};
607629static void nf874xCreateControllerCallFunc (const iocshArgBuf *args)
608630{
609- nf874xCreateController (args[0 ].sval , args[1 ].sval , args[2 ].ival , args[3 ].ival , args[4 ].ival );
631+ nf874xCreateController (args[0 ].sval , args[1 ].sval , args[2 ].ival , args[3 ].ival , args[4 ].ival , args[ 5 ]. ival );
610632}
611633
612634static void nf874xMotorRegister (void )
0 commit comments