Consolidated the debug print information for the linux server demo.
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
/* buffers used for receiving */
|
/* buffers used for receiving */
|
||||||
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
||||||
|
static char *Network_Interface = NULL;
|
||||||
|
|
||||||
static void Init_Service_Handlers(void)
|
static void Init_Service_Handlers(void)
|
||||||
{
|
{
|
||||||
@@ -90,25 +91,11 @@ static void cleanup(void)
|
|||||||
datalink_cleanup();
|
datalink_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_address(char *name, BACNET_ADDRESS * dest)
|
|
||||||
{ /* destination address */
|
|
||||||
int i = 0; /* counter */
|
|
||||||
|
|
||||||
if (dest) {
|
|
||||||
printf("%s: ", name);
|
|
||||||
for (i = 0; i < dest->mac_len; i++) {
|
|
||||||
printf("%02X", dest->mac[i]);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||||
uint16_t pdu_len = 0;
|
uint16_t pdu_len = 0;
|
||||||
unsigned timeout = 100; /* milliseconds */
|
unsigned timeout = 100; /* milliseconds */
|
||||||
BACNET_ADDRESS my_address, broadcast_address;
|
|
||||||
time_t last_seconds = 0;
|
time_t last_seconds = 0;
|
||||||
time_t current_seconds = 0;
|
time_t current_seconds = 0;
|
||||||
|
|
||||||
@@ -117,17 +104,16 @@ int main(int argc, char *argv[])
|
|||||||
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
|
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
|
||||||
#if defined(BACDL_BIP)
|
#if defined(BACDL_BIP)
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
bip_set_port(strtol(argv[2], NULL, 0));
|
Network_Interface = argv[2];
|
||||||
|
if (argc > 3)
|
||||||
|
bip_set_port(strtol(argv[3], NULL, 0));
|
||||||
#endif
|
#endif
|
||||||
printf("BACnet Server Demo - Device #%u\r\n",
|
printf("BACnet Server Demo\n"
|
||||||
|
"BACnet Device ID: %u\r\n",
|
||||||
Device_Object_Instance_Number());
|
Device_Object_Instance_Number());
|
||||||
Init_Service_Handlers();
|
Init_Service_Handlers();
|
||||||
if (!datalink_init(NULL))
|
if (!datalink_init(Network_Interface))
|
||||||
return 1;
|
return 1;
|
||||||
datalink_get_broadcast_address(&broadcast_address);
|
|
||||||
print_address("Broadcast", &broadcast_address);
|
|
||||||
datalink_get_my_address(&my_address);
|
|
||||||
print_address("Address", &my_address);
|
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
/* configure the timeout values */
|
/* configure the timeout values */
|
||||||
last_seconds = time(NULL);
|
last_seconds = time(NULL);
|
||||||
|
|||||||
@@ -89,8 +89,11 @@ static void bip_set_interface(char *ifname)
|
|||||||
get_local_address_ioctl(ifname, &broadcast_address, SIOCGIFBRDADDR);
|
get_local_address_ioctl(ifname, &broadcast_address, SIOCGIFBRDADDR);
|
||||||
bip_set_broadcast_addr(broadcast_address.s_addr);
|
bip_set_broadcast_addr(broadcast_address.s_addr);
|
||||||
#ifdef BIP_DEBUG
|
#ifdef BIP_DEBUG
|
||||||
fprintf(stderr, "Broadcast Address: %s\n",
|
fprintf(stderr, "IP Broadcast Address: %s\n",
|
||||||
inet_ntoa(broadcast_address));
|
inet_ntoa(broadcast_address));
|
||||||
|
fprintf(stderr, "UDP Port: 0x%04X [%hu]\n",
|
||||||
|
bip_get_port(),
|
||||||
|
bip_get_port());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user