Fixed some warnings detected by CSTAT.
Consolidated some unit tests and added a single test prototype to header file.
This commit is contained in:
@@ -608,7 +608,7 @@ void handler_cov_timer_seconds(
|
||||
}
|
||||
}
|
||||
|
||||
void handler_cov_task(
|
||||
bool handler_cov_fsm(
|
||||
void)
|
||||
{
|
||||
static int index = 0;
|
||||
@@ -739,6 +739,13 @@ void handler_cov_task(
|
||||
cov_task_state = COV_STATE_IDLE;
|
||||
break;
|
||||
}
|
||||
return (cov_task_state == COV_STATE_IDLE);
|
||||
}
|
||||
|
||||
void handler_cov_task(
|
||||
void)
|
||||
{
|
||||
handler_cov_fsm();
|
||||
}
|
||||
|
||||
static bool cov_subscribe(
|
||||
|
||||
@@ -143,11 +143,12 @@ uint8_t Send_COV_Subscribe(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send SubscribeCOV Request (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
tsm_free_invoke_id(invoke_id);
|
||||
invoke_id = 0;
|
||||
|
||||
@@ -80,11 +80,13 @@ void Send_I_Am_To_Network(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(target_address, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send I-Am Request (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Encode an I Am message to be broadcast.
|
||||
@@ -227,10 +229,9 @@ void Send_I_Am_Unicast(
|
||||
/* send data */
|
||||
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &buffer[0], pdu_len);
|
||||
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||
#else
|
||||
(void)bytes_sent;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
/** @file s_upt.c Send an Unconfirmed Private Transfer request. */
|
||||
|
||||
void Send_UnconfirmedPrivateTransfer(
|
||||
int Send_UnconfirmedPrivateTransfer(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_PRIVATE_TRANSFER_DATA * private_data)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ void Send_UnconfirmedPrivateTransfer(
|
||||
BACNET_ADDRESS my_address;
|
||||
|
||||
if (!dcc_communication_enabled())
|
||||
return;
|
||||
return bytes_sent;
|
||||
|
||||
datalink_get_my_address(&my_address);
|
||||
/* encode the NPDU portion of the packet */
|
||||
@@ -73,10 +73,13 @@ void Send_UnconfirmedPrivateTransfer(
|
||||
bytes_sent =
|
||||
datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send UnconfirmedPrivateTransfer Request (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
|
||||
return bytes_sent;
|
||||
}
|
||||
|
||||
@@ -417,9 +417,13 @@ extern "C" {
|
||||
/* true if the tag is a closing tag */
|
||||
#define IS_CLOSING_TAG(x) ((x & 0x07) == 7)
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
void test_BACDCode(
|
||||
Test * pTest);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
@@ -243,7 +243,7 @@ extern "C" {
|
||||
uint32_t device_id,
|
||||
BACNET_ALARM_ACK_DATA * data);
|
||||
|
||||
void Send_UnconfirmedPrivateTransfer(
|
||||
int Send_UnconfirmedPrivateTransfer(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_PRIVATE_TRANSFER_DATA * private_data);
|
||||
|
||||
|
||||
@@ -190,8 +190,7 @@ extern "C" {
|
||||
int handler_timesync_encode_recipients(
|
||||
uint8_t * apdu,
|
||||
int max_apdu);
|
||||
void handler_timesync_task(
|
||||
void);
|
||||
void handler_timesync_task(BACNET_DATE_TIME *bdatetime);
|
||||
void handler_timesync_init(
|
||||
void);
|
||||
bool handler_timesync_recipient_write(
|
||||
@@ -233,6 +232,8 @@ extern "C" {
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS * src,
|
||||
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
||||
bool handler_cov_fsm(
|
||||
void);
|
||||
void handler_cov_task(
|
||||
void);
|
||||
void handler_cov_timer_seconds(
|
||||
|
||||
@@ -331,10 +331,10 @@ uint16_t apdu_decode_confirmed_service_request(
|
||||
{
|
||||
uint16_t len = 0; /* counts where we are in PDU */
|
||||
|
||||
service_data->segmented_message = (apdu[0] & BIT3) ? true : false;
|
||||
service_data->more_follows = (apdu[0] & BIT2) ? true : false;
|
||||
service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false;
|
||||
service_data->more_follows = (apdu[0] & BIT(2)) ? true : false;
|
||||
service_data->segmented_response_accepted =
|
||||
(apdu[0] & BIT1) ? true : false;
|
||||
(apdu[0] & BIT(1)) ? true : false;
|
||||
service_data->max_segs = decode_max_segs(apdu[1]);
|
||||
service_data->max_resp = decode_max_apdu(apdu[1]);
|
||||
service_data->invoke_id = apdu[2];
|
||||
@@ -534,9 +534,9 @@ void apdu_handler(
|
||||
break;
|
||||
case PDU_TYPE_COMPLEX_ACK:
|
||||
service_ack_data.segmented_message =
|
||||
(apdu[0] & BIT3) ? true : false;
|
||||
(apdu[0] & BIT(3)) ? true : false;
|
||||
service_ack_data.more_follows =
|
||||
(apdu[0] & BIT2) ? true : false;
|
||||
(apdu[0] & BIT(2)) ? true : false;
|
||||
invoke_id = service_ack_data.invoke_id = apdu[1];
|
||||
len = 2;
|
||||
if (service_ack_data.segmented_message) {
|
||||
|
||||
+40
-45
@@ -1855,7 +1855,7 @@ static void print_apdu(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeTags(
|
||||
static void testBACDCodeTags(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
@@ -1905,7 +1905,7 @@ void testBACDCodeTags(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeEnumerated(
|
||||
static void testBACDCodeEnumerated(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t array[5] = { 0 };
|
||||
@@ -1949,7 +1949,7 @@ void testBACDCodeEnumerated(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeReal(
|
||||
static void testBACDCodeReal(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t real_array[4] = { 0 };
|
||||
@@ -1983,7 +1983,7 @@ void testBACDCodeReal(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeDouble(
|
||||
static void testBACDCodeDouble(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t double_array[8] = { 0 };
|
||||
@@ -2017,7 +2017,7 @@ void testBACDCodeDouble(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeUnsignedValue(
|
||||
static void testBACDCodeUnsignedValue(
|
||||
Test * pTest,
|
||||
uint32_t value)
|
||||
{
|
||||
@@ -2050,7 +2050,7 @@ void testBACDCodeUnsignedValue(
|
||||
ct_test(pTest, IS_CONTEXT_SPECIFIC(apdu[0]) == false);
|
||||
}
|
||||
|
||||
void testBACDCodeUnsigned(
|
||||
static void testBACDCodeUnsigned(
|
||||
Test * pTest)
|
||||
{
|
||||
uint32_t value = 1;
|
||||
@@ -2066,7 +2066,7 @@ void testBACDCodeUnsigned(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACnetUnsigned(
|
||||
static void testBACnetUnsigned(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[32] = { 0 };
|
||||
@@ -2083,7 +2083,7 @@ void testBACnetUnsigned(
|
||||
}
|
||||
}
|
||||
|
||||
void testBACDCodeSignedValue(
|
||||
static void testBACDCodeSignedValue(
|
||||
Test * pTest,
|
||||
int32_t value)
|
||||
{
|
||||
@@ -2125,7 +2125,7 @@ void testBACDCodeSignedValue(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeSigned(
|
||||
static void testBACDCodeSigned(
|
||||
Test * pTest)
|
||||
{
|
||||
int value = 1;
|
||||
@@ -2150,7 +2150,7 @@ void testBACDCodeSigned(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACnetSigned(
|
||||
static void testBACnetSigned(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[32] = { 0 };
|
||||
@@ -2171,7 +2171,7 @@ void testBACnetSigned(
|
||||
}
|
||||
}
|
||||
|
||||
void testBACDCodeOctetString(
|
||||
static void testBACDCodeOctetString(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t array[MAX_APDU] = { 0 };
|
||||
@@ -2228,7 +2228,7 @@ void testBACDCodeOctetString(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeCharacterString(
|
||||
static void testBACDCodeCharacterString(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t array[MAX_APDU] = { 0 };
|
||||
@@ -2286,7 +2286,7 @@ void testBACDCodeCharacterString(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeObject(
|
||||
static void testBACDCodeObject(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t object_array[4] = {
|
||||
@@ -2323,7 +2323,7 @@ void testBACDCodeObject(
|
||||
return;
|
||||
}
|
||||
|
||||
void testBACDCodeMaxSegsApdu(
|
||||
static void testBACDCodeMaxSegsApdu(
|
||||
Test * pTest)
|
||||
{
|
||||
int max_segs[8] = { 0, 2, 4, 8, 16, 32, 64, 65 };
|
||||
@@ -2342,7 +2342,7 @@ void testBACDCodeMaxSegsApdu(
|
||||
}
|
||||
}
|
||||
|
||||
void testBACDCodeBitString(
|
||||
static void testBACDCodeBitString(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t bit = 0;
|
||||
@@ -2390,7 +2390,7 @@ void testBACDCodeBitString(
|
||||
}
|
||||
}
|
||||
|
||||
void testUnsignedContextDecodes(
|
||||
static void testUnsignedContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2484,7 +2484,7 @@ void testUnsignedContextDecodes(
|
||||
|
||||
}
|
||||
|
||||
void testSignedContextDecodes(
|
||||
static void testSignedContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2582,7 +2582,7 @@ void testSignedContextDecodes(
|
||||
|
||||
}
|
||||
|
||||
void testEnumeratedContextDecodes(
|
||||
static void testEnumeratedContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2675,7 +2675,7 @@ void testEnumeratedContextDecodes(
|
||||
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
|
||||
}
|
||||
|
||||
void testFloatContextDecodes(
|
||||
static void testFloatContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2723,7 +2723,7 @@ void testFloatContextDecodes(
|
||||
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
|
||||
}
|
||||
|
||||
void testDoubleContextDecodes(
|
||||
static void testDoubleContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2771,7 +2771,7 @@ void testDoubleContextDecodes(
|
||||
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
|
||||
}
|
||||
|
||||
void testObjectIDContextDecodes(
|
||||
static void testObjectIDContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2812,7 +2812,7 @@ void testObjectIDContextDecodes(
|
||||
ct_test(pTest, outLen2 == BACNET_STATUS_ERROR);
|
||||
}
|
||||
|
||||
void testCharacterStringContextDecodes(
|
||||
static void testCharacterStringContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2849,7 +2849,7 @@ void testCharacterStringContextDecodes(
|
||||
ct_test(pTest, strcmp(in.value, out.value) == 0);
|
||||
}
|
||||
|
||||
void testBitStringContextDecodes(
|
||||
static void testBitStringContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2888,7 +2888,7 @@ void testBitStringContextDecodes(
|
||||
ct_test(pTest, memcmp(in.value, out.value, MAX_BITSTRING_BYTES) == 0);
|
||||
}
|
||||
|
||||
void testOctetStringContextDecodes(
|
||||
static void testOctetStringContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2925,7 +2925,7 @@ void testOctetStringContextDecodes(
|
||||
|
||||
}
|
||||
|
||||
void testTimeContextDecodes(
|
||||
static void testTimeContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -2967,7 +2967,7 @@ void testTimeContextDecodes(
|
||||
|
||||
}
|
||||
|
||||
void testDateContextDecodes(
|
||||
static void testDateContextDecodes(
|
||||
Test * pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU];
|
||||
@@ -3008,16 +3008,12 @@ void testDateContextDecodes(
|
||||
ct_test(pTest, in.year == out.year);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_DECODE
|
||||
int main(
|
||||
void)
|
||||
void test_BACDCode(
|
||||
Test * pTest)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
|
||||
pTest = ct_create("BACDCode", NULL);
|
||||
/* individual tests */
|
||||
/* add individual tests */
|
||||
rc = ct_addTestFunction(pTest, testBACDCodeTags);
|
||||
assert(rc);
|
||||
rc = ct_addTestFunction(pTest, testBACDCodeReal);
|
||||
@@ -3042,42 +3038,41 @@ int main(
|
||||
assert(rc);
|
||||
rc = ct_addTestFunction(pTest, testBACDCodeBitString);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testUnsignedContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testSignedContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testEnumeratedContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testCharacterStringContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testFloatContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testDoubleContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testObjectIDContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testBitStringContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testTimeContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testDateContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testOctetStringContextDecodes);
|
||||
assert(rc);
|
||||
|
||||
rc = ct_addTestFunction(pTest, testBACDCodeDouble);
|
||||
assert(rc);
|
||||
}
|
||||
|
||||
#ifdef TEST_DECODE
|
||||
int main(
|
||||
void)
|
||||
{
|
||||
Test *pTest;
|
||||
|
||||
pTest = ct_create("BACDCode", NULL);
|
||||
test_BACDCode(pTest);
|
||||
|
||||
/* configure output */
|
||||
ct_setStream(pTest, stdout);
|
||||
ct_run(pTest);
|
||||
|
||||
Reference in New Issue
Block a user