ao.c: set proper bounds for Analog_Output_Present_Value_Set and Analog_Output_Present_Value_Write (#575)
* ao.c: set proper bounds for Analog_Output_Present_Value_Write The lower and upper bounds to the value passed to this function were hard-coded to 0 and 100 respectively. This meant that a client was not able to write a value outside of these bounds, regardless of the values of `Min_Pres_Value` and `Max_Pres_Value`. Now properly compare the new value against `Min_Pres_Value` and `Max_Pres_Value` and only return `ERROR_CODE_VALUE_OUT_OF_RANGE` when it is outside of this range. Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr> * ao.c: make Analog_Output_Present_Value_Set return 0 when out of range Compare the new value passsed to `Analog_Output_Present_Value_Set` against `Min_Pres_Value` and `Max_Pres_Value`. If the new value is outside of these bounds, don't update the present value and return false. Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr> --------- Signed-off-by: Sebastian Weyer <sebastian.weyer@smile.fr> Co-authored-by: Sebastian Weyer <sebastian.weyer@smile.fr>
This commit is contained in:
@@ -340,7 +340,8 @@ bool Analog_Output_Present_Value_Set(
|
||||
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
if ((priority >= 1) && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
if ((priority >= 1) && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
value >= pObject->Min_Pres_Value && value <= pObject->Max_Pres_Value) {
|
||||
pObject->Relinquished[priority - 1] = false;
|
||||
pObject->Priority_Array[priority - 1] = value;
|
||||
Analog_Output_Present_Value_COV_Detect(
|
||||
@@ -402,7 +403,7 @@ static bool Analog_Output_Present_Value_Write(uint32_t object_instance,
|
||||
pObject = Keylist_Data(Object_List, object_instance);
|
||||
if (pObject) {
|
||||
if ((priority >= 1) && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(value >= 0.0) && (value <= 100.0)) {
|
||||
(value >= pObject->Min_Pres_Value) && (value <= pObject->Max_Pres_Value)) {
|
||||
if (priority != 6) {
|
||||
old_value = Analog_Output_Present_Value(object_instance);
|
||||
Analog_Output_Present_Value_Set(
|
||||
|
||||
Reference in New Issue
Block a user