reverted the who-has back from the who-is copy-paste of the directory which included the CVS directory which checked in the who-is demo as the who-has demo. Aaarghh!

This commit is contained in:
skarg
2006-02-20 21:59:40 +00:00
parent b6e1d31f09
commit fbb3b45038
3 changed files with 75 additions and 99 deletions
+2 -3
View File
@@ -18,7 +18,7 @@ INCLUDES = -I$(BACNET_ROOT) -I$(BACNET_PORT) -I$(BACNET_OBJECT) -I$(BACNET_HANDL
CFLAGS = -Wall -g $(INCLUDES) $(DEFINES) CFLAGS = -Wall -g $(INCLUDES) $(DEFINES)
TARGET = bacwi TARGET = bacwh
SRCS = main.c \ SRCS = main.c \
$(BACNET_ROOT)/rd.c \ $(BACNET_ROOT)/rd.c \
@@ -28,10 +28,9 @@ SRCS = main.c \
$(BACNET_HANDLER)/noserv.c \ $(BACNET_HANDLER)/noserv.c \
$(BACNET_HANDLER)/h_whois.c \ $(BACNET_HANDLER)/h_whois.c \
$(BACNET_HANDLER)/h_ihave.c \ $(BACNET_HANDLER)/h_ihave.c \
$(BACNET_HANDLER)/h_iam.c \
$(BACNET_HANDLER)/h_rp.c \ $(BACNET_HANDLER)/h_rp.c \
$(BACNET_HANDLER)/s_whohas.c \
$(BACNET_HANDLER)/s_ihave.c \ $(BACNET_HANDLER)/s_ihave.c \
$(BACNET_HANDLER)/s_whois.c \
$(BACNET_OBJECT)/device.c \ $(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \ $(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/ao.c \ $(BACNET_OBJECT)/ao.c \
+31 -49
View File
@@ -32,6 +32,8 @@
#include <errno.h> #include <errno.h>
#include "bactext.h" #include "bactext.h"
#include "iam.h" #include "iam.h"
#include "arf.h"
#include "tsm.h"
#include "address.h" #include "address.h"
#include "config.h" #include "config.h"
#include "bacdef.h" #include "bacdef.h"
@@ -40,6 +42,7 @@
#include "device.h" #include "device.h"
#include "net.h" #include "net.h"
#include "datalink.h" #include "datalink.h"
#include "whohas.h"
/* some demo stuff needed */ /* some demo stuff needed */
#include "filename.h" #include "filename.h"
#include "handlers.h" #include "handlers.h"
@@ -50,8 +53,9 @@
static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/* global variables used in this file */ /* global variables used in this file */
static int32_t Target_Object_Instance_Min = 0; static BACNET_OBJECT_TYPE Target_Object_Type = MAX_BACNET_OBJECT_TYPE;
static int32_t Target_Object_Instance_Max = BACNET_MAX_INSTANCE; static uint32_t Target_Object_Instance = BACNET_MAX_INSTANCE;
static char *Target_Object_Name = NULL;
static bool Error_Detected = false; static bool Error_Detected = false;
@@ -91,8 +95,8 @@ static void Init_Service_Handlers(void)
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY, apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
handler_read_property); handler_read_property);
/* handle the reply (request) coming back */ /* handle the reply (request) coming back */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_HAVE,
handler_i_am_add); handler_i_have);
/* handle any errors coming back */ /* handle any errors coming back */
apdu_set_abort_handler(MyAbortHandler); apdu_set_abort_handler(MyAbortHandler);
apdu_set_reject_handler(MyRejectHandler); apdu_set_reject_handler(MyRejectHandler);
@@ -113,27 +117,6 @@ static void print_address(char *name, BACNET_ADDRESS * dest)
} }
#endif #endif
static void print_address_cache(void)
{
int i, j;
BACNET_ADDRESS address;
uint32_t device_id = 0;
unsigned max_apdu = 0;
fprintf(stderr, "Device\tMAC\tMaxAPDU\tNet\n");
for (i = 0; i < MAX_ADDRESS_CACHE; i++) {
if (address_get_by_index(i, &device_id, &max_apdu, &address)) {
fprintf(stderr, "%u\t", device_id);
for (j = 0; j < address.mac_len; j++) {
fprintf(stderr, "%02X", address.mac[j]);
}
fprintf(stderr, "\t");
fprintf(stderr, "%hu\t", max_apdu);
fprintf(stderr, "%hu\n", address.net);
}
}
}
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 */
@@ -148,38 +131,34 @@ int main(int argc, char *argv[])
#endif #endif
if (argc < 2) { if (argc < 2) {
printf("Usage: %s device-instance | device-instance-min device-instance-max\r\n" /* note: priority 16 and 0 should produce the same end results... */
"Send BACnet WhoIs request to devices, and wait for responses.\r\n" printf("Usage: %s <object-type object-instance | object-name>\r\n"
"Send BACnet WhoHas request to devices, and wait for responses.\r\n"
"\r\n" "\r\n"
"The device-instance can be 0 to %d, or -1 for ALL.\r\n" "Use either:\r\n"
"The device-instance can also be specified as a range.\r\n", "The object-type can be 0 to %d.\r\n"
"The object-instance can be 0 to %d.\r\n"
"or:\r\n"
"The object-name can be any string of characters.\r\n",
filename_remove_path(argv[0]), filename_remove_path(argv[0]),
BACNET_MAX_INSTANCE); MAX_BACNET_OBJECT_TYPE - 1, BACNET_MAX_INSTANCE);
return 0; return 0;
} }
/* decode the command line parameters */ /* decode the command line parameters */
if (argc < 3) { if (argc < 3) {
Target_Object_Instance_Min = strtol(argv[1], NULL, 0); Target_Object_Name = argv[1];
Target_Object_Instance_Max = Target_Object_Instance_Min;
if (Target_Object_Instance_Min > BACNET_MAX_INSTANCE) {
fprintf(stderr,
"object-instance-min=%u - it must be less than %u\r\n",
Target_Object_Instance_Min, BACNET_MAX_INSTANCE + 1);
return 1;
}
} else { } else {
Target_Object_Instance_Min = strtol(argv[1], NULL, 0); Target_Object_Type = strtol(argv[1], NULL, 0);
Target_Object_Instance_Max = strtol(argv[2], NULL, 0); Target_Object_Instance = strtol(argv[2], NULL, 0);
if (Target_Object_Instance_Min > BACNET_MAX_INSTANCE) { if (Target_Object_Instance > BACNET_MAX_INSTANCE) {
fprintf(stderr, fprintf(stderr,
"object-instance-min=%u - it must be less than %u\r\n", "object-instance=%u - it must be less than %u\r\n",
Target_Object_Instance_Min, BACNET_MAX_INSTANCE + 1); Target_Object_Instance, BACNET_MAX_INSTANCE + 1);
return 1; return 1;
} }
if (Target_Object_Instance_Max > BACNET_MAX_INSTANCE) { if (Target_Object_Type > MAX_BACNET_OBJECT_TYPE) {
fprintf(stderr, fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
"object-instance-max=%u - it must be less than %u\r\n", Target_Object_Type, MAX_BACNET_OBJECT_TYPE + 1);
Target_Object_Instance_Max, BACNET_MAX_INSTANCE + 1);
return 1; return 1;
} }
} }
@@ -201,7 +180,11 @@ int main(int argc, char *argv[])
last_seconds = time(NULL); last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000; timeout_seconds = Device_APDU_Timeout() / 1000;
/* send the request */ /* send the request */
Send_WhoIs(Target_Object_Instance_Min, Target_Object_Instance_Max); if (argc < 3)
Send_WhoHas_Name(-1, -1, Target_Object_Name);
else
Send_WhoHas_Object(-1, -1,
Target_Object_Type, Target_Object_Instance);
/* loop forever */ /* loop forever */
for (;;) { for (;;) {
/* increment timer - exit if timed out */ /* increment timer - exit if timed out */
@@ -221,7 +204,6 @@ int main(int argc, char *argv[])
/* keep track of time for next check */ /* keep track of time for next check */
last_seconds = current_seconds; last_seconds = current_seconds;
} }
print_address_cache();
return 0; return 0;
} }
+42 -47
View File
@@ -11,54 +11,49 @@ BORLAND_DIR_Not_Defined:
@echo You must define environment variable BORLAND_DIR to compile. @echo You must define environment variable BORLAND_DIR to compile.
!endif !endif
PRODUCT = bacwi PRODUCT = bacwh
PRODUCT_EXE = $(PRODUCT).exe PRODUCT_EXE = $(PRODUCT).exe
# Choose the Data Link Layer to Enable # Choose the Data Link Layer to Enable
DEFINES = -DBACDL_BIP=1;TSM_ENABLED=0;USE_INADDR=1 DEFINES = -DBACDL_BIP=1;TSM_ENABLED=0;USE_INADDR=1
# Directories
BACNET_PORT = ..\..\ports\win32
BACNET_OBJECT = ..\object
BACNET_HANDLER = ..\handler
BACNET_ROOT = ..\..
SRCS = main.c \ SRCS = main.c \
$(BACNET_PORT)\bip-init.c \ ..\..\rd.c \
$(BACNET_ROOT)\bip.c \ ..\..\ports\win32\bip-init.c \
$(BACNET_HANDLER)\txbuf.c \ ..\..\filename.c \
$(BACNET_HANDLER)\noserv.c \ ..\..\bip.c \
$(BACNET_HANDLER)\h_whois.c \ ..\..\demo\handler\txbuf.c \
$(BACNET_HANDLER)\h_iam.c \ ..\..\demo\handler\noserv.c \
$(BACNET_HANDLER)\h_rp.c \ ..\..\demo\handler\h_whois.c \
$(BACNET_HANDLER)\s_whois.c \ ..\..\demo\handler\h_ihave.c \
$(BACNET_OBJECT)\bacfile.c \ ..\..\demo\handler\h_rp.c \
$(BACNET_OBJECT)\device.c \ ..\..\demo\handler\s_ihave.c \
$(BACNET_OBJECT)\ai.c \ ..\..\demo\handler\s_whohas.c \
$(BACNET_OBJECT)\ao.c \ ..\..\bacdcode.c \
$(BACNET_ROOT)\address.c \ ..\..\bacapp.c \
$(BACNET_ROOT)\filename.c \ ..\..\bacstr.c \
$(BACNET_ROOT)\bacdcode.c \ ..\..\bactext.c \
$(BACNET_ROOT)\bacapp.c \ ..\..\indtext.c \
$(BACNET_ROOT)\bacstr.c \ ..\..\bigend.c \
$(BACNET_ROOT)\bactext.c \ ..\..\whois.c \
$(BACNET_ROOT)\indtext.c \ ..\..\iam.c \
$(BACNET_ROOT)\bigend.c \ ..\..\whohas.c \
$(BACNET_ROOT)\whois.c \ ..\..\ihave.c \
$(BACNET_ROOT)\iam.c \ ..\..\rp.c \
$(BACNET_ROOT)\whohas.c \ ..\..\wp.c \
$(BACNET_ROOT)\ihave.c \ ..\..\arf.c \
$(BACNET_ROOT)\rd.c \ ..\..\awf.c \
$(BACNET_ROOT)\rp.c \ ..\..\dcc.c \
$(BACNET_ROOT)\wp.c \ ..\..\demo\object\bacfile.c \
$(BACNET_ROOT)\arf.c \ ..\..\demo\object\device.c \
$(BACNET_ROOT)\awf.c \ ..\..\demo\object\ai.c \
$(BACNET_ROOT)\dcc.c \ ..\..\demo\object\ao.c \
$(BACNET_ROOT)\datalink.c \ ..\..\datalink.c \
$(BACNET_ROOT)\abort.c \ ..\..\abort.c \
$(BACNET_ROOT)\reject.c \ ..\..\reject.c \
$(BACNET_ROOT)\bacerror.c \ ..\..\bacerror.c \
$(BACNET_ROOT)\apdu.c \ ..\..\apdu.c \
$(BACNET_ROOT)\npdu.c ..\..\npdu.c
OBJS = $(SRCS:.c=.obj) OBJS = $(SRCS:.c=.obj)
@@ -73,7 +68,7 @@ TLIB = $(BORLAND_DIR)\bin\tlib
# Include directories # Include directories
# #
CC_DIR = $(BORLAND_DIR)\BIN CC_DIR = $(BORLAND_DIR)\BIN
INCL_DIRS = -I$(BORLAND_DIR)\include;$(BACNET_ROOT)\;$(BACNET_OBJECT)\;$(BACNET_HANDLER)\;$(BACNET_PORT)\;. INCL_DIRS = -I$(BORLAND_DIR)\include;..\..\;..\..\demo\object\;..\..\demo\handler\;..\..\ports\win32\;.
CFLAGS = $(INCL_DIRS) $(CS_FLAGS) $(DEFINES) CFLAGS = $(INCL_DIRS) $(CS_FLAGS) $(DEFINES)
@@ -112,10 +107,10 @@ clean :
@echo Deleting obj files, $(PRODUCT_EXE) and map files. @echo Deleting obj files, $(PRODUCT_EXE) and map files.
# del $(OBJS) # command too long, bummer! # del $(OBJS) # command too long, bummer!
del *.obj del *.obj
del $(BACNET_ROOT)\*.obj del ..\..\*.obj
del $(BACNET_HANDLER)\*.obj del ..\..\demo\handler\*.obj
del $(BACNET_OBJECT)\*.obj del ..\..\demo\object\*.obj
del $(BACNET_PORT)\*.obj del ..\..\ports\win32\*.obj
del $(PRODUCT_EXE) del $(PRODUCT_EXE)
del *.map del *.map
del bcc32.cfg del bcc32.cfg