This commit is contained in:
2021-08-11 10:46:20 +02:00
parent c7293f88d0
commit d5a3ddfe7e

View File

@ -6797,52 +6797,60 @@ int set_current_source(int file_des) {
} }
#else #else
int chipVersion = getChipVersion(); int chipVersion = getChipVersion();
if (chipVersion == 11) { if (ret == OK) {
// require both if (chipVersion == 11) {
if ((fix != 0 && fix != 1) || (normal != 0 && normal != 1)) { // require both
ret = FAIL; if ((fix != 0 && fix != 1) ||
strcpy(mess, (normal != 0 && normal != 1)) {
"Could not enable current source. Invalid value for parameters (fix or normal). Options: 0 or 1.\n"); ret = FAIL;
LOG(logERROR, (mess)); strcpy(mess, "Could not enable current source. Invalid "
"or insufficient parameters (fix or "
"normal). or Options: 0 or 1.\n");
LOG(logERROR, (mess));
}
} }
} // chipv1.0
// chipv1.0 else {
else { // require only fix
// require only fix if (fix != 0 && fix != 1) {
if (fix != 0 && fix != 1) { ret = FAIL;
ret = FAIL; strcpy(mess,
strcpy(mess, "Could not enable current source. Invalid value for parameter (fix). Options: 0 or 1.\n");
"Could not enable current source. Invalid value for parameter (fix). Options: 0 or 1.\n"); LOG(logERROR, (mess));
LOG(logERROR, (mess)); } else if (normal != -1) {
} else if (normal != -1) { ret = FAIL;
ret = FAIL; strcpy(mess, "Could not enable current source. Invalid "
strcpy(mess, "parmaeter (normal). Require only fix and "
"Could not enable current source. Invalid parmaeter (normal). Require only fix and select for chipv1.0.\n"); "select for chipv1.0.\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} }
// select can only be 0-63 // select can only be 0-63
else if (select > MAX_SELECT_CHIP10_VAL) { else if (select > MAX_SELECT_CHIP10_VAL) {
ret = FAIL; ret = FAIL;
strcpy(mess, strcpy(mess,
"Could not enable current source. Invalid value for parameter (select). Options: 0-63.\n"); "Could not enable current source. Invalid value "
LOG(logERROR, (mess)); "for parameter (select). Options: 0-63.\n");
LOG(logERROR, (mess));
}
} }
} }
#endif #endif
} }
if (ret == OK) {
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
if (enable == 0) { if (enable == 0) {
disableCurrentSource(); disableCurrentSource();
} else { } else {
enableCurrentSource(fix, select, normal); enableCurrentSource(fix, select, normal);
} }
#else #else
setCurrentSource(enable); setCurrentSource(enable);
#endif #endif
int retval = getCurrentSource(); int retval = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retval)); LOG(logDEBUG1, ("current source enable retval: %u\n", retval));
validate(&ret, mess, enable, retval, "set current source enable", DEC); validate(&ret, mess, enable, retval, "set current source enable", DEC);
}
} }
#endif #endif
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
@ -6863,10 +6871,14 @@ int get_current_source(int file_des) {
retvals[0] = getCurrentSource(); retvals[0] = getCurrentSource();
LOG(logDEBUG1, ("current source enable retval: %u\n", retvals[0])); LOG(logDEBUG1, ("current source enable retval: %u\n", retvals[0]));
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
retvals[1] = getFixCurrentSource(); if (retvals[0]) {
retvals[2] = getNormalCurrentSource(); retvals[1] = getFixCurrentSource();
retval_select = getSelectCurrentSource(); retvals[2] = getNormalCurrentSource();
LOG(logDEBUG1, ("current source parameters retval: [fix:%d, normal:%d, select:%lld]\n", retvals[1], retvals[2], retval_select)); retval_select = getSelectCurrentSource();
}
LOG(logDEBUG1, ("current source parameters retval: [enable:%d fix:%d, "
"normal:%d, select:%lld]\n",
retvals[0], retvals[1], retvals[2], retval_select));
#endif #endif
#endif #endif
Server_SendResult(file_des, INT32, NULL, 0); Server_SendResult(file_des, INT32, NULL, 0);