Revert "Ctb: allow adc mask enable to be 0 for 1 and 10GbE", and better error message (#751)

* Revert "Ctb: allow adc mask enable to be 0 for 1 and 10GbE (#750)"

This reverts commit a0f250a4876937ebb2a96c8948fdea380625a86e.

* better error message about setting adc mask to 0. Cannot set it to 0 due to ram allocation
This commit is contained in:
maliakal_d 2023-05-22 12:26:07 +02:00 committed by GitHub
parent a0f250a487
commit f0c789dc91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 14 deletions

View File

@ -723,6 +723,10 @@ int getDynamicRange(int *retval) {
} }
int setADCEnableMask(uint32_t mask) { int setADCEnableMask(uint32_t mask) {
if (mask == 0u) {
LOG(logERROR, ("Cannot set 1gb adc mask to 0\n"));
return FAIL;
}
LOG(logINFO, ("Setting adcEnableMask 1G to 0x%08x\n", mask)); LOG(logINFO, ("Setting adcEnableMask 1G to 0x%08x\n", mask));
adcEnableMask_1g = mask; adcEnableMask_1g = mask;
// 1Gb enabled // 1Gb enabled
@ -737,6 +741,10 @@ int setADCEnableMask(uint32_t mask) {
uint32_t getADCEnableMask() { return adcEnableMask_1g; } uint32_t getADCEnableMask() { return adcEnableMask_1g; }
void setADCEnableMask_10G(uint32_t mask) { void setADCEnableMask_10G(uint32_t mask) {
if (mask == 0u) {
LOG(logERROR, ("Cannot set 10gb adc mask to 0\n"));
return;
}
// convert 32 bit mask to 8 bit mask // convert 32 bit mask to 8 bit mask
uint8_t actualMask = 0; uint8_t actualMask = 0;
if (mask != 0) { if (mask != 0) {

View File

@ -4203,19 +4203,28 @@ int set_adc_enable_mask(int file_des) {
#else #else
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
ret = setADCEnableMask(arg); if (arg == 0u) {
if (ret == FAIL) { ret = FAIL;
sprintf(mess, "Could not set 1Gb ADC Enable mask to 0x%x.\n", arg); sprintf(mess,
"Not allowed to set adc mask of 0 due to data readout. \n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
uint32_t retval = getADCEnableMask(); ret = setADCEnableMask(arg);
if (arg != retval) { if (ret == FAIL) {
ret = FAIL; sprintf(mess, "Could not set 1Gb ADC Enable mask to 0x%x.\n",
sprintf(mess, arg);
LOG(logERROR, (mess));
} else {
uint32_t retval = getADCEnableMask();
if (arg != retval) {
ret = FAIL;
sprintf(
mess,
"Could not set 1Gb ADC Enable mask. Set 0x%x, but read " "Could not set 1Gb ADC Enable mask. Set 0x%x, but read "
"0x%x\n", "0x%x\n",
arg, retval); arg, retval);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
}
} }
} }
} }
@ -4254,15 +4263,22 @@ int set_adc_enable_mask_10g(int file_des) {
#else #else
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
setADCEnableMask_10G(arg); if (arg == 0u) {
uint32_t retval = getADCEnableMask_10G();
if (arg != retval) {
ret = FAIL; ret = FAIL;
sprintf(mess, sprintf(mess,
"Could not set 10Gb ADC Enable mask. Set 0x%x, but " "Not allowed to set adc mask of 0 due to data readout \n");
"read 0x%x\n",
arg, retval);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else {
setADCEnableMask_10G(arg);
uint32_t retval = getADCEnableMask_10G();
if (arg != retval) {
ret = FAIL;
sprintf(mess,
"Could not set 10Gb ADC Enable mask. Set 0x%x, but "
"read 0x%x\n",
arg, retval);
LOG(logERROR, (mess));
}
} }
} }
#endif #endif