Feature/refactor bacnet ipv4 add unit tests (#64)
* refactor BACnet/IPv4 BVLC into encode-decode library with unit tests Added Read-Broadcast-Distribution-Table encoding and unit test. Added Read-Broadcast-Distribution-Table-Ack encoding and unit test. Added Read-Foreign-Device-Table-Ack encoding and unit test. Added some BDT/FDT diff copy functions with unit tests Added some FDT add and delete entry functions with unit tests Added some BDT set append and clear entry functions with unit tests Added some BIPv4 address conversion functions with unit tests Added non-BBMD handling unit test Added basic unit test for BBMD handler Added BBMD broadcast mask get set and unit tests Added IPv6 maintenance timer. Added ReadFDT app Fixed ReadBDT app Added Who-Is to Makefile for individual app build Fixed debugging code blocks projects by swapping bip.c for h_bbmd.c module. Ported BACnet/IPv4 to refactored BVLC for Linux, BSD, Windows Fix datalink debug for DLENV module Improve BIPv4 linux driver debug info Added BDT mask functions Reduce debug info clutter in Who-Is app by using environment option Fix TTL seconds upper bounds addition Fix CIDR prefix calculation on Linux BIPv4. Convert BSD BIPv4 to BVLCv4 Fix CMake build for BIPv4 (Linux, BSD, Windows) Added [U]nsigned to 0xBAC0 constants Cleanup POSIX and Win32 API sockets Remove unnecessary file scope variable initialization Fix routed NPDU to depend on datalink; fix warning Remove OS dependent network code from gateway Enable BBMD client in library by default Co-authored-by: Steve Karg <skarg@users.sourceforge.net> Co-authored-by: Steve Karg <steve.karg@legrand.us>
This commit is contained in:
+6
-10
@@ -56,8 +56,7 @@
|
||||
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
||||
|
||||
/* targets interpreted from the command line options */
|
||||
static uint32_t Target_BBMD_Address;
|
||||
static uint16_t Target_BBMD_Port;
|
||||
static BACNET_IP_ADDRESS Target_BBMD_Address;
|
||||
|
||||
static bool Error_Detected = false;
|
||||
|
||||
@@ -134,8 +133,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
/* decode the command line parameters */
|
||||
if (argc > 1) {
|
||||
Target_BBMD_Address = inet_addr(argv[1]);
|
||||
if (Target_BBMD_Address == (-1)) {
|
||||
if (!bip_get_addr_by_name(argv[1], &Target_BBMD_Address)) {
|
||||
fprintf(stderr, "IP=%s - failed to convert address.\r\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
@@ -143,14 +141,14 @@ int main(int argc, char *argv[])
|
||||
if (argc > 2) {
|
||||
port = strtol(argv[2], NULL, 0);
|
||||
if ((port > 0) && (port <= 65535)) {
|
||||
Target_BBMD_Port = htons(port);
|
||||
Target_BBMD_Address.port = (uint16_t)port;
|
||||
} else {
|
||||
fprintf(
|
||||
stderr, "port=%ld - port must be between 0-65535.\r\n", port);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
Target_BBMD_Port = htons(47808);
|
||||
Target_BBMD_Address.port = 0xBAC0U;
|
||||
}
|
||||
/* setup my info */
|
||||
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
|
||||
@@ -162,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
last_seconds = time(NULL);
|
||||
timeout_seconds = apdu_timeout() / 1000;
|
||||
/* send the request */
|
||||
bvlc_bbmd_read_bdt(Target_BBMD_Address, Target_BBMD_Port);
|
||||
bvlc_bbmd_read_bdt(&Target_BBMD_Address);
|
||||
/* loop forever */
|
||||
for (;;) {
|
||||
/* increment timer - exit if timed out */
|
||||
@@ -178,9 +176,7 @@ int main(int argc, char *argv[])
|
||||
/* increment timer - exit if timed out */
|
||||
elapsed_seconds = current_seconds - last_seconds;
|
||||
if (elapsed_seconds) {
|
||||
#if defined(BACDL_BIP) && BBMD_ENABLED
|
||||
bvlc_maintenance_timer(elapsed_seconds);
|
||||
#endif
|
||||
datalink_maintenance_timer(elapsed_seconds);
|
||||
}
|
||||
total_seconds += elapsed_seconds;
|
||||
if (total_seconds > timeout_seconds) {
|
||||
|
||||
Reference in New Issue
Block a user