Combined the interface set into the datalink_init for all the datalink layers. Changed all the demo programs to use datalink_init instead of specific datalink functions.

This commit is contained in:
skarg
2007-05-25 01:08:42 +00:00
parent 076ee5f3ca
commit 8026dc003b
29 changed files with 123 additions and 295 deletions
+1 -38
View File
@@ -138,21 +138,6 @@ static void Init_Service_Handlers(void)
apdu_set_reject_handler(MyRejectHandler);
}
#ifdef BIP_DEBUG
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");
}
}
#endif
int main(int argc, char *argv[])
{
BACNET_ADDRESS src = { 0 }; /* address where message came from */
@@ -165,9 +150,6 @@ int main(int argc, char *argv[])
time_t timeout_seconds = 0;
uint8_t invoke_id = 0;
bool found = false;
#ifdef BIP_DEBUG
BACNET_ADDRESS my_address, broadcast_address;
#endif
if (argc < 3) {
/* note: priority 16 and 0 should produce the same end results... */
@@ -202,27 +184,8 @@ int main(int argc, char *argv[])
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
#ifdef BACDL_ETHERNET
/* init the physical layer */
if (!ethernet_init("eth0"))
if (!datalink_init(NULL))
return 1;
#endif
#ifdef BACDL_BIP
bip_set_interface("eth0");
if (!bip_init())
return 1;
printf("bip: using port %hu\r\n", bip_get_port());
#ifdef BIP_DEBUG
datalink_get_broadcast_address(&broadcast_address);
print_address("Broadcast", &broadcast_address);
datalink_get_my_address(&my_address);
print_address("Address", &my_address);
#endif
#endif
#ifdef BACDL_ARCNET
if (!arcnet_init("arc0"))
return 1;
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
+2 -22
View File
@@ -342,28 +342,8 @@ int main(int argc, char *argv[])
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
#if defined(BACDL_ETHERNET)
/* init the physical layer */
if (!Network_Interface)
Network_Interface = "eth0";
if (!ethernet_init(Network_Interface))
return 1;
#elif defined(BACDL_BIP)
if (!Network_Interface)
Network_Interface = "eth0";
bip_set_interface(Network_Interface);
if (!bip_init())
return 1;
/* printf("bip: using port %hu\r\n", bip_get_port()); */
#elif defined(BACDL_ARCNET)
if (!Network_Interface)
Network_Interface = "arc0";
if (!arcnet_init(Network_Interface))
return 1;
#else
#error Define a datalink (BACDL_ETHERNET,BACDL_BIP, or BACDL_ARCNET)
#endif
Init_Service_Handlers();
datalink_init(Network_Interface);
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
+1 -14
View File
@@ -230,21 +230,8 @@ int main(int argc, char *argv[])
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
#ifdef BACDL_ETHERNET
/* init the physical layer */
if (!ethernet_init("eth0"))
if (!datalink_init(NULL))
return 1;
#endif
#ifdef BACDL_BIP
bip_set_interface("eth0");
if (!bip_init())
return 1;
printf("bip: using port %hu\r\n", bip_get_port());
#endif
#ifdef BACDL_ARCNET
if (!arcnet_init("arc0"))
return 1;
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
+1 -1
View File
@@ -20,7 +20,7 @@ CFLAGS = -Wall -g $(INCLUDES) $(DEFINES)
TARGET = bacrp
SRCS = readprop.c \
SRCS = main.c \
$(BACNET_PORT)/bip-init.c \
$(BACNET_PORT)/ethernet.c \
$(BACNET_PORT)/arcnet.c \
@@ -175,21 +175,8 @@ int main(int argc, char *argv[])
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
#if defined(BACDL_ETHERNET)
/* init the physical layer */
if (!ethernet_init("eth0"))
if (!datalink_init(NULL))
return 1;
#elif defined(BACDL_BIP)
bip_set_interface("eth0");
if (!bip_init())
return 1;
printf("bip: using port %hu\r\n", bip_get_port());
#elif defined(BACDL_ARCNET)
if (!arcnet_init("arc0"))
return 1;
#else
#error Datalink (BACDL_ETHERNET,BACDL_BIP, or BACDL_ARCNET) undefined
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
+1 -1
View File
@@ -17,7 +17,7 @@ PRODUCT_EXE = $(PRODUCT).exe
# Choose the Data Link Layer to Enable
DEFINES = -DBACDL_BIP=1;TSM_ENABLED=1;BIG_ENDIAN=0;PRINT_ENABLED=1
SRCS = readprop.c \
SRCS = main.c \
..\..\ports\win32\bip-init.c \
..\..\filename.c \
..\..\bip.c \
+6 -29
View File
@@ -133,21 +133,6 @@ static void Init_Service_Handlers(void)
apdu_set_reject_handler(MyRejectHandler);
}
#ifdef BIP_DEBUG
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");
}
}
#endif
int main(int argc, char *argv[])
{
BACNET_ADDRESS src = { 0 }; /* address where message came from */
@@ -160,9 +145,6 @@ int main(int argc, char *argv[])
time_t timeout_seconds = 0;
uint8_t invoke_id = 0;
bool found = false;
#ifdef BIP_DEBUG
BACNET_ADDRESS my_address, broadcast_address;
#endif
if (argc < 3) {
/* note: priority 16 and 0 should produce the same end results... */
@@ -199,17 +181,8 @@ int main(int argc, char *argv[])
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
if (!datalink_init(NULL))
return 1;
#ifdef BIP_DEBUG
datalink_get_broadcast_address(&broadcast_address);
print_address("Broadcast", &broadcast_address);
datalink_get_my_address(&my_address);
print_address("Address", &my_address);
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
@@ -223,7 +196,11 @@ int main(int argc, char *argv[])
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
pdu_len = datalink_receive(
&src,
&Rx_Buf[0],
MAX_MPDU,
timeout);
/* process */
if (pdu_len) {
+1 -14
View File
@@ -122,21 +122,8 @@ int main(int argc, char *argv[])
printf("BACnet Server Demo - Device #%u\r\n",
Device_Object_Instance_Number());
Init_Service_Handlers();
#ifdef BACDL_ETHERNET
/* init the physical layer */
if (!ethernet_init("eth0"))
if (!datalink_init(NULL))
return 1;
#endif
#ifdef BACDL_BIP
bip_set_interface("eth0");
if (!bip_init())
return 1;
printf("bip: using port %hu\r\n", bip_get_port());
#endif
#ifdef BACDL_ARCNET
if (!arcnet_init("arc0"))
return 1;
#endif
datalink_get_broadcast_address(&broadcast_address);
print_address("Broadcast", &broadcast_address);
datalink_get_my_address(&my_address);
+2 -30
View File
@@ -103,21 +103,6 @@ static void Init_Service_Handlers(void)
apdu_set_reject_handler(MyRejectHandler);
}
#ifdef BIP_DEBUG
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");
}
}
#endif
int main(int argc, char *argv[])
{
BACNET_ADDRESS src = { 0 }; /* address where message came from */
@@ -132,10 +117,6 @@ int main(int argc, char *argv[])
BACNET_DATE bdate;
BACNET_TIME btime;
#ifdef BIP_DEBUG
BACNET_ADDRESS my_address, broadcast_address;
#endif
/* FIXME: we could send directed time sync, and how do we send UTC? */
#if 0
if (argc < 2) {
@@ -164,17 +145,8 @@ int main(int argc, char *argv[])
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
if (!datalink_init(NULL))
return 1;
#ifdef BIP_DEBUG
datalink_get_broadcast_address(&broadcast_address);
print_address("Broadcast", &broadcast_address);
datalink_get_my_address(&my_address);
print_address("Address", &my_address);
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
@@ -195,7 +167,7 @@ int main(int argc, char *argv[])
/* increment timer - exit if timed out */
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
/* process */
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
+3 -9
View File
@@ -202,19 +202,13 @@ int main(int argc, char *argv[])
fprintf(stderr, "unable to parse the tag value\r\n");
return 1;
}
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
return 1;
Init_Service_Handlers();
if (!datalink_init(NULL))
return 1;
/* only one value in our value list */
cov_data.listOfValues.next = NULL;
ucov_notify_send(&Handler_Transmit_Buffer[0], &cov_data);
return 0;
+2 -29
View File
@@ -103,21 +103,6 @@ static void Init_Service_Handlers(void)
apdu_set_reject_handler(MyRejectHandler);
}
#ifdef BIP_DEBUG
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");
}
}
#endif
int main(int argc, char *argv[])
{
BACNET_ADDRESS src = { 0 }; /* address where message came from */
@@ -127,9 +112,6 @@ int main(int argc, char *argv[])
time_t last_seconds = 0;
time_t current_seconds = 0;
time_t timeout_seconds = 0;
#ifdef BIP_DEBUG
BACNET_ADDRESS my_address, broadcast_address;
#endif
if (argc < 2) {
/* note: priority 16 and 0 should produce the same end results... */
@@ -166,17 +148,8 @@ int main(int argc, char *argv[])
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
if (!datalink_init(NULL))
return 1;
#ifdef BIP_DEBUG
datalink_get_broadcast_address(&broadcast_address);
print_address("Broadcast", &broadcast_address);
datalink_get_my_address(&my_address);
print_address("Address", &my_address);
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
@@ -191,7 +164,7 @@ int main(int argc, char *argv[])
/* increment timer - exit if timed out */
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
/* process */
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
+2 -29
View File
@@ -99,21 +99,6 @@ static void Init_Service_Handlers(void)
apdu_set_reject_handler(MyRejectHandler);
}
#ifdef BIP_DEBUG
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");
}
}
#endif
static void print_address_cache(void)
{
int i, j;
@@ -144,9 +129,6 @@ int main(int argc, char *argv[])
time_t last_seconds = 0;
time_t current_seconds = 0;
time_t timeout_seconds = 0;
#ifdef BIP_DEBUG
BACNET_ADDRESS my_address, broadcast_address;
#endif
if (argc < 2) {
printf
@@ -186,17 +168,8 @@ int main(int argc, char *argv[])
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
if (!datalink_init(NULL))
return 1;
#ifdef BIP_DEBUG
datalink_get_broadcast_address(&broadcast_address);
print_address("Broadcast", &broadcast_address);
datalink_get_my_address(&my_address);
print_address("Address", &my_address);
#endif
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
@@ -207,7 +180,7 @@ int main(int argc, char *argv[])
/* increment timer - exit if timed out */
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
/* process */
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
+1 -1
View File
@@ -20,7 +20,7 @@ CFLAGS = -Wall -g $(INCLUDES) $(DEFINES)
TARGET = bacawf
SRCS = writefile.c \
SRCS = main.c \
$(BACNET_PORT)/bip-init.c \
$(BACNET_ROOT)/bip.c \
$(BACNET_HANDLER)/txbuf.c \
@@ -186,10 +186,7 @@ int main(int argc, char *argv[])
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
if (!datalink_init(NULL))
return 1;
/* configure the timeout values */
last_seconds = time(NULL);
@@ -204,7 +201,7 @@ int main(int argc, char *argv[])
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
/* process */
if (pdu_len) {
+1 -1
View File
@@ -17,7 +17,7 @@ PRODUCT_EXE = $(PRODUCT).exe
# Choose the Data Link Layer to Enable
DEFINES = -DBACDL_BIP=1;TSM_ENABLED=1;BIG_ENDIAN=0;PRINT_ENABLED=1
SRCS = writefile.c \
SRCS = main.c \
..\..\ports\win32\bip-init.c \
..\..\bip.c \
..\..\demo\handler\txbuf.c \
+3 -6
View File
@@ -310,11 +310,8 @@ int main(int argc, char *argv[])
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
address_init();
Init_Service_Handlers();
/* configure standard BACnet/IP port */
bip_set_interface("eth0"); /* for linux */
bip_set_port(0xBAC0);
if (!bip_init())
return 1;
if (!datalink_init(NULL))
return 1;
/* configure the timeout values */
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
@@ -328,7 +325,7 @@ int main(int argc, char *argv[])
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
/* process */
if (pdu_len) {