From 03de78716ff914dbdc82a78a95a09eb9035563df Mon Sep 17 00:00:00 2001 From: Davide Marcato Date: Tue, 24 Sep 2019 14:57:10 +0200 Subject: [PATCH] Fixing uint conversion on gcc4.8 (centos) --- beckMotorApp/BeckhoffSrc/BeckController.cpp | 36 ++++++++++----------- beckMotorApp/BeckhoffSrc/BeckController.h | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/beckMotorApp/BeckhoffSrc/BeckController.cpp b/beckMotorApp/BeckhoffSrc/BeckController.cpp index 7f0288f..2a92cbd 100644 --- a/beckMotorApp/BeckhoffSrc/BeckController.cpp +++ b/beckMotorApp/BeckhoffSrc/BeckController.cpp @@ -210,8 +210,8 @@ asynStatus BeckController::readUInt32DigitalArray(asynInt32ArrayClient *client, * writes only if necessary: a read is always performed * to avoid useless writings to static memory */ -bool BeckController::writeWithPassword(asynInt32ArrayClient *client, int *value, uint mask, size_t nElem, const char *regName) { - asynPrint(pasynUserSelf, ASYN_TRACE_BECK,"-%s(%p, %p, %d, %ld, %s)\n", __FUNCTION__, client, value, mask, nElem, regName); +bool BeckController::writeWithPassword(asynInt32ArrayClient *client, int *value, uint mask, int nElem, const char *regName) { + asynPrint(pasynUserSelf, ASYN_TRACE_BECK,"-%s(%p, %p, %d, %d, %s)\n", __FUNCTION__, client, value, mask, nElem, regName); int password[numAxes_]; int oldValue[nElem]; @@ -250,8 +250,8 @@ bool BeckController::writeWithPassword(asynInt32ArrayClient *client, int *value, /** * write the same value on all the registers pointed by a client */ -bool BeckController::writeWithPassword(asynInt32ArrayClient *client, int value, uint mask, size_t nElem, const char *regName) { - asynPrint(pasynUserSelf, ASYN_TRACE_BECK,"-%s(%p, %d, %d, %ld, %s)\n", __FUNCTION__, client, value, mask, nElem, regName); +bool BeckController::writeWithPassword(asynInt32ArrayClient *client, int value, uint mask, int nElem, const char *regName) { + asynPrint(pasynUserSelf, ASYN_TRACE_BECK,"-%s(%p, %d, %d, %d, %s)\n", __FUNCTION__, client, value, mask, nElem, regName); int values[nElem]; std::fill_n(values, nElem, value); return writeWithPassword(client, values, mask, nElem, regName); @@ -283,7 +283,7 @@ asynStatus BeckController::init(int firstAxis, int lastAxis, bool encoder, bool asynInt32ArrayClient *r46 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R46"); asynInt32ArrayClient *r52 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R52"); - size_t axisLen = lastAxis - firstAxis +1; + int axisLen = lastAxis - firstAxis +1; //reset precedent errors by putting 0 -> 1 -> 0 to bit 0x40 of control byte //and stop all the axis by putting 0 -> 1 -> 0 to bit 0x2 of control byte @@ -338,7 +338,7 @@ asynStatus BeckController::initStepResolution(int firstAxis, int lastAxis, int m asynInt32ArrayClient *r46 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R46"); asynInt32ArrayClient *r33 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R33"); - size_t axisLen = lastAxis - firstAxis +1; + int axisLen = lastAxis - firstAxis +1; int tobewritten[axisLen]; if (microstepPerStep>0) { @@ -390,7 +390,7 @@ asynStatus BeckController::initCurrents(int firstAxis, int lastAxis, double maxA asynInt32ArrayClient *r43 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R43"); asynInt32ArrayClient *r44 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R44"); - size_t axisLen = lastAxis - firstAxis +1; + int axisLen = lastAxis - firstAxis +1; epicsInt32 termType[numAxes_]; double fullScaleCurr[axisLen]; double setMaxAmp[axisLen]; @@ -400,22 +400,22 @@ asynStatus BeckController::initCurrents(int firstAxis, int lastAxis, double maxA //read controller code and convert ampere to % r_[8]->read(termType, numAxes_, &nIn); - for (size_t i=0; i=0){ if (maxAmp>fullScaleCurr[i]) { - asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02ld Warning: Cannot set max current higher than full scale, reverting to %.2lfA\n", firstAxis+i, fullScaleCurr[i]); + asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02d Warning: Cannot set max current higher than full scale, reverting to %.2lfA\n", firstAxis+i, fullScaleCurr[i]); } percent[i] = round( std::min(maxAmp, fullScaleCurr[i]) / fullScaleCurr[i] *100 ); //enforce here fullScaleCurr as higher limit setMaxAmp[i] = ((double) percent[i])/100.0*fullScaleCurr[i]; @@ -431,9 +431,9 @@ asynStatus BeckController::initCurrents(int firstAxis, int lastAxis, double maxA //R44: Coil current, v = 0 (automatic) (in % to maxAmp) if (autoHoldinCurr>=0) { - for (size_t i=0; isetMaxAmp[i]) { - asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02ld Warning: Cannot set holding current higher than maximum coil current, reverting to %.2lfA\n", firstAxis+i, setMaxAmp[i]); + asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02d Warning: Cannot set holding current higher than maximum coil current, reverting to %.2lfA\n", firstAxis+i, setMaxAmp[i]); } percent[i] = round( std::min(setMaxAmp[i], autoHoldinCurr) / setMaxAmp[i] *100 ); } @@ -442,9 +442,9 @@ asynStatus BeckController::initCurrents(int firstAxis, int lastAxis, double maxA //R42: Coil current, a > ath (in % to maxAmp) if (highAccCurr>=0) { - for (size_t i=0; isetMaxAmp[i]) { - asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02ld Warning: Cannot set over acceleration current higher than maximum coil current, reverting to %.2lfA\n", firstAxis+i, setMaxAmp[i]); + asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02d Warning: Cannot set over acceleration current higher than maximum coil current, reverting to %.2lfA\n", firstAxis+i, setMaxAmp[i]); } percent[i] = round( std::min(setMaxAmp[i], highAccCurr) / setMaxAmp[i] *100 ); } @@ -453,9 +453,9 @@ asynStatus BeckController::initCurrents(int firstAxis, int lastAxis, double maxA //R43: Coil current, a <= ath (in % to maxAmp) if (lowAccCurr>=0) { - for (size_t i=0; isetMaxAmp[i]) { - asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02ld Warning: Cannot set sub acceleration current higher than maximum coil current, reverting to %.2lfA\n\n", firstAxis+i, setMaxAmp[i]); + asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,"-%02d Warning: Cannot set sub acceleration current higher than maximum coil current, reverting to %.2lfA\n\n", firstAxis+i, setMaxAmp[i]); } percent[i] = round( std::min(setMaxAmp[i], lowAccCurr) / setMaxAmp[i] *100 ); } @@ -481,7 +481,7 @@ asynStatus BeckController::initHomingParams(int firstAxis, int lastAxis, int ref asynInt32ArrayClient *r55 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R55"); asynInt32ArrayClient *r56 = new asynInt32ArrayClient(beckDriverPName_, firstAxis, "R56"); - size_t axisLen = lastAxis - firstAxis +1; + int axisLen = lastAxis - firstAxis +1; epicsUInt32 featureReg; writeWithPassword(r55, refPosition & 0xFFFF, NO_MASK, axisLen, "R55 reference position (low word)"); diff --git a/beckMotorApp/BeckhoffSrc/BeckController.h b/beckMotorApp/BeckhoffSrc/BeckController.h index 5934893..4f47287 100644 --- a/beckMotorApp/BeckhoffSrc/BeckController.h +++ b/beckMotorApp/BeckhoffSrc/BeckController.h @@ -150,8 +150,8 @@ class epicsShareClass BeckController : public asynMotorController { asynStatus initStepResolution(int firstAxis, int lastAxis, int microstepPerStep, int stepPerRevolution); asynStatus readUInt32DigitalArray(asynInt32ArrayClient *client, int *value, uint mask, size_t nElements, size_t *nIn); asynStatus writeUInt32DigitalArray(asynInt32ArrayClient *client, int *value, uint mask, size_t nElements); - bool writeWithPassword(asynInt32ArrayClient *client, int value, uint mask, size_t nElem, const char *regName); - bool writeWithPassword(asynInt32ArrayClient *client, int *value, uint mask, size_t nElem, const char *regName); + bool writeWithPassword(asynInt32ArrayClient *client, int value, uint mask, int nElem, const char *regName); + bool writeWithPassword(asynInt32ArrayClient *client, int *value, uint mask, int nElem, const char *regName); bool axisRangeOk(int *begin, int *end); friend class BeckAxis;