Test timing problem

This commit is contained in:
2025-07-24 09:40:52 +02:00
parent 338b4d61b4
commit a980740fd5
2 changed files with 18 additions and 24 deletions

View File

@@ -13,6 +13,15 @@
#include <unistd.h>
#include <vector>
#include <sys/time.h>
long long timeInMilliseconds(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return (((long long)tv.tv_sec) * 1000) + (tv.tv_usec / 1000);
}
struct turboPmacAxisImpl {
bool waitForHandshake;
time_t timeAtHandshake;
@@ -739,6 +748,9 @@ asynStatus turboPmacAxis::doMove(double position, int relative,
double minVelocity, double maxVelocity,
double acceleration) {
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Received move command at %lli\n", timeInMilliseconds());
// Status of read-write-operations of ASCII commands to the controller
asynStatus status = asynSuccess;
@@ -886,14 +898,8 @@ asynStatus turboPmacAxis::doReset() {
// if we're currently inside it.
pTurboPmacA_->waitForHandshake = false;
// Disable the axis, if it is not in a moving state
int axStat = pTurboPmacA_->axisStatus;
if (axStat == 0 || axStat == -6) {
snprintf(command, sizeof(command), "M%2.2d14=0", axisNo_);
status = pC_->writeRead(axisNo_, command, response, 0);
}
return status;
// Disable the axis
return enable(false);
}
/*
@@ -1143,6 +1149,10 @@ asynStatus turboPmacAxis::enable(bool on) {
bool moving = false;
// Perform a poll to update the parameter library
poll(&moving);
asynPrint(pC_->pasynUser(), ASYN_TRACE_ERROR,
"Finished enable %i at %lli\n", on, timeInMilliseconds());
return asynSuccess;
}
}

View File

@@ -254,22 +254,6 @@ asynStatus turboPmacController::writeRead(int axisNo, const char *command,
pasynOctetSyncIOipPort(), command, commandLength, response, MAXBUF_,
pTurboPmacC_->comTimeout, &nbytesOut, &nbytesIn, &eomReason);
/*
If sth. is written to the controller, it needs some time to process the
command. However, the controller returns the acknowledgment via
pasynOctetSyncIO->writeRead immediately, signalling to the driver that it is
ready to receive the next command. In practice, this can result in commands
getting discarded on the driver side or in bringing the driver in undefined
states (e.g. stuck in status 1).
To prevent this, we wait for 20 ms after a write command to give the
controller enough time to process everything. A write command can be
identified by looking for the equal sign.
*/
if (strchr(command, '=')) {
usleep(20000);
}
msgPrintControlKey comKey =
msgPrintControlKey(portName, axisNo, __PRETTY_FUNCTION__, __LINE__);