Changed some plumbing for printing values to handle the case of a Present-Value enumerated property from a proprietary object type.
This commit is contained in:
@@ -304,12 +304,15 @@ static void Init_Service_Handlers(
|
||||
|
||||
bool PrettyPrintPropertyValue(
|
||||
FILE * stream,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
BACNET_PROPERTY_ID property)
|
||||
BACNET_OBJECT_PROPERTY_VALUE *object_value)
|
||||
{
|
||||
BACNET_APPLICATION_DATA_VALUE * value = NULL;
|
||||
bool status = true; /*return value */
|
||||
size_t len = 0, i = 0, j = 0;
|
||||
BACNET_PROPERTY_ID property = PROP_ALL;
|
||||
|
||||
value = object_value->value;
|
||||
property = object_value->object_property;
|
||||
if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) &&
|
||||
((property == PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED) ||
|
||||
(property == PROP_PROTOCOL_SERVICES_SUPPORTED))) {
|
||||
@@ -359,7 +362,7 @@ bool PrettyPrintPropertyValue(
|
||||
} else if (value != NULL) {
|
||||
assert(false); /* How did I get here? Fix your code. */
|
||||
/* Meanwhile, a fallback plan */
|
||||
status = bacapp_print_value(stdout, value, property);
|
||||
status = bacapp_print_value(stdout, object_value);
|
||||
} else
|
||||
fprintf(stream, "? \r\n");
|
||||
|
||||
@@ -376,8 +379,11 @@ bool PrettyPrintPropertyValue(
|
||||
* Value, and Error information.
|
||||
*/
|
||||
void PrintReadPropertyData(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_REFERENCE * rpm_property)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_APPLICATION_DATA_VALUE *value, *old_value;
|
||||
bool print_brace = false;
|
||||
KEY object_list_element;
|
||||
@@ -395,6 +401,8 @@ void PrintReadPropertyData(
|
||||
bactext_error_code_name((int) rpm_property->error.error_code));
|
||||
return;
|
||||
}
|
||||
object_value.object_type = object_type;
|
||||
object_value.object_instance = object_instance;
|
||||
if ((value != NULL) && (value->next != NULL)) {
|
||||
/* Then this is an array of values.
|
||||
* But are we showing Values? We (VTS3) want ? instead of {?,?} to show up. */
|
||||
@@ -425,6 +433,9 @@ void PrintReadPropertyData(
|
||||
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
|
||||
/* value(s) loop until there is no "next" ... */
|
||||
while (value != NULL) {
|
||||
object_value.object_property = rpm_property->propertyIdentifier;
|
||||
object_value.array_index = rpm_property->propertyArrayIndex;
|
||||
object_value.value = value;
|
||||
switch (rpm_property->propertyIdentifier) {
|
||||
/* These are all arrays, so they open and close with braces */
|
||||
case PROP_OBJECT_LIST:
|
||||
@@ -500,8 +511,7 @@ void PrintReadPropertyData(
|
||||
/* If the object is a Sequence, it needs its own bracketing braces */
|
||||
if (isSequence)
|
||||
fprintf(stdout, "{");
|
||||
bacapp_print_value(stdout, value,
|
||||
rpm_property->propertyIdentifier);
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
if (isSequence)
|
||||
fprintf(stdout, "}");
|
||||
|
||||
@@ -518,8 +528,7 @@ void PrintReadPropertyData(
|
||||
|
||||
case PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED:
|
||||
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
||||
PrettyPrintPropertyValue(stdout, value,
|
||||
rpm_property->propertyIdentifier);
|
||||
PrettyPrintPropertyValue(stdout, &object_value);
|
||||
break;
|
||||
|
||||
/* Our special non-existent case; do nothing further here. */
|
||||
@@ -552,8 +561,7 @@ void PrintReadPropertyData(
|
||||
}
|
||||
/* Else, fall through and print value: */
|
||||
default:
|
||||
bacapp_print_value(stdout, value,
|
||||
rpm_property->propertyIdentifier);
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
break;
|
||||
}
|
||||
if (value->next != NULL) {
|
||||
@@ -722,7 +730,10 @@ EPICS_STATES ProcessRPMData(
|
||||
fprintf(stdout, " ");
|
||||
Print_Property_Identifier(rpm_property->propertyIdentifier);
|
||||
fprintf(stdout, ": ");
|
||||
PrintReadPropertyData(rpm_property);
|
||||
PrintReadPropertyData(
|
||||
rpm_data->object_type,
|
||||
rpm_data->object_instance,
|
||||
rpm_property);
|
||||
}
|
||||
old_rpm_property = rpm_property;
|
||||
rpm_property = rpm_property->next;
|
||||
@@ -1097,9 +1108,10 @@ int main(
|
||||
(invoke_id ==
|
||||
Read_Property_Multiple_Data.service_data.invoke_id)) {
|
||||
Read_Property_Multiple_Data.new_data = false;
|
||||
PrintReadPropertyData
|
||||
(Read_Property_Multiple_Data.rpm_data->
|
||||
listOfProperties);
|
||||
PrintReadPropertyData(
|
||||
Read_Property_Multiple_Data.rpm_data->object_type,
|
||||
Read_Property_Multiple_Data.rpm_data->object_instance,
|
||||
Read_Property_Multiple_Data.rpm_data->listOfProperties);
|
||||
if (tsm_invoke_id_free(invoke_id)) {
|
||||
invoke_id = 0;
|
||||
} else {
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
void rp_ack_print_data(
|
||||
BACNET_READ_PROPERTY_DATA * data)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
|
||||
int len = 0;
|
||||
uint8_t *application_data;
|
||||
@@ -72,7 +73,12 @@ void rp_ack_print_data(
|
||||
#endif
|
||||
print_brace = true;
|
||||
}
|
||||
bacapp_print_value(stdout, &value, data->object_property);
|
||||
object_value.object_type = data->object_type;
|
||||
object_value.object_instance = data->object_instance;
|
||||
object_value.object_property = data->object_property;
|
||||
object_value.array_index = data->array_index;
|
||||
object_value.value = &value;
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
if (len) {
|
||||
if (len < application_data_len) {
|
||||
application_data += len;
|
||||
|
||||
@@ -202,6 +202,7 @@ int rpm_ack_decode_service_request(
|
||||
void rpm_ack_print_data(
|
||||
BACNET_READ_ACCESS_DATA * rpm_data)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_PROPERTY_REFERENCE *listOfProperties;
|
||||
BACNET_APPLICATION_DATA_VALUE *value;
|
||||
bool array_value = false;
|
||||
@@ -240,9 +241,18 @@ void rpm_ack_print_data(
|
||||
array_value = false;
|
||||
}
|
||||
#endif
|
||||
object_value.object_type =
|
||||
rpm_data->object_type;
|
||||
object_value.object_instance =
|
||||
rpm_data->object_instance;
|
||||
while (value) {
|
||||
bacapp_print_value(stdout, value,
|
||||
listOfProperties->propertyIdentifier);
|
||||
object_value.object_property =
|
||||
listOfProperties->propertyIdentifier;
|
||||
object_value.array_index =
|
||||
listOfProperties->propertyArrayIndex;
|
||||
object_value.value =
|
||||
listOfProperties->value;
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
#if PRINT_ENABLED
|
||||
if (value->next) {
|
||||
fprintf(stdout, ",\r\n ");
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
static void PrintReadRangeData(
|
||||
BACNET_READ_RANGE_DATA * data)
|
||||
{
|
||||
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
|
||||
BACNET_APPLICATION_DATA_VALUE value; /* for decode value data */
|
||||
int len = 0;
|
||||
uint8_t *application_data;
|
||||
@@ -69,7 +70,12 @@ static void PrintReadRangeData(
|
||||
#endif
|
||||
print_brace = true;
|
||||
}
|
||||
bacapp_print_value(stdout, &value, data->object_property);
|
||||
object_value.object_type = data->object_type;
|
||||
object_value.object_instance = data->object_instance;
|
||||
object_value.object_property = data->object_property;
|
||||
object_value.array_index = data->array_index;
|
||||
object_value.value = &value;
|
||||
bacapp_print_value(stdout, &object_value);
|
||||
if (len) {
|
||||
if (len < application_data_len) {
|
||||
application_data += len;
|
||||
|
||||
@@ -117,6 +117,16 @@ typedef struct BACnet_Property_Value {
|
||||
struct BACnet_Property_Value *next;
|
||||
} BACNET_PROPERTY_VALUE;
|
||||
|
||||
/* used for printing values */
|
||||
struct BACnet_Object_Property_Value;
|
||||
typedef struct BACnet_Object_Property_Value {
|
||||
BACNET_OBJECT_TYPE object_type;
|
||||
uint32_t object_instance;
|
||||
BACNET_PROPERTY_ID object_property;
|
||||
int32_t array_index;
|
||||
BACNET_APPLICATION_DATA_VALUE *value;
|
||||
} BACNET_OBJECT_PROPERTY_VALUE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
@@ -191,12 +201,11 @@ extern "C" {
|
||||
BACNET_APPLICATION_DATA_VALUE * value);
|
||||
bool bacapp_print_value(
|
||||
FILE * stream,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
BACNET_PROPERTY_ID property);
|
||||
BACNET_OBJECT_PROPERTY_VALUE * value);
|
||||
#else
|
||||
/* Provide harmless return values */
|
||||
#define bacapp_parse_application_data(x,y,z) false
|
||||
#define bacapp_print_value(x,y,z) false
|
||||
#define bacapp_print_value(x,y) false
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
@@ -820,15 +820,20 @@ int bacapp_data_len(
|
||||
#ifdef BACAPP_PRINT_ENABLED
|
||||
bool bacapp_print_value(
|
||||
FILE * stream,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
BACNET_PROPERTY_ID property)
|
||||
BACNET_OBJECT_PROPERTY_VALUE *object_value)
|
||||
{
|
||||
bool status = true; /*return value */
|
||||
size_t len = 0, i = 0;
|
||||
char *char_str;
|
||||
uint8_t *octet_str;
|
||||
BACNET_APPLICATION_DATA_VALUE *value;
|
||||
BACNET_PROPERTY_ID property = PROP_ALL;
|
||||
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
|
||||
|
||||
if (value) {
|
||||
if (object_value && object_value->value) {
|
||||
value = object_value->value;
|
||||
property = object_value->object_property;
|
||||
object_type = object_value->object_type;
|
||||
switch (value->tag) {
|
||||
case BACNET_APPLICATION_TAG_NULL:
|
||||
fprintf(stream, "Null");
|
||||
@@ -921,9 +926,14 @@ bool bacapp_print_value(
|
||||
Enumerated));
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_present_value_name(value->type.
|
||||
Enumerated));
|
||||
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stream, "%s",
|
||||
bactext_binary_present_value_name(
|
||||
value->type.Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "%lu",
|
||||
(unsigned long) value->type.Enumerated);
|
||||
}
|
||||
break;
|
||||
case PROP_RELIABILITY:
|
||||
fprintf(stream, "%s",
|
||||
|
||||
Reference in New Issue
Block a user