Changed ReadPropertyMultiple demo example to be able to request multiple properties from the same object. Also removed the array-index parameter (the quad) in favor of bracketing the array index if an array index is desired: 76[0] is the object-list property array index 0. Multiple properties are sent using a comma separating the properties. Updated the --help to show examples of the new forms.
This commit is contained in:
@@ -261,12 +261,17 @@ int main(
|
|||||||
};
|
};
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||||
|
char *property_token = NULL;
|
||||||
|
unsigned property_id = 0;
|
||||||
|
unsigned property_array_index = 0;
|
||||||
|
int scan_count = 0;
|
||||||
|
char *filename = NULL;
|
||||||
|
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
|
filename = filename_remove_path(argv[0]);
|
||||||
printf("Usage: %s device-instance object-type object-instance "
|
printf("Usage: %s device-instance object-type object-instance "
|
||||||
"property index [object-type ...]\r\n",
|
"property[index][,property[index]] [object-type ...]\r\n",
|
||||||
filename_remove_path(argv[0]));
|
filename);
|
||||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||||
printf("device-instance:\r\n"
|
printf("device-instance:\r\n"
|
||||||
"BACnet Device Object Instance number that you are\r\n"
|
"BACnet Device Object Instance number that you are\r\n"
|
||||||
@@ -288,21 +293,30 @@ int main(
|
|||||||
"BACNET_PROPERTY_ID in bacenum.h. It is the property\r\n"
|
"BACNET_PROPERTY_ID in bacenum.h. It is the property\r\n"
|
||||||
"you are reading. For example, if you were reading the\r\n"
|
"you are reading. For example, if you were reading the\r\n"
|
||||||
"Present Value property, use 85 as the property.\r\n"
|
"Present Value property, use 85 as the property.\r\n"
|
||||||
"\r\nindex:\r\n"
|
"\r\n[index]:\r\n"
|
||||||
"This integer parameter is the index number of an array.\r\n"
|
"This optional integer parameter is the index number of \r\n"
|
||||||
"If the property is an array, individual elements can\r\n"
|
"an array property. Individual elements of an array can\r\n"
|
||||||
"be read. If this parameter is missing and the property\r\n"
|
"be read. If this parameter is missing and the property\r\n"
|
||||||
"is an array, the entire array will be read.\r\n"
|
"is an array, the entire array will be read.\r\n"
|
||||||
"\r\nExample:\r\n" "If you want read the ALL property in\r\n"
|
"\r\nExample:\r\n"
|
||||||
|
"If you want read the PRESENT_VALUE property and various\r\n"
|
||||||
|
"array elements of the PRIORITY_ARRAY in Device 123\r\n"
|
||||||
|
"Analog Output object 99, use the following command:\r\n"
|
||||||
|
"%s 123 1 99 85,87[0],87\r\n"
|
||||||
|
"If you want read the PRESENT_VALUE property in objects\r\n"
|
||||||
|
"Analog Input 77 and Analog Input 78 in Device 123\r\n"
|
||||||
|
"use the following command:\r\n"
|
||||||
|
"%s 123 0 77 85 0 78 85\r\n"
|
||||||
|
"If you want read the ALL property in\r\n"
|
||||||
"Device object 123, you would use the following command:\r\n"
|
"Device object 123, you would use the following command:\r\n"
|
||||||
"%s 123 8 123 8 -1\r\n"
|
"%s 123 8 123 8\r\n"
|
||||||
"If you want read the OPTIONAL property in\r\n"
|
"If you want read the OPTIONAL property in\r\n"
|
||||||
"Device object 123, you would use the following command:\r\n"
|
"Device object 123, you would use the following command:\r\n"
|
||||||
"%s 123 8 123 80 -1\r\n"
|
"%s 123 8 123 80\r\n"
|
||||||
"If you want read the REQUIRED property in\r\n"
|
"If you want read the REQUIRED property in\r\n"
|
||||||
"Device object 123, you would use the following command:\r\n"
|
"Device object 123, you would use the following command:\r\n"
|
||||||
"%s 123 8 123 105 -1\r\n", filename_remove_path(argv[0]),
|
"%s 123 8 123 105\r\n",
|
||||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
filename, filename, filename, filename, filename);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -319,12 +333,12 @@ int main(
|
|||||||
args_remaining = (argc - 2);
|
args_remaining = (argc - 2);
|
||||||
arg_sets = 0;
|
arg_sets = 0;
|
||||||
while (rpm_object) {
|
while (rpm_object) {
|
||||||
tag_value_arg = 2 + (arg_sets * 4);
|
tag_value_arg = 2 + (arg_sets * 3);
|
||||||
rpm_object->object_type = strtol(argv[tag_value_arg], NULL, 0);
|
rpm_object->object_type = strtol(argv[tag_value_arg], NULL, 0);
|
||||||
tag_value_arg++;
|
tag_value_arg++;
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (args_remaining <= 0) {
|
if (args_remaining <= 0) {
|
||||||
fprintf(stderr, "Error: not enough object property quads.\r\n");
|
fprintf(stderr, "Error: not enough object property triples.\r\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (rpm_object->object_type >= MAX_BACNET_OBJECT_TYPE) {
|
if (rpm_object->object_type >= MAX_BACNET_OBJECT_TYPE) {
|
||||||
@@ -336,7 +350,7 @@ int main(
|
|||||||
tag_value_arg++;
|
tag_value_arg++;
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (args_remaining <= 0) {
|
if (args_remaining <= 0) {
|
||||||
fprintf(stderr, "Error: not enough object property quads.\r\n");
|
fprintf(stderr, "Error: not enough object property triples.\r\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (rpm_object->object_instance > BACNET_MAX_INSTANCE) {
|
if (rpm_object->object_instance > BACNET_MAX_INSTANCE) {
|
||||||
@@ -346,31 +360,40 @@ int main(
|
|||||||
}
|
}
|
||||||
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
||||||
rpm_object->listOfProperties = rpm_property;
|
rpm_object->listOfProperties = rpm_property;
|
||||||
if (rpm_property) {
|
property_token = strtok(argv[tag_value_arg], ",");
|
||||||
rpm_property->propertyIdentifier =
|
/* add all the properties and optional index to our list */
|
||||||
strtol(argv[tag_value_arg], NULL, 0);
|
while (rpm_property) {
|
||||||
/* used up another arg */
|
scan_count = sscanf(property_token, "%u[%u]",
|
||||||
tag_value_arg++;
|
&property_id,
|
||||||
args_remaining--;
|
&property_array_index);
|
||||||
if (args_remaining <= 0) {
|
if (scan_count > 0) {
|
||||||
fprintf(stderr,
|
rpm_property->propertyIdentifier = property_id;
|
||||||
"Error: not enough object property quads.\r\n");
|
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
||||||
return 1;
|
fprintf(stderr, "property=%u - it must be less than %u\r\n",
|
||||||
|
rpm_property->propertyIdentifier,
|
||||||
|
MAX_BACNET_PROPERTY_ID + 1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
if (scan_count > 1) {
|
||||||
fprintf(stderr, "property=%u - it must be less than %u\r\n",
|
rpm_property->propertyArrayIndex = property_array_index;
|
||||||
rpm_property->propertyIdentifier,
|
} else {
|
||||||
MAX_BACNET_PROPERTY_ID + 1);
|
rpm_property->propertyArrayIndex = BACNET_ARRAY_ALL;
|
||||||
return 1;
|
}
|
||||||
|
/* is there another property? */
|
||||||
|
property_token = strtok(NULL, ",");
|
||||||
|
if (property_token) {
|
||||||
|
rpm_property->next =
|
||||||
|
calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
||||||
|
rpm_property = rpm_property->next;
|
||||||
|
} else {
|
||||||
|
rpm_property->next = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
rpm_property->propertyArrayIndex =
|
|
||||||
strtol(argv[tag_value_arg], NULL, 0);
|
|
||||||
/* note: we are only loading one property for now */
|
|
||||||
rpm_property->next = NULL;
|
|
||||||
/* used up another arg */
|
|
||||||
tag_value_arg++;
|
|
||||||
args_remaining--;
|
|
||||||
}
|
}
|
||||||
|
/* used up another arg */
|
||||||
|
tag_value_arg++;
|
||||||
|
args_remaining--;
|
||||||
if (args_remaining) {
|
if (args_remaining) {
|
||||||
arg_sets++;
|
arg_sets++;
|
||||||
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
||||||
|
|||||||
Reference in New Issue
Block a user