Esempio n. 1
0
/* for debugging... */
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;
    int application_data_len;
    bool first_value = true;
    bool print_brace = false;

    if (data) {
        application_data = data->application_data;
        application_data_len = data->application_data_len;
        /* FIXME: what if application_data_len is bigger than 255? */
        /* value? need to loop until all of the len is gone... */
        for (;;) {
            len =
                bacapp_decode_application_data(application_data,
                (uint8_t) application_data_len, &value);
            if (first_value && (len < application_data_len)) {
                first_value = false;
#if PRINT_ENABLED
                fprintf(stdout, "{");
#endif
                print_brace = true;
            }
            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 > 0) {
                if (len < application_data_len) {
                    application_data += len;
                    application_data_len -= len;
                    /* there's more! */
#if PRINT_ENABLED
                    fprintf(stdout, ",");
#endif
                } else {
                    break;
                }
            } else {
                break;
            }
        }
#if PRINT_ENABLED
        if (print_brace)
            fprintf(stdout, "}");
        fprintf(stdout, "\r\n");
#endif
    }
}
Esempio n. 2
0
/* for debugging... */
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;

    if (rpm_data) {
#if PRINT_ENABLED
        fprintf(stdout, "%s #%lu\r\n",
            bactext_object_type_name(rpm_data->object_type),
            (unsigned long) rpm_data->object_instance);
        fprintf(stdout, "{\r\n");
#endif
        listOfProperties = rpm_data->listOfProperties;
        while (listOfProperties) {
#if PRINT_ENABLED
            if (listOfProperties->propertyIdentifier < 512) {
                fprintf(stdout, "    %s: ",
                    bactext_property_name(listOfProperties->
                        propertyIdentifier));
            } else {
                fprintf(stdout, "    proprietary %u: ",
                    (unsigned) listOfProperties->propertyIdentifier);
            }
#endif
            if (listOfProperties->propertyArrayIndex != BACNET_ARRAY_ALL) {
#if PRINT_ENABLED
                fprintf(stdout, "[%d]", listOfProperties->propertyArrayIndex);
#endif
            }
            value = listOfProperties->value;
            if (value) {
#if PRINT_ENABLED
                if (value->next) {
                    fprintf(stdout, "{");
                    array_value = true;
                } else {
                    array_value = false;
                }
#endif
                object_value.object_type = rpm_data->object_type;
                object_value.object_instance = rpm_data->object_instance;
                while (value) {
                    object_value.object_property =
                        listOfProperties->propertyIdentifier;
                    object_value.array_index =
                        listOfProperties->propertyArrayIndex;
                    object_value.value = value;
                    bacapp_print_value(stdout, &object_value);
#if PRINT_ENABLED
                    if (value->next) {
                        fprintf(stdout, ",\r\n        ");
                    } else {
                        if (array_value) {
                            fprintf(stdout, "}\r\n");
                        } else {
                            fprintf(stdout, "\r\n");
                        }
                    }
#endif
                    value = value->next;
                }
            } else {
#if PRINT_ENABLED
                /* AccessError */
                fprintf(stdout, "BACnet Error: %s: %s\r\n",
                    bactext_error_class_name((int) listOfProperties->
                        error.error_class),
                    bactext_error_code_name((int) listOfProperties->
                        error.error_code));
#endif
            }
            listOfProperties = listOfProperties->next;
        }
#if PRINT_ENABLED
        fprintf(stdout, "}\r\n");
#endif
    }
}