Updated BDK device object to have minimum length. Updated other BDK objects to use sprintf since it was already in use in another object.
This commit is contained in:
@@ -34,9 +34,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
/* Analog Input */
|
/* Analog Input */
|
||||||
|
#ifndef MAX_ANALOG_INPUTS
|
||||||
#define MAX_ANALOG_INPUTS 2
|
#define MAX_ANALOG_INPUTS 2
|
||||||
#if (MAX_ANALOG_INPUTS > 9)
|
|
||||||
#error Modify the Analog_Input_Name to handle multiple digits
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t Present_Value[MAX_ANALOG_INPUTS];
|
static uint8_t Present_Value[MAX_ANALOG_INPUTS];
|
||||||
@@ -113,10 +112,10 @@ uint32_t Analog_Input_Index_To_Instance(
|
|||||||
char *Analog_Input_Name(
|
char *Analog_Input_Name(
|
||||||
uint32_t object_instance)
|
uint32_t object_instance)
|
||||||
{
|
{
|
||||||
static char text_string[16] = "AI-0"; /* okay for single thread */
|
static char text_string[32]; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_ANALOG_INPUTS) {
|
if (object_instance < MAX_ANALOG_INPUTS) {
|
||||||
text_string[3] = '0' + (uint8_t) object_instance;
|
sprintf(text_string, "AI-%lu", object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,8 @@
|
|||||||
#include "bacenum.h"
|
#include "bacenum.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifndef MAX_BINARY_INPUTS
|
||||||
#define MAX_BINARY_INPUTS 8
|
#define MAX_BINARY_INPUTS 8
|
||||||
#if (MAX_BINARY_INPUTS > 9)
|
|
||||||
#error Modify the Binary_Input_Name to handle multiple digits
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static BACNET_BINARY_PV Present_Value[MAX_BINARY_INPUTS];
|
static BACNET_BINARY_PV Present_Value[MAX_BINARY_INPUTS];
|
||||||
@@ -164,10 +163,10 @@ bool Binary_Input_Present_Value_Set(
|
|||||||
char *Binary_Input_Name(
|
char *Binary_Input_Name(
|
||||||
uint32_t object_instance)
|
uint32_t object_instance)
|
||||||
{
|
{
|
||||||
static char text_string[16] = "BI-0"; /* okay for single thread */
|
static char text_string[32]; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_INPUTS) {
|
if (object_instance < MAX_BINARY_INPUTS) {
|
||||||
text_string[3] = '0' + (uint8_t) object_instance;
|
sprintf(text_string, "BI-%lu", object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,8 @@
|
|||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "nvdata.h"
|
#include "nvdata.h"
|
||||||
|
|
||||||
|
#ifndef MAX_BINARY_OUTPUTS
|
||||||
#define MAX_BINARY_OUTPUTS 2
|
#define MAX_BINARY_OUTPUTS 2
|
||||||
#if (MAX_BINARY_OUTPUTS > 9)
|
|
||||||
#error Modify the Binary_Output_Name to handle multiple digits
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* When all the priorities are level null, the present value returns */
|
/* When all the priorities are level null, the present value returns */
|
||||||
@@ -241,10 +240,10 @@ void Binary_Output_Level_Sync(
|
|||||||
char *Binary_Output_Name(
|
char *Binary_Output_Name(
|
||||||
uint32_t object_instance)
|
uint32_t object_instance)
|
||||||
{
|
{
|
||||||
static char text_string[16] = "BV-0"; /* okay for single thread */
|
static char text_string[32]; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_OUTPUTS) {
|
if (object_instance < MAX_BINARY_OUTPUTS) {
|
||||||
text_string[3] = '0' + (uint8_t) object_instance;
|
sprintf(text_string, "BO-%lu", object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "bacdef.h"
|
#include "bacdef.h"
|
||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
#include "bacstr.h"
|
#include "bacstr.h"
|
||||||
@@ -119,6 +120,7 @@ void Device_Init(
|
|||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
Reinitialize_State = REINITIALIZED_STATE_IDLE;
|
Reinitialize_State = REINITIALIZED_STATE_IDLE;
|
||||||
|
|
||||||
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
|
dcc_set_status_duration(COMMUNICATION_ENABLE, 0);
|
||||||
/* Get the data from the eeprom */
|
/* Get the data from the eeprom */
|
||||||
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & Object_Instance_Number,
|
eeprom_bytes_read(NV_EEPROM_DEVICE_0, (uint8_t *) & Object_Instance_Number,
|
||||||
@@ -137,11 +139,14 @@ void Device_Init(
|
|||||||
if ((Object_Name_Encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
if ((Object_Name_Encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
||||||
(Object_Name_Length > NV_EEPROM_DEVICE_NAME_SIZE)) {
|
(Object_Name_Length > NV_EEPROM_DEVICE_NAME_SIZE)) {
|
||||||
Object_Name_Encoding = CHARACTER_ANSI_X34;
|
Object_Name_Encoding = CHARACTER_ANSI_X34;
|
||||||
Object_Name_Length = 0;
|
Object_Name_Length = 11;
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
|
||||||
&Object_Name_Encoding, 1);
|
&Object_Name_Encoding, 1);
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &Object_Name_Length,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &Object_Name_Length,
|
||||||
1);
|
1);
|
||||||
|
sprintf(Object_Name, "DEVICE-%lu", Object_Instance_Number);
|
||||||
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & Object_Name[0],
|
||||||
|
NV_EEPROM_DEVICE_NAME_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +588,10 @@ bool Device_Write_Property(
|
|||||||
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||||
size_t length =
|
size_t length =
|
||||||
characterstring_length(&value.type.Character_String);
|
characterstring_length(&value.type.Character_String);
|
||||||
if (length < NV_EEPROM_DEVICE_NAME_SIZE) {
|
if (length < 1) {
|
||||||
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
|
} else if (length < NV_EEPROM_DEVICE_NAME_SIZE) {
|
||||||
uint8_t encoding =
|
uint8_t encoding =
|
||||||
characterstring_encoding(&value.type.Character_String);
|
characterstring_encoding(&value.type.Character_String);
|
||||||
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
|
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
|
||||||
|
|||||||
Reference in New Issue
Block a user