Indented.
This commit is contained in:
+70
-80
@@ -75,7 +75,7 @@ static uint8_t month_days(
|
||||
if ((month == 2) && is_leap_year(year))
|
||||
return 29;
|
||||
else if (month >= 1 && month <= 12)
|
||||
return (uint8_t)month_days[month];
|
||||
return (uint8_t) month_days[month];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -435,48 +435,47 @@ int bacapp_encode_context_datetime(
|
||||
uint8_t tag_number,
|
||||
BACNET_DATE_TIME * value)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
int len = 0;
|
||||
int apdu_len = 0;
|
||||
|
||||
|
||||
if ( apdu && value )
|
||||
{
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
if (apdu && value) {
|
||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_application_date(&apdu[apdu_len], &value->date);
|
||||
apdu_len += len;
|
||||
len = encode_application_date(&apdu[apdu_len], &value->date);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_application_time(&apdu[apdu_len], &value->time);
|
||||
apdu_len += len;
|
||||
len = encode_application_time(&apdu[apdu_len], &value->time);
|
||||
apdu_len += len;
|
||||
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
}
|
||||
return apdu_len;
|
||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||
apdu_len += len;
|
||||
}
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
int bacapp_decode_datetime(
|
||||
uint8_t * apdu,
|
||||
BACNET_DATE_TIME * value)
|
||||
{
|
||||
int len = 0;
|
||||
int section_len;
|
||||
int len = 0;
|
||||
int section_len;
|
||||
|
||||
if ( -1 == ( section_len = decode_application_date(&apdu[len], &value->date) ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
len += section_len;
|
||||
if (-1 == (section_len =
|
||||
decode_application_date(&apdu[len], &value->date))) {
|
||||
return -1;
|
||||
}
|
||||
len += section_len;
|
||||
|
||||
if ( -1 == ( section_len = decode_application_time(&apdu[len], &value->time) ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (-1 == (section_len =
|
||||
decode_application_time(&apdu[len], &value->time))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
len += section_len;
|
||||
|
||||
return len;
|
||||
len += section_len;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int bacapp_decode_context_datetime(
|
||||
@@ -484,35 +483,27 @@ int bacapp_decode_context_datetime(
|
||||
uint8_t tag_number,
|
||||
BACNET_DATE_TIME * value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
int len;
|
||||
int apdu_len = 0;
|
||||
int len;
|
||||
|
||||
if (decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len++;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( -1 == (len = bacapp_decode_datetime(&apdu[apdu_len], value)))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
apdu_len += len;
|
||||
}
|
||||
if (-1 == (len = bacapp_decode_datetime(&apdu[apdu_len], value))) {
|
||||
return -1;
|
||||
} else {
|
||||
apdu_len += len;
|
||||
}
|
||||
|
||||
if (decode_is_closing_tag_number(&apdu[apdu_len], tag_number))
|
||||
{
|
||||
apdu_len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return apdu_len;
|
||||
if (decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||
apdu_len++;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
|
||||
@@ -836,36 +827,36 @@ void testBACnetDayOfWeek(
|
||||
void testDatetimeCodec(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
BACNET_DATE_TIME datetimeIn;
|
||||
BACNET_DATE_TIME datetimeOut;
|
||||
int inLen;
|
||||
int outLen;
|
||||
uint8_t apdu[MAX_APDU];
|
||||
BACNET_DATE_TIME datetimeIn;
|
||||
BACNET_DATE_TIME datetimeOut;
|
||||
int inLen;
|
||||
int outLen;
|
||||
|
||||
datetimeIn.date.day = 1;
|
||||
datetimeIn.date.month = 2;
|
||||
datetimeIn.date.wday = 3;
|
||||
datetimeIn.date.year = 1904;
|
||||
datetimeIn.date.day = 1;
|
||||
datetimeIn.date.month = 2;
|
||||
datetimeIn.date.wday = 3;
|
||||
datetimeIn.date.year = 1904;
|
||||
|
||||
datetimeIn.time.hour = 5;
|
||||
datetimeIn.time.min = 6;
|
||||
datetimeIn.time.sec = 7;
|
||||
datetimeIn.time.hundredths = 8;
|
||||
datetimeIn.time.hour = 5;
|
||||
datetimeIn.time.min = 6;
|
||||
datetimeIn.time.sec = 7;
|
||||
datetimeIn.time.hundredths = 8;
|
||||
|
||||
inLen = bacapp_encode_context_datetime(apdu, 10, &datetimeIn);
|
||||
outLen = bacapp_decode_context_datetime(apdu, 10, &datetimeOut);
|
||||
inLen = bacapp_encode_context_datetime(apdu, 10, &datetimeIn);
|
||||
outLen = bacapp_decode_context_datetime(apdu, 10, &datetimeOut);
|
||||
|
||||
ct_test(pTest, inLen == outLen );
|
||||
ct_test(pTest, inLen == outLen);
|
||||
|
||||
ct_test(pTest, datetimeIn.date.day == datetimeOut.date.day);
|
||||
ct_test(pTest, datetimeIn.date.month == datetimeOut.date.month);
|
||||
ct_test(pTest, datetimeIn.date.wday == datetimeOut.date.wday);
|
||||
ct_test(pTest, datetimeIn.date.year == datetimeOut.date.year);
|
||||
ct_test(pTest, datetimeIn.date.day == datetimeOut.date.day);
|
||||
ct_test(pTest, datetimeIn.date.month == datetimeOut.date.month);
|
||||
ct_test(pTest, datetimeIn.date.wday == datetimeOut.date.wday);
|
||||
ct_test(pTest, datetimeIn.date.year == datetimeOut.date.year);
|
||||
|
||||
ct_test(pTest, datetimeIn.time.hour == datetimeOut.time.hour);
|
||||
ct_test(pTest, datetimeIn.time.min == datetimeOut.time.min);
|
||||
ct_test(pTest, datetimeIn.time.sec == datetimeOut.time.sec);
|
||||
ct_test(pTest, datetimeIn.time.hundredths == datetimeOut.time.hundredths);
|
||||
ct_test(pTest, datetimeIn.time.hour == datetimeOut.time.hour);
|
||||
ct_test(pTest, datetimeIn.time.min == datetimeOut.time.min);
|
||||
ct_test(pTest, datetimeIn.time.sec == datetimeOut.time.sec);
|
||||
ct_test(pTest, datetimeIn.time.hundredths == datetimeOut.time.hundredths);
|
||||
|
||||
}
|
||||
|
||||
@@ -909,4 +900,3 @@ int main(
|
||||
|
||||
#endif /* TEST_DATE_TIME */
|
||||
#endif /* TEST */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user