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