Added command line option for setting the Device Name in the demo server project.
This commit is contained in:
@@ -742,6 +742,11 @@ bool Device_Set_Object_Name(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device_Object_Name_ANSI_Init(const char * value)
|
||||||
|
{
|
||||||
|
return characterstring_init_ansi(&My_Object_Name, value);
|
||||||
|
}
|
||||||
|
|
||||||
BACNET_DEVICE_STATUS Device_System_Status(
|
BACNET_DEVICE_STATUS Device_System_Status(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ extern "C" {
|
|||||||
BACNET_OBJECT_TYPE object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
BACNET_CHARACTER_STRING * object_name);
|
BACNET_CHARACTER_STRING * object_name);
|
||||||
|
bool Device_Object_Name_ANSI_Init(const char * object_name);
|
||||||
|
|
||||||
BACNET_DEVICE_STATUS Device_System_Status(
|
BACNET_DEVICE_STATUS Device_System_Status(
|
||||||
void);
|
void);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include "bacfile.h"
|
#include "bacfile.h"
|
||||||
#include "datalink.h"
|
#include "datalink.h"
|
||||||
#include "dcc.h"
|
#include "dcc.h"
|
||||||
|
#include "filename.h"
|
||||||
#include "getevent.h"
|
#include "getevent.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "txbuf.h"
|
#include "txbuf.h"
|
||||||
@@ -134,6 +135,27 @@ static void Init_Service_Handlers(
|
|||||||
#endif /* defined(INTRINSIC_REPORTING) */
|
#endif /* defined(INTRINSIC_REPORTING) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_usage(char *filename)
|
||||||
|
{
|
||||||
|
printf("Usage: %s [device-instance [device-name]]\n", filename);
|
||||||
|
printf(" [--version][--help]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_help(char *filename)
|
||||||
|
{
|
||||||
|
printf("Simulate a BACnet server device\n"
|
||||||
|
"device-instance:\n"
|
||||||
|
"BACnet Device Object Instance number that you are\n"
|
||||||
|
"trying simulate.\n"
|
||||||
|
"device-name:\n"
|
||||||
|
"The Device object-name is the text name for the device.\n"
|
||||||
|
"\nExample:\n");
|
||||||
|
printf("To simulate Device 123, use the following command:\n"
|
||||||
|
"%s 123\n", filename);
|
||||||
|
printf("To simulate Device 123 named Fred, use following command:\n"
|
||||||
|
"%s 123 Fred\n", filename);
|
||||||
|
}
|
||||||
|
|
||||||
/** Main function of server demo.
|
/** Main function of server demo.
|
||||||
*
|
*
|
||||||
* @see Device_Set_Object_Instance_Number, dlenv_init, Send_I_Am,
|
* @see Device_Set_Object_Instance_Number, dlenv_init, Send_I_Am,
|
||||||
@@ -164,7 +186,27 @@ int main(
|
|||||||
#if defined(BAC_UCI)
|
#if defined(BAC_UCI)
|
||||||
int uciId = 0;
|
int uciId = 0;
|
||||||
struct uci_context *ctx;
|
struct uci_context *ctx;
|
||||||
|
#endif
|
||||||
|
int argi = 0;
|
||||||
|
char *filename = NULL;
|
||||||
|
|
||||||
|
filename = filename_remove_path(argv[0]);
|
||||||
|
for (argi = 1; argi < argc; argi++) {
|
||||||
|
if (strcmp(argv[argi], "--help") == 0) {
|
||||||
|
print_usage(filename);
|
||||||
|
print_help(filename);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (strcmp(argv[argi], "--version") == 0) {
|
||||||
|
printf("%s %s\n", filename, BACNET_VERSION_TEXT);
|
||||||
|
printf("Copyright (C) 2014 by Steve Karg and others.\n"
|
||||||
|
"This is free software; see the source for copying conditions.\n"
|
||||||
|
"There is NO warranty; not even for MERCHANTABILITY or\n"
|
||||||
|
"FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if defined(BAC_UCI)
|
||||||
ctx = ucix_init("bacnet_dev");
|
ctx = ucix_init("bacnet_dev");
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||||
@@ -175,8 +217,12 @@ int main(
|
|||||||
} else {
|
} else {
|
||||||
#endif /* defined(BAC_UCI) */
|
#endif /* defined(BAC_UCI) */
|
||||||
/* allow the device ID to be set */
|
/* allow the device ID to be set */
|
||||||
if (argc > 1)
|
if (argc > 1) {
|
||||||
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
|
Device_Set_Object_Instance_Number(strtol(argv[1], NULL, 0));
|
||||||
|
}
|
||||||
|
if (argc > 2) {
|
||||||
|
Device_Object_Name_ANSI_Init(argv[2]);
|
||||||
|
}
|
||||||
#if defined(BAC_UCI)
|
#if defined(BAC_UCI)
|
||||||
}
|
}
|
||||||
ucix_cleanup(ctx);
|
ucix_cleanup(ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user