diff --git a/vmmTblApp/src/vmm_tbl.cpp b/vmmTblApp/src/vmm_tbl.cpp index 5d92ebae0243daecacf2ecaf1118445618d48938..e2c1060cc53f38c1ec14e5c0f457902656f23b3a 100644 --- a/vmmTblApp/src/vmm_tbl.cpp +++ b/vmmTblApp/src/vmm_tbl.cpp @@ -29,6 +29,7 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) { int tmp_val; bool tmp_val_bool; uint8_t tmp_val_uint8; + vmmStatus result = vmmSuccess; int param_index = 0, hyb_index, vmm_index; if (function < FIRST_VMM_PARAM) { @@ -36,16 +37,14 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) { } if (function == vmmRegBankVersion) { - vmmStatus result = this->pVmmAPI->getRegBankVersion(val); - if (result != vmmSuccess) status = asynError; + result = this->pVmmAPI->getRegBankVersion(val); *value = val; goto endOfReadInt32; } if (function == vmmIsAcquiring_) { - vmmStatus result = this->pVmmAPI->isAcquiring(tmp_val_bool); + result = this->pVmmAPI->isAcquiring(tmp_val_bool); printf("Is acquiring: %d\n", tmp_val_bool); - if (result != vmmSuccess) status = asynError; *value = tmp_val_bool; goto endOfReadInt32; } @@ -53,42 +52,42 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) { //Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid. param_index = VecUtils::getIndex(vmmHybSkew_, function); if (param_index >= 0) { - this->pVmmAPI->getSkew(param_index, tmp_val_uint8); + result = this->pVmmAPI->getSkew(param_index, tmp_val_uint8); *value = tmp_val_uint8; goto endOfReadInt32; } param_index = VecUtils::getIndex(vmmHybLinkStatus_, function); if (param_index >= 0) { - this->pVmmAPI->checkLinkStatus(param_index, tmp_val); + result = this->pVmmAPI->checkLinkStatus(param_index, tmp_val); *value = tmp_val; goto endOfReadInt32; } param_index = VecUtils::getIndex(vmmHybWidth_, function); if (param_index >= 0) { - this->pVmmAPI->getWidth(param_index, tmp_val_uint8); + result = this->pVmmAPI->getWidth(param_index, tmp_val_uint8); *value = tmp_val_uint8; goto endOfReadInt32; } param_index = VecUtils::getIndex(vmmHybPolarity_, function); if (param_index >= 0) { - this->pVmmAPI->getHybPolarity(param_index, tmp_val_bool); + result = this->pVmmAPI->getHybPolarity(param_index, tmp_val_bool); *value = tmp_val_bool; goto endOfReadInt32; } param_index = VecUtils::getIndex(vmmADCIDX_, function, hyb_index, vmm_index); if (param_index == 0) { - this->pVmmAPI->getADCIdx(hyb_index, vmm_index, tmp_val); + result = this->pVmmAPI->getADCIdx(hyb_index, vmm_index, tmp_val); *value = tmp_val; goto endOfReadInt32; } param_index = VecUtils::getIndex(vmmADCVAL_, function, hyb_index, vmm_index); if (param_index == 0) { - this->pVmmAPI->readADC(hyb_index, vmm_index, tmp_val); + result = this->pVmmAPI->readADC(hyb_index, vmm_index, tmp_val); *value = tmp_val; goto endOfReadInt32; } @@ -101,11 +100,17 @@ asynStatus VMMTbl::readInt32(asynUser *pasynUser, epicsInt32 *value) { *value = 0; return asynError; } + if (result != vmmSuccess) { + asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, + "%s:%s: Failed to adequately read parameter: %d.\n", + driverName, __FUNCTION__, function); + status = asynError; + } setIntegerParam(function, *value); callParamCallbacks(); - return asynSuccess; + return status; } @@ -114,33 +119,32 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value, int *eomReason) { - int status = asynSuccess; + asynStatus status = asynSuccess; + vmmStatus result; int function = pasynUser->reason; std::string read = ""; /* If this parameter belongs to a base class call its method */ if (function < FIRST_VMM_PARAM) { - status = asynPortDriver::readOctet(pasynUser, value, nChars, nActual, - eomReason); - return (asynStatus)status; + return asynPortDriver::readOctet(pasynUser, value, nChars, nActual, eomReason); } //Search for parameter in all parameter vectors. If found, execute correct function for specific hybrid. int param_index = VecUtils::getIndex(vmmHybFwVersion_, function); if (param_index >= 0) { - this->pVmmAPI->readFwVersion(param_index, read); + result = this->pVmmAPI->readFwVersion(param_index, read); goto endOfReadOctet; } param_index = VecUtils::getIndex(vmmHybId_, function); if (param_index >= 0) { - this->pVmmAPI->readIDChip(param_index, read); + result = this->pVmmAPI->readIDChip(param_index, read); goto endOfReadOctet; } param_index = VecUtils::getIndex(vmmHybGeoPos_, function); if (param_index >= 0) { - this->pVmmAPI->readGeoPos(param_index, read); + result = this->pVmmAPI->readGeoPos(param_index, read); goto endOfReadOctet; } @@ -150,6 +154,12 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value, *nActual = 1; return asynError; } + if (result != vmmSuccess) { + asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, + "%s:%s: Failed to adequately read parameter: %d.\n", + driverName, __FUNCTION__, function); + status = asynError; + } size_t copy_size = std::min(read.size(), nChars); strncpy(value, read.c_str(), copy_size); setStringParam(function, value); @@ -158,7 +168,7 @@ asynStatus VMMTbl::readOctet(asynUser *pasynUser, char *value, *eomReason = ASYN_EOM_END; callParamCallbacks(); - return asynSuccess; + return status; } @@ -266,7 +276,7 @@ asynStatus VMMTbl::createEpicsParams() { asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) { asynStatus status = asynSuccess; - vmmStatus vmm_stat; + vmmStatus vmm_stat = vmmSuccess; bool is_acquiring; int function = pasynUser->reason; int param_index = 0, hyb_index, vmm_index; @@ -293,28 +303,24 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) { param_index = VecUtils::getIndex(vmmHybSkew_, function); if (param_index >= 0) { vmm_stat = this->pVmmAPI->setSkew(param_index, value); - if (vmm_stat != vmmSuccess) status = asynError; goto endOfWriteInt32; } param_index = VecUtils::getIndex(vmmHybWidth_, function); if (param_index >= 0) { vmm_stat = this->pVmmAPI->setWidth(param_index, value); - if (vmm_stat != vmmSuccess) status = asynError; goto endOfWriteInt32; } param_index = VecUtils::getIndex(vmmHybPolarity_, function); if (param_index >= 0) { vmm_stat = this->pVmmAPI->setHybPolarity(param_index, value); - if (vmm_stat != vmmSuccess) status = asynError; goto endOfWriteInt32; } param_index = VecUtils::getIndex(vmmADCIDX_, function, hyb_index, vmm_index); if (param_index == 0) { vmm_stat = this->pVmmAPI->setADCIdx(hyb_index, vmm_index, value); - if (vmm_stat != vmmSuccess) status = asynError; goto endOfWriteInt32; } @@ -322,6 +328,7 @@ asynStatus VMMTbl::writeInt32(asynUser *pasynUser, epicsInt32 value) { if (param_index < 0) { status = asynError; } + if (vmm_stat != vmmSuccess) status = asynError; setIntegerParam(function, value); callParamCallbacks();