Cleaned up device object and server demo for MS/TP properties and compiler warnings.

This commit is contained in:
skarg
2007-07-20 00:42:49 +00:00
parent a2c12b4d12
commit f25766c185
3 changed files with 43 additions and 11 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
/************************************************************************** /**************************************************************************
* *
* Copyright (C) 2007 Steve Karg <skarg@users.sourceforge.net> * Copyright (C) 2007 Steve Karg <skarg@users.sourceforge.net>
* Inspired by John Stachler. * Inspired by John Stachler <John.Stachler@lennoxind.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
+35 -8
View File
@@ -46,7 +46,9 @@
#if BACFILE #if BACFILE
#include "bacfile.h" /* object list dependency */ #include "bacfile.h" /* object list dependency */
#endif #endif
#if defined(BACDL_MSTP)
#include "dlmstp.h"
#endif
/* These three arrays are used by the ReadPropertyMultiple handler */ /* These three arrays are used by the ReadPropertyMultiple handler */
static const int Device_Properties_Required[] = static const int Device_Properties_Required[] =
{ {
@@ -891,7 +893,6 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_INVALID_DATA_TYPE; *error_code = ERROR_CODE_INVALID_DATA_TYPE;
} }
break; break;
case PROP_NUMBER_OF_APDU_RETRIES: case PROP_NUMBER_OF_APDU_RETRIES:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
@@ -903,7 +904,6 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_INVALID_DATA_TYPE; *error_code = ERROR_CODE_INVALID_DATA_TYPE;
} }
break; break;
case PROP_APDU_TIMEOUT: case PROP_APDU_TIMEOUT:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
@@ -914,7 +914,6 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_INVALID_DATA_TYPE; *error_code = ERROR_CODE_INVALID_DATA_TYPE;
} }
break; break;
case PROP_VENDOR_IDENTIFIER: case PROP_VENDOR_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) { if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
@@ -926,7 +925,6 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_INVALID_DATA_TYPE; *error_code = ERROR_CODE_INVALID_DATA_TYPE;
} }
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) { if (value.tag == BACNET_APPLICATION_TAG_ENUMERATED) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
@@ -937,7 +935,6 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_INVALID_DATA_TYPE; *error_code = ERROR_CODE_INVALID_DATA_TYPE;
} }
break; break;
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) { if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
uint8_t encoding; uint8_t encoding;
@@ -961,8 +958,38 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_INVALID_DATA_TYPE; *error_code = ERROR_CODE_INVALID_DATA_TYPE;
} }
break; break;
#if defined(BACDL_MSTP)
default: case PROP_MAX_INFO_FRAMES:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames(value.type.Unsigned_Int);
status = true;
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
}
break;
case PROP_MAX_MASTER:
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
if ((value.type.Unsigned_Int > 0) &&
(value.type.Unsigned_Int <= 127)) {
dlmstp_set_max_master(value.type.Unsigned_Int);
status = true;
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_INVALID_DATA_TYPE;
}
break;
#endif
default:
*error_class = ERROR_CLASS_PROPERTY; *error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED; *error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break; break;
+7 -2
View File
@@ -45,6 +45,9 @@
#include "net.h" #include "net.h"
#include "txbuf.h" #include "txbuf.h"
#include "lc.h" #include "lc.h"
#if defined(BACDL_MSTP)
#include "rs485.h"
#endif
/* This is an example server application using the BACnet Stack */ /* This is an example server application using the BACnet Stack */
@@ -122,8 +125,10 @@ int main(int argc, char *argv[])
} }
#endif #endif
printf("BACnet Server Demo\n" printf("BACnet Server Demo\n"
"BACnet Device ID: %u\r\n", "BACnet Device ID: %u\n"
Device_Object_Instance_Number()); "Max APDU: %d\n",
Device_Object_Instance_Number(),
MAX_APDU);
Init_Service_Handlers(); Init_Service_Handlers();
if (!datalink_init(Network_Interface)) if (!datalink_init(Network_Interface))
return 1; return 1;