Bugfix/writeproperty app known property (#450)

* Fix write-property app known property option

* Fix write-property app priority handling

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2023-07-13 10:21:21 -05:00
committed by GitHub
parent 4efaf097c0
commit 2bf1e9a548
2 changed files with 25 additions and 16 deletions
+11 -7
View File
@@ -249,7 +249,8 @@ int main(int argc, char *argv[])
char *value_string = NULL;
bool status = false;
int args_remaining = 0, tag_value_arg = 0, i = 0;
BACNET_APPLICATION_TAG property_tag;
long property_tag;
long priority;
uint8_t context_tag = 0;
int argi = 0;
@@ -288,7 +289,12 @@ int main(int argc, char *argv[])
return 1;
}
Target_Object_Property = object_property;
Target_Object_Property_Priority = (uint8_t)strtol(argv[5], NULL, 0);
priority = strtol(argv[5], NULL, 0);
if ((priority < BACNET_MIN_PRIORITY) ||
(priority > BACNET_MAX_PRIORITY)) {
priority = BACNET_NO_PRIORITY;
}
Target_Object_Property_Priority = priority;
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
if (Target_Object_Property_Index == -1) {
Target_Object_Property_Index = BACNET_ARRAY_ALL;
@@ -341,7 +347,7 @@ int main(int argc, char *argv[])
property_tag = bacapp_known_property_tag(
Target_Object_Type, Target_Object_Property);
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
fprintf(stderr, "Error: tag=%ld - it must be less than %u\n",
property_tag, MAX_BACNET_APPLICATION_TAG);
return 1;
}
@@ -354,11 +360,9 @@ int main(int argc, char *argv[])
return 1;
}
} else {
/* FIXME: show the expected entry format for the tag */
fprintf(stderr,
"Error: unable to parse the known property"
" \"%s\"\r\n",
value_string);
"Error: parser for property %s is not implemented\n",
bactext_property_name(Target_Object_Property));
return 1;
}
+14 -9
View File
@@ -279,7 +279,8 @@ int main(int argc, char *argv[])
BACNET_PROPERTY_VALUE *wpm_property;
char *value_string = NULL;
bool status = false;
BACNET_APPLICATION_TAG property_tag;
long property_tag;
long priority;
uint8_t context_tag = 0;
unsigned object_type = 0;
unsigned property_id = 0;
@@ -394,8 +395,12 @@ int main(int argc, char *argv[])
return 1;
}
/* Priority */
wpm_property->priority =
(uint8_t)strtol(argv[tag_value_arg], NULL, 0);
priority = strtol(argv[tag_value_arg], NULL, 0);
if ((priority < BACNET_MIN_PRIORITY) ||
(priority > BACNET_MAX_PRIORITY)) {
priority = BACNET_NO_PRIORITY;
}
wpm_property->priority = priority;
tag_value_arg++;
args_remaining--;
if (Verbose) {
@@ -429,14 +434,15 @@ int main(int argc, char *argv[])
tag_value_arg++;
args_remaining--;
if (Verbose) {
printf("tag=%u value=%s\n", property_tag, value_string);
printf("tag=%ld value=%s\n", property_tag, value_string);
}
if (property_tag < 0) {
property_tag =
bacapp_known_property_tag(wpm_object->object_type,
wpm_property->propertyIdentifier);
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
fprintf(stderr,
"Error: tag=%ld - it must be less than %u\n",
property_tag, MAX_BACNET_APPLICATION_TAG);
return 1;
}
@@ -450,11 +456,10 @@ int main(int argc, char *argv[])
return 1;
}
} else {
/* FIXME: show the expected entry format for the tag */
fprintf(stderr,
"Error: unable to parse the known property"
" \"%s\"\r\n",
value_string);
"Error: parser for property %s is not implemented\n",
bactext_property_name(
wpm_property->propertyIdentifier));
return 1;
}
wpm_property->value.next = NULL;