示例#1
0
void testTimestampTime(
    Test * pTest)
{
    BACNET_TIMESTAMP testTimestampIn;
    BACNET_TIMESTAMP testTimestampOut;
    uint8_t buffer[MAX_APDU];
    int inLen;
    int outLen;

    testTimestampIn.tag = TIME_STAMP_TIME;
    testTimestampIn.value.time.hour = 1;
    testTimestampIn.value.time.min = 2;
    testTimestampIn.value.time.sec = 3;
    testTimestampIn.value.time.hundredths = 4;

    memset(&testTimestampOut, 0, sizeof(testTimestampOut));


    inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
    outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);

    ct_test(pTest, inLen == outLen);
    ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
    ct_test(pTest,
        testTimestampIn.value.time.hour == testTimestampOut.value.time.hour);
    ct_test(pTest,
        testTimestampIn.value.time.min == testTimestampOut.value.time.min);
    ct_test(pTest,
        testTimestampIn.value.time.sec == testTimestampOut.value.time.sec);
    ct_test(pTest,
        testTimestampIn.value.time.hundredths ==
        testTimestampOut.value.time.hundredths);
}
示例#2
0
/***************************************************
**
** Encodes the service data part of Event Notification
**
****************************************************/
int alarm_ack_encode_service_request(
    uint8_t * apdu,
    BACNET_ALARM_ACK_DATA * data)
{
    int len = 0;        /* length of each encoding */
    int apdu_len = 0;   /* total length of the apdu, return value */

    if (apdu) {
        len =
            encode_context_unsigned(&apdu[apdu_len], 0,
                                    data->ackProcessIdentifier);
        apdu_len += len;

        len =
            encode_context_object_id(&apdu[apdu_len], 1,
                                     (int) data->eventObjectIdentifier.type,
                                     data->eventObjectIdentifier.instance);
        apdu_len += len;

        len =
            encode_context_enumerated(&apdu[apdu_len], 2,
                                      data->eventStateAcked);
        apdu_len += len;

        len =
            bacapp_encode_context_timestamp(&apdu[apdu_len], 3,
                                            &data->eventTimeStamp);
        apdu_len += len;

        len =
            encode_context_character_string(&apdu[apdu_len], 4,
                                            &data->ackSource);
        apdu_len += len;

        len =
            bacapp_encode_context_timestamp(&apdu[apdu_len], 5,
                                            &data->ackTimeStamp);
        apdu_len += len;
    }

    return apdu_len;
}
示例#3
0
void testTimestampSequence(
    Test * pTest)
{
    BACNET_TIMESTAMP testTimestampIn;
    BACNET_TIMESTAMP testTimestampOut;
    uint8_t buffer[MAX_APDU];
    int inLen;
    int outLen;

    testTimestampIn.tag = TIME_STAMP_SEQUENCE;
    testTimestampIn.value.sequenceNum = 0x1234;

    memset(&testTimestampOut, 0, sizeof(testTimestampOut));


    inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
    outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);

    ct_test(pTest, inLen == outLen);
    ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
    ct_test(pTest,
        testTimestampIn.value.sequenceNum ==
        testTimestampOut.value.sequenceNum);
}