Added WhoHas/I-Have services.
Simplified the BO writes from main.
This commit is contained in:
@@ -84,6 +84,8 @@ extern "C" {
|
|||||||
bool Binary_Output_Write_Property(
|
bool Binary_Output_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
|
BACNET_BINARY_PV Binary_Output_Present_Value(
|
||||||
|
uint32_t instance);
|
||||||
bool Binary_Output_Present_Value_Set(
|
bool Binary_Output_Present_Value_Set(
|
||||||
uint32_t instance,
|
uint32_t instance,
|
||||||
BACNET_BINARY_PV binary_value,
|
BACNET_BINARY_PV binary_value,
|
||||||
|
|||||||
@@ -74,7 +74,9 @@ DEMOSRC = $(BACNET_DEMO)/handler/txbuf.c \
|
|||||||
$(BACNET_DEMO)/handler/h_wp.c \
|
$(BACNET_DEMO)/handler/h_wp.c \
|
||||||
$(BACNET_DEMO)/handler/h_rp.c \
|
$(BACNET_DEMO)/handler/h_rp.c \
|
||||||
$(BACNET_DEMO)/handler/h_rpm.c \
|
$(BACNET_DEMO)/handler/h_rpm.c \
|
||||||
|
$(BACNET_DEMO)/handler/h_whohas.c \
|
||||||
$(BACNET_DEMO)/handler/s_iam.c \
|
$(BACNET_DEMO)/handler/s_iam.c \
|
||||||
|
$(BACNET_DEMO)/handler/s_ihave.c \
|
||||||
$(BACNET_DEMO)/handler/noserv.c
|
$(BACNET_DEMO)/handler/noserv.c
|
||||||
|
|
||||||
# core BACnet stack files
|
# core BACnet stack files
|
||||||
@@ -89,12 +91,14 @@ CORESRC = \
|
|||||||
$(BACNET_CORE)/bacreal.c \
|
$(BACNET_CORE)/bacreal.c \
|
||||||
$(BACNET_CORE)/bacstr.c \
|
$(BACNET_CORE)/bacstr.c \
|
||||||
$(BACNET_CORE)/iam.c \
|
$(BACNET_CORE)/iam.c \
|
||||||
|
$(BACNET_CORE)/ihave.c \
|
||||||
$(BACNET_CORE)/dcc.c \
|
$(BACNET_CORE)/dcc.c \
|
||||||
$(BACNET_CORE)/rp.c \
|
$(BACNET_CORE)/rp.c \
|
||||||
$(BACNET_CORE)/rd.c \
|
$(BACNET_CORE)/rd.c \
|
||||||
$(BACNET_CORE)/rpm.c \
|
$(BACNET_CORE)/rpm.c \
|
||||||
$(BACNET_CORE)/wp.c \
|
$(BACNET_CORE)/wp.c \
|
||||||
$(BACNET_CORE)/whois.c \
|
$(BACNET_CORE)/whois.c \
|
||||||
|
$(BACNET_CORE)/whohas.c \
|
||||||
$(BACNET_CORE)/bacaddr.c \
|
$(BACNET_CORE)/bacaddr.c \
|
||||||
$(BACNET_CORE)/abort.c \
|
$(BACNET_CORE)/abort.c \
|
||||||
$(BACNET_CORE)/reject.c \
|
$(BACNET_CORE)/reject.c \
|
||||||
@@ -137,8 +141,8 @@ DEFINES =
|
|||||||
OPTIMIZE_FLAGS = -mcall-prologues
|
OPTIMIZE_FLAGS = -mcall-prologues
|
||||||
OPTIMIZE_FLAGS += -finline-functions-called-once
|
OPTIMIZE_FLAGS += -finline-functions-called-once
|
||||||
# default is for debugging from AVR Studio
|
# default is for debugging from AVR Studio
|
||||||
OPTIMIZATION = -O0
|
OPTIMIZATION = -Os $(OPTIMIZE_FLAGS)
|
||||||
DEBUGGING = -g
|
DEBUGGING =
|
||||||
ifeq (${BUILD},debug)
|
ifeq (${BUILD},debug)
|
||||||
OPTIMIZATION = -O0
|
OPTIMIZATION = -O0
|
||||||
DEBUGGING = -g
|
DEBUGGING = -g
|
||||||
|
|||||||
Binary file not shown.
@@ -150,7 +150,7 @@ static BACNET_BINARY_PV Present_Value(
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BACNET_BINARY_PV Binary_Output_Present_Value(
|
BACNET_BINARY_PV Binary_Output_Present_Value(
|
||||||
uint32_t object_instance)
|
uint32_t object_instance)
|
||||||
{
|
{
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
@@ -160,7 +160,7 @@ static BACNET_BINARY_PV Binary_Output_Present_Value(
|
|||||||
return Present_Value(index);
|
return Present_Value(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Binary_Output_Level_Sync(
|
static void Binary_Output_Level_Sync(
|
||||||
uint32_t instance)
|
uint32_t instance)
|
||||||
{
|
{
|
||||||
BACNET_BINARY_PV pv;
|
BACNET_BINARY_PV pv;
|
||||||
@@ -198,19 +198,25 @@ void Binary_Output_Level_Sync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Binary_Output_Level_Set(
|
bool Binary_Output_Present_Value_Set(
|
||||||
uint32_t instance,
|
uint32_t instance,
|
||||||
unsigned int priority,
|
BACNET_BINARY_PV binary_value,
|
||||||
BACNET_BINARY_PV level)
|
unsigned priority) /* 0..15 */
|
||||||
{
|
{
|
||||||
|
bool status = false;
|
||||||
|
|
||||||
if (instance < MAX_BINARY_OUTPUTS) {
|
if (instance < MAX_BINARY_OUTPUTS) {
|
||||||
if (priority < BACNET_MAX_PRIORITY) {
|
if (priority < BACNET_MAX_PRIORITY) {
|
||||||
Binary_Output_Level[instance][priority] = (uint8_t) level;
|
Binary_Output_Level[instance][priority] = (uint8_t) binary_value;
|
||||||
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(instance,
|
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(instance,
|
||||||
NV_SEEPROM_BO_PRIORITY_ARRAY_1 + priority),
|
NV_SEEPROM_BO_PRIORITY_ARRAY_1 + priority),
|
||||||
&Binary_Output_Level[instance][priority], 1);
|
&Binary_Output_Level[instance][priority], 1);
|
||||||
|
Binary_Output_Level_Sync(instance);
|
||||||
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Binary_Output_Polarity_Set(
|
void Binary_Output_Polarity_Set(
|
||||||
@@ -434,10 +440,9 @@ bool Binary_Output_Write_Property(
|
|||||||
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
(value.type.Enumerated <= MAX_BINARY_PV)) {
|
||||||
level = (BACNET_BINARY_PV) value.type.Enumerated;
|
level = (BACNET_BINARY_PV) value.type.Enumerated;
|
||||||
priority--;
|
priority--;
|
||||||
Binary_Output_Level_Set(
|
Binary_Output_Present_Value_Set(
|
||||||
wp_data->object_instance,
|
wp_data->object_instance,
|
||||||
priority, level);
|
level, priority);
|
||||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
|
||||||
} else if (priority == 6) {
|
} else if (priority == 6) {
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
algorithm and may not be used for other purposes in any
|
algorithm and may not be used for other purposes in any
|
||||||
@@ -460,10 +465,9 @@ bool Binary_Output_Write_Property(
|
|||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
Binary_Output_Level_Set(
|
Binary_Output_Present_Value_Set(
|
||||||
wp_data->object_instance,
|
wp_data->object_instance,
|
||||||
priority, level);
|
level, priority);
|
||||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
|
||||||
} else if (priority == 6) {
|
} else if (priority == 6) {
|
||||||
status = false;
|
status = false;
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
|
|||||||
@@ -97,7 +97,10 @@ static void bacnet_init(
|
|||||||
apdu_set_unrecognized_service_handler_handler
|
apdu_set_unrecognized_service_handler_handler
|
||||||
(handler_unrecognized_service);
|
(handler_unrecognized_service);
|
||||||
/* we need to handle who-is to support dynamic device binding */
|
/* we need to handle who-is to support dynamic device binding */
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
|
||||||
|
handler_who_is);
|
||||||
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
||||||
|
handler_who_has);
|
||||||
/* Set the handlers for any confirmed services that we support. */
|
/* Set the handlers for any confirmed services that we support. */
|
||||||
/* We must implement read property - it's required! */
|
/* We must implement read property - it's required! */
|
||||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||||
@@ -187,22 +190,16 @@ void test_task(
|
|||||||
/* echo the character */
|
/* echo the character */
|
||||||
serial_byte_send(data_register);
|
serial_byte_send(data_register);
|
||||||
if (data_register == '0') {
|
if (data_register == '0') {
|
||||||
Binary_Output_Level_Set(0, 1, BINARY_INACTIVE);
|
Binary_Output_Present_Value_Set(0, 0, BINARY_INACTIVE);
|
||||||
Binary_Output_Level_Sync(0);
|
Binary_Output_Present_Value_Set(1, 0, BINARY_INACTIVE);
|
||||||
Binary_Output_Level_Set(1, 1, BINARY_INACTIVE);
|
|
||||||
Binary_Output_Level_Sync(1);
|
|
||||||
}
|
}
|
||||||
if (data_register == '1') {
|
if (data_register == '1') {
|
||||||
Binary_Output_Level_Set(0, 1, BINARY_ACTIVE);
|
Binary_Output_Present_Value_Set(0, 0, BINARY_ACTIVE);
|
||||||
Binary_Output_Level_Sync(0);
|
Binary_Output_Present_Value_Set(1, 0, BINARY_ACTIVE);
|
||||||
Binary_Output_Level_Set(1, 1, BINARY_ACTIVE);
|
|
||||||
Binary_Output_Level_Sync(1);
|
|
||||||
}
|
}
|
||||||
if (data_register == '2') {
|
if (data_register == '2') {
|
||||||
Binary_Output_Level_Set(0, 1, BINARY_NULL);
|
Binary_Output_Present_Value_Set(0, 0, BINARY_NULL);
|
||||||
Binary_Output_Level_Sync(0);
|
Binary_Output_Present_Value_Set(1, 0, BINARY_NULL);
|
||||||
Binary_Output_Level_Set(1, 1, BINARY_NULL);
|
|
||||||
Binary_Output_Level_Sync(1);
|
|
||||||
}
|
}
|
||||||
serial_byte_send('\r');
|
serial_byte_send('\r');
|
||||||
serial_byte_send('\n');
|
serial_byte_send('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user