Added ability to specify the BACnet/IP interface on multi-homed machines from the command line demo for demo/epics on a Win32 platform.
This commit is contained in:
@@ -57,7 +57,8 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
||||
/* global variables used in this file */
|
||||
static uint32_t Target_Device_Object_Instance = BACNET_MAX_INSTANCE;
|
||||
static bool Error_Detected = false;
|
||||
static BACNET_ADDRESS Target_Address;
|
||||
static BACNET_ADDRESS Target_Address;
|
||||
static char *Network_Interface = NULL;
|
||||
|
||||
typedef struct BACnet_RP_Service_Data_t {
|
||||
bool new_data;
|
||||
@@ -267,7 +268,48 @@ static uint8_t Read_Properties(uint32_t device_instance)
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
}
|
||||
}
|
||||
|
||||
static void Interpret_Arguments(int argc, char *argv[])
|
||||
{
|
||||
int i = 0, j = 0; /* used to index through arguments */
|
||||
char *p_arg = NULL; /* points to current argument */
|
||||
long number = 0; /* used for strtol */
|
||||
char *p_data = NULL; /* points to data portion of argument */
|
||||
|
||||
if (!argv)
|
||||
return;
|
||||
|
||||
/* skip 1st one [0] - its the command line for the filename */
|
||||
for (i = 1; i < argc; i++) {
|
||||
p_arg = argv[i];
|
||||
if (p_arg[0] == '-') {
|
||||
p_data = p_arg + 2;
|
||||
switch (p_arg[1]) {
|
||||
case 'a':
|
||||
bip_set_addr(inet_addr(p_data));
|
||||
break;
|
||||
case 'd':
|
||||
Network_Interface = p_data;
|
||||
break;
|
||||
/* double dash */
|
||||
case '-':
|
||||
if (strcmp(p_data, "help") == 0) {
|
||||
printf
|
||||
("%s device-instance\r\n",
|
||||
filename_remove_path(argv[0]));
|
||||
}
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
break;
|
||||
} /* end of arguments beginning with - */
|
||||
} /* dash arguments */
|
||||
} /* end of arg loop */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -288,11 +330,13 @@ int main(int argc, char *argv[])
|
||||
filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
}
|
||||
Interpret_Arguments(argc, argv);
|
||||
|
||||
/* decode the command line parameters */
|
||||
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
||||
if (Target_Device_Object_Instance >= BACNET_MAX_INSTANCE) {
|
||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE+1);
|
||||
return 1;
|
||||
}
|
||||
/* setup my info */
|
||||
@@ -300,19 +344,25 @@ int main(int argc, char *argv[])
|
||||
address_init();
|
||||
Init_Service_Handlers();
|
||||
#if defined(BACDL_ETHERNET)
|
||||
/* init the physical layer */
|
||||
if (!ethernet_init("eth0"))
|
||||
/* init the physical layer */
|
||||
if (!Network_Interface)
|
||||
Network_Interface = "eth0";
|
||||
if (!ethernet_init(Network_Interface))
|
||||
return 1;
|
||||
#elif defined(BACDL_BIP)
|
||||
bip_set_interface("eth0");
|
||||
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 (!arcnet_init("arc0"))
|
||||
if (!Network_Interface)
|
||||
Network_Interface = "arc0";
|
||||
if (!arcnet_init(Network_Interface))
|
||||
return 1;
|
||||
#else
|
||||
#error Datalink (BACDL_ETHERNET,BACDL_BIP, or BACDL_ARCNET) undefined
|
||||
#error Define a datalink (BACDL_ETHERNET,BACDL_BIP, or BACDL_ARCNET)
|
||||
#endif
|
||||
/* configure the timeout values */
|
||||
last_seconds = time(NULL);
|
||||
|
||||
@@ -15,7 +15,7 @@ PRODUCT = bacepics
|
||||
PRODUCT_EXE = $(PRODUCT).exe
|
||||
|
||||
# Choose the Data Link Layer to Enable
|
||||
DEFINES = -DBACDL_BIP=1;TSM_ENABLED=1;BIG_ENDIAN=0;PRINT_ENABLED=1
|
||||
DEFINES = -DBACDL_BIP=1;TSM_ENABLED=1;BIG_ENDIAN=0;PRINT_ENABLED=1;BIP_DEBUG=0
|
||||
|
||||
SRCS = main.c \
|
||||
..\..\ports\win32\bip-init.c \
|
||||
|
||||
Reference in New Issue
Block a user