Added a Binary Input object to the demo objects and updated the demo applications and device object to support the new object.

This commit is contained in:
skarg
2006-03-22 03:51:36 +00:00
parent 69289f8f88
commit e6a37a34a8
42 changed files with 191 additions and 135 deletions
+5 -7
View File
@@ -223,12 +223,11 @@ bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE * dest_value,
}
/* returns true if matching or same, false if different */
bool bacapp_same_date(BACNET_DATE *date1, BACNET_DATE *date2)
bool bacapp_same_date(BACNET_DATE * date1, BACNET_DATE * date2)
{
bool status = false;
if (date1 && date2)
{
if (date1 && date2) {
status = true;
if (date1->year != date2->year)
status = false;
@@ -244,12 +243,11 @@ bool bacapp_same_date(BACNET_DATE *date1, BACNET_DATE *date2)
}
/* returns true if matching or same, false if different */
bool bacapp_same_time(BACNET_TIME *time1, BACNET_TIME *time2)
bool bacapp_same_time(BACNET_TIME * time1, BACNET_TIME * time2)
{
bool status = false;
if (time1 && time2)
{
if (time1 && time2) {
status = true;
if (time1->hour != time2->hour)
status = false;
@@ -305,7 +303,7 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE * value,
break;
case BACNET_APPLICATION_TAG_DATE:
status = bacapp_same_date(&test_value->type.Date,
&value->type.Date);
&value->type.Date);
break;
case BACNET_APPLICATION_TAG_TIME:
status = bacapp_same_time(&test_value->type.Time,
+2 -2
View File
@@ -72,8 +72,8 @@ extern "C" {
bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE * dest_value,
BACNET_APPLICATION_DATA_VALUE * src_value);
bool bacapp_same_time(BACNET_TIME *time1, BACNET_TIME *time2);
bool bacapp_same_date(BACNET_DATE *date1, BACNET_DATE *date2);
bool bacapp_same_time(BACNET_TIME * time1, BACNET_TIME * time2);
bool bacapp_same_date(BACNET_DATE * date1, BACNET_DATE * date2);
bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE * value,
BACNET_APPLICATION_DATA_VALUE * test_value);
+6 -6
View File
@@ -1342,7 +1342,7 @@ int encode_context_signed(uint8_t * apdu, int tag_number, int32_t value)
/* from clause 20.2.13 Encoding of a Time Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_bacnet_time(uint8_t * apdu, BACNET_TIME *btime)
int encode_bacnet_time(uint8_t * apdu, BACNET_TIME * btime)
{
apdu[0] = btime->hour;
apdu[1] = btime->min;
@@ -1355,7 +1355,7 @@ int encode_bacnet_time(uint8_t * apdu, BACNET_TIME *btime)
/* from clause 20.2.13 Encoding of a Time Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_tagged_time(uint8_t * apdu, BACNET_TIME *btime)
int encode_tagged_time(uint8_t * apdu, BACNET_TIME * btime)
{
int len = 0;
@@ -1370,7 +1370,7 @@ int encode_tagged_time(uint8_t * apdu, BACNET_TIME *btime)
/* from clause 20.2.13 Encoding of a Time Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int decode_bacnet_time(uint8_t * apdu, BACNET_TIME *btime)
int decode_bacnet_time(uint8_t * apdu, BACNET_TIME * btime)
{
btime->hour = apdu[0];
btime->min = apdu[1];
@@ -1389,7 +1389,7 @@ int decode_bacnet_time(uint8_t * apdu, BACNET_TIME *btime)
/* from clause 20.2.12 Encoding of a Date Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_bacnet_date(uint8_t * apdu, BACNET_DATE *bdate)
int encode_bacnet_date(uint8_t * apdu, BACNET_DATE * bdate)
{
/* allow 2 digit years */
if (bdate->year < 1900) {
@@ -1409,7 +1409,7 @@ int encode_bacnet_date(uint8_t * apdu, BACNET_DATE *bdate)
/* from clause 20.2.12 Encoding of a Date Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_tagged_date(uint8_t * apdu, BACNET_DATE *bdate)
int encode_tagged_date(uint8_t * apdu, BACNET_DATE * bdate)
{
int len = 0;
@@ -1424,7 +1424,7 @@ int encode_tagged_date(uint8_t * apdu, BACNET_DATE *bdate)
/* from clause 20.2.12 Encoding of a Date Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int decode_date(uint8_t * apdu, BACNET_DATE *bdate)
int decode_date(uint8_t * apdu, BACNET_DATE * bdate)
{
bdate->year = apdu[0] + 1900;
bdate->month = apdu[1];
+6 -6
View File
@@ -155,9 +155,9 @@ extern "C" {
/* from clause 20.2.13 Encoding of a Time Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_bacnet_time(uint8_t * apdu, BACNET_TIME *btime);
int encode_tagged_time(uint8_t * apdu, BACNET_TIME *btime);
int decode_bacnet_time(uint8_t * apdu, BACNET_TIME *btime);
int encode_bacnet_time(uint8_t * apdu, BACNET_TIME * btime);
int encode_tagged_time(uint8_t * apdu, BACNET_TIME * btime);
int decode_bacnet_time(uint8_t * apdu, BACNET_TIME * btime);
/* BACnet Date */
/* year = years since 1900 */
@@ -168,9 +168,9 @@ extern "C" {
/* from clause 20.2.12 Encoding of a Date Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */
int encode_bacnet_date(uint8_t * apdu, BACNET_DATE *bdate);
int encode_tagged_date(uint8_t * apdu, BACNET_DATE *bdate);
int decode_date(uint8_t * apdu, BACNET_DATE *bdate);
int encode_bacnet_date(uint8_t * apdu, BACNET_DATE * bdate);
int encode_tagged_date(uint8_t * apdu, BACNET_DATE * bdate);
int decode_date(uint8_t * apdu, BACNET_DATE * bdate);
/* two octet unsigned16 */
int encode_unsigned16(uint8_t * apdu, uint16_t value);
+1
View File
@@ -34,6 +34,7 @@ SRCS = main.c \
$(BACNET_HANDLER)/s_dcc.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+1
View File
@@ -45,6 +45,7 @@ SRCS = main.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\tsm.c \
+2 -2
View File
@@ -73,8 +73,8 @@ extern "C" {
uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t timeDuration, /* 0=optional */
BACNET_COMMUNICATION_ENABLE_DISABLE state, char *password); /* NULL=optional */
void Send_TimeSync(BACNET_DATE *bdate, BACNET_TIME *btime);
void Send_TimeSyncUTC(BACNET_DATE *bdate, BACNET_TIME *btime);
void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime);
void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime);
#ifdef __cplusplus
+22
View File
@@ -38,6 +38,7 @@
/* demo objects */
#include "device.h"
#include "ai.h"
#include "bi.h"
#include "ao.h"
#if BACFILE
#include "bacfile.h"
@@ -123,6 +124,27 @@ void handler_read_property(uint8_t * service_request,
} else
error = true;
break;
case OBJECT_BINARY_INPUT:
if (Binary_Input_Valid_Instance(data.object_instance)) {
len = Binary_Input_Encode_Property_APDU(&Temp_Buf[0],
data.object_instance,
data.object_property,
data.array_index, &error_class, &error_code);
if (len >= 0) {
/* encode the APDU portion of the packet */
data.application_data = &Temp_Buf[0];
data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */
pdu_len +=
rp_ack_encode_apdu(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id, &data);
fprintf(stderr, "Sending Read Property Ack!\n");
send = true;
} else
error = true;
} else
error = true;
break;
case OBJECT_ANALOG_OUTPUT:
if (Analog_Output_Valid_Instance(data.object_instance)) {
len = Analog_Output_Encode_Property_APDU(&Temp_Buf[0],
+10 -16
View File
@@ -31,19 +31,17 @@
#include "bacdcode.h"
#include "timesync.h"
static void show_bacnet_date_time(
BACNET_DATE *bdate,
BACNET_TIME *btime)
static void show_bacnet_date_time(BACNET_DATE * bdate, BACNET_TIME * btime)
{
/* show the date received */
fprintf(stderr, "%u", (unsigned)bdate->year);
fprintf(stderr, "/%u", (unsigned)bdate->month);
fprintf(stderr, "/%u", (unsigned)bdate->day);
fprintf(stderr, "%u", (unsigned) bdate->year);
fprintf(stderr, "/%u", (unsigned) bdate->month);
fprintf(stderr, "/%u", (unsigned) bdate->day);
/* show the time received */
fprintf(stderr, " %02u", (unsigned)btime->hour);
fprintf(stderr, ":%02u", (unsigned)btime->min);
fprintf(stderr, ":%02u", (unsigned)btime->sec);
fprintf(stderr, ".%02u", (unsigned)btime->hundredths);
fprintf(stderr, " %02u", (unsigned) btime->hour);
fprintf(stderr, ":%02u", (unsigned) btime->min);
fprintf(stderr, ":%02u", (unsigned) btime->sec);
fprintf(stderr, ".%02u", (unsigned) btime->hundredths);
fprintf(stderr, "\r\n");
}
@@ -57,9 +55,7 @@ void handler_timesync(uint8_t * service_request,
(void) src;
(void) service_len;
len = timesync_decode_service_request(service_request,
service_len,
&bdate,
&btime);
service_len, &bdate, &btime);
fprintf(stderr, "Received TimeSyncronization Request\r\n");
show_bacnet_date_time(&bdate, &btime);
/* FIXME: set the time? */
@@ -77,9 +73,7 @@ void handler_timesync_utc(uint8_t * service_request,
(void) src;
(void) service_len;
len = timesync_decode_service_request(service_request,
service_len,
&bdate,
&btime);
service_len, &bdate, &btime);
fprintf(stderr, "Received TimeSyncronization Request\r\n");
show_bacnet_date_time(&bdate, &btime);
/* FIXME: set the time? */
+3 -2
View File
@@ -54,10 +54,11 @@ void handler_who_is(uint8_t * service_request,
else if (len != -1) {
/* is my device id within the limits? */
if (((Device_Object_Instance_Number() >= (uint32_t) low_limit) &&
(Device_Object_Instance_Number() <= (uint32_t) high_limit)) ||
(Device_Object_Instance_Number() <= (uint32_t) high_limit))
||
/* BACnet wildcard is the max instance number - everyone responds */
((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) &&
(BACNET_MAX_INSTANCE <= (uint32_t) high_limit)))
(BACNET_MAX_INSTANCE <= (uint32_t) high_limit)))
iam_send(&Handler_Transmit_Buffer[0]);
}
+1 -1
View File
@@ -90,7 +90,7 @@ extern "C" {
void handler_i_have(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src);
void handler_timesync(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src);
+10 -8
View File
@@ -42,7 +42,7 @@
#include "handlers.h"
#include "txbuf.h"
void Send_TimeSync(BACNET_DATE *bdate, BACNET_TIME *btime)
void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime)
{
int pdu_len = 0;
BACNET_ADDRESS dest;
@@ -60,14 +60,15 @@ void Send_TimeSync(BACNET_DATE *bdate, BACNET_TIME *btime)
pdu_len += timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
bdate, btime);
/* send it out the datalink */
bytes_sent = datalink_send_pdu(&dest,
&Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest,
&Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Time-Synchronization Request (%s)!\n",
fprintf(stderr,
"Failed to Send Time-Synchronization Request (%s)!\n",
strerror(errno));
}
void Send_TimeSyncUTC(BACNET_DATE *bdate, BACNET_TIME *btime)
void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime)
{
int pdu_len = 0;
BACNET_ADDRESS dest;
@@ -85,9 +86,10 @@ void Send_TimeSyncUTC(BACNET_DATE *bdate, BACNET_TIME *btime)
pdu_len += timesync_utc_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
bdate, btime);
/* send it out the datalink */
bytes_sent = datalink_send_pdu(&dest,
&Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest,
&Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send UTC-Time-Synchronization Request (%s)!\n",
fprintf(stderr,
"Failed to Send UTC-Time-Synchronization Request (%s)!\n",
strerror(errno));
}
+4 -4
View File
@@ -176,10 +176,10 @@ int bacfile_encode_property_apdu(uint8_t * apdu,
break;
case PROP_MODIFICATION_DATE:
/* FIXME: get the actual value instead of April Fool's Day */
bdate.year = 2006; /* AD */
bdate.month = 4; /* 1=Jan */
bdate.day = 1; /* 1..31 */
bdate.wday = 6; /* 1=Monday */
bdate.year = 2006; /* AD */
bdate.month = 4; /* 1=Jan */
bdate.day = 1; /* 1..31 */
bdate.wday = 6; /* 1=Monday */
apdu_len = encode_tagged_date(&apdu[0], &bdate);
/* FIXME: get the actual value */
btime.hour = 7;
+46 -3
View File
@@ -1,6 +1,6 @@
/**************************************************************************
*
* Copyright (C) 2005 Steve Karg <skarg@users.sourceforge.net>
* Copyright (C) 2005,2006 Steve Karg <skarg@users.sourceforge.net>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -32,6 +32,7 @@
#include "config.h" /* the custom stuff */
#include "apdu.h"
#include "ai.h" /* object list dependency */
#include "bi.h" /* object list dependency */
#include "ao.h" /* object list dependency */
#include "wp.h" /* write property handling */
#include "device.h" /* me */
@@ -318,6 +319,7 @@ unsigned Device_Object_List_Count(void)
unsigned count = 1;
count += Analog_Input_Count();
count += Binary_Input_Count();
count += Analog_Output_Count();
#if BACFILE
count += bacfile_count();
@@ -332,12 +334,13 @@ bool Device_Object_List_Identifier(unsigned array_index,
bool status = false;
unsigned object_index = 0;
/* device object */
if (array_index == 1) {
*object_type = OBJECT_DEVICE;
*instance = Object_Instance_Number;
status = true;
}
/* analog input objects */
if (!status) {
/* array index starts at 1, and 1 for the device object */
object_index = array_index - 2;
@@ -347,17 +350,37 @@ bool Device_Object_List_Identifier(unsigned array_index,
status = true;
}
}
/* binary input objects */
if (!status) {
/* normalize the index since
we know it is not the previous objects */
object_index -= Analog_Input_Count();
/* is it a valid index for this object? */
if (object_index < Binary_Input_Count()) {
*object_type = OBJECT_BINARY_INPUT;
*instance = Binary_Input_Index_To_Instance(object_index);
status = true;
}
}
/* analog output objects */
if (!status) {
/* normalize the index since
we know it is not the previous objects */
object_index -= Binary_Input_Count();
/* is it a valid index for this object? */
if (object_index < Analog_Output_Count()) {
*object_type = OBJECT_ANALOG_OUTPUT;
*instance = Analog_Output_Index_To_Instance(object_index);
status = true;
}
}
/**/
#if BACFILE
if (!status) {
if (!status) {
/* normalize the index since
we know it is not the previous objects */
object_index -= Analog_Output_Count();
/* is it a valid index for this object? */
if (object_index < bacfile_count()) {
*object_type = OBJECT_FILE;
*instance = bacfile_index_to_instance(object_index);
@@ -407,6 +430,9 @@ char *Device_Valid_Object_Id(int object_type, uint32_t object_instance)
case OBJECT_ANALOG_INPUT:
name = Analog_Input_Name(object_instance);
break;
case OBJECT_BINARY_INPUT:
name = Binary_Input_Name(object_instance);
break;
case OBJECT_ANALOG_OUTPUT:
name = Analog_Output_Name(object_instance);
break;
@@ -779,6 +805,23 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index)
return index;
}
/* stubs to dependencies to keep unit test simple */
char *Binary_Input_Name(uint32_t object_instance)
{
(void) object_instance;
return "";
}
unsigned Binary_Input_Count(void)
{
return 0;
}
uint32_t Binary_Input_Index_To_Instance(unsigned index)
{
return index;
}
char *Analog_Output_Name(uint32_t object_instance)
{
(void) object_instance;
+1
View File
@@ -43,6 +43,7 @@ SRCS = readfile.c \
$(BACNET_ROOT)/filename.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/arf.c \
+1
View File
@@ -41,6 +41,7 @@ SRCS = readfile.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\tsm.c \
+1
View File
@@ -33,6 +33,7 @@ SRCS = readprop.c \
$(BACNET_HANDLER)/s_whois.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+1
View File
@@ -45,6 +45,7 @@ SRCS = readprop.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\tsm.c \
+1
View File
@@ -33,6 +33,7 @@ SRCS = main.c \
$(BACNET_HANDLER)/s_rd.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+1 -1
View File
@@ -44,7 +44,7 @@ SRCS = main.c \
..\..\dcc.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\tsm.c \
+1
View File
@@ -36,6 +36,7 @@ SRCS = server.c \
$(BACNET_HANDLER)/s_ihave.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/datalink.c \
+1
View File
@@ -53,6 +53,7 @@ SRCS = server.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\abort.c \
+2 -1
View File
@@ -71,7 +71,8 @@ static void Init_Service_Handlers(void)
handler_atomic_read_file);
apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
handler_reinitialize_device);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
apdu_set_unconfirmed_handler
(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
handler_timesync_utc);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
handler_timesync);
+1
View File
@@ -33,6 +33,7 @@ SRCS = main.c \
$(BACNET_HANDLER)/s_ts.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+9 -8
View File
@@ -90,7 +90,8 @@ static void Init_Service_Handlers(void)
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
handler_read_property);
/* handle the reply (request) coming in */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
apdu_set_unconfirmed_handler
(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
handler_timesync_utc);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
handler_timesync);
@@ -124,7 +125,7 @@ int main(int argc, char *argv[])
time_t current_seconds = 0;
time_t timeout_seconds = 0;
time_t rawtime;
struct tm * my_time;
struct tm *my_time;
BACNET_DATE bdate;
BACNET_TIME btime;
@@ -133,7 +134,7 @@ int main(int argc, char *argv[])
#endif
/* FIXME: we could send directed time sync, and how to we send UTC? */
#if 0
#if 0
if (argc < 2) {
printf("Usage: %s date time [device-instance]\r\n"
"Send BACnet TimeSynchronization request to all devices.\r\n"
@@ -153,7 +154,7 @@ int main(int argc, char *argv[])
filename_remove_path(argv[0]));
return 0;
}
#endif
#endif
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
Init_Service_Handlers();
@@ -172,17 +173,17 @@ int main(int argc, char *argv[])
last_seconds = time(NULL);
timeout_seconds = Device_APDU_Timeout() / 1000;
/* send the request */
time ( &rawtime );
my_time = localtime ( &rawtime );
time(&rawtime);
my_time = localtime(&rawtime);
bdate.year = my_time->tm_year + 1900;
bdate.month = my_time->tm_mon + 1;
bdate.day = my_time->tm_mday;
bdate.wday = my_time->tm_wday?my_time->tm_wday:7;
bdate.wday = my_time->tm_wday ? my_time->tm_wday : 7;
btime.hour = my_time->tm_hour;
btime.min = my_time->tm_min;
btime.sec = my_time->tm_sec;
btime.hundredths = 0;
Send_TimeSync(&bdate,&btime);
Send_TimeSync(&bdate, &btime);
/* loop forever - not necessary for time sync, but we can watch */
for (;;) {
/* increment timer - exit if timed out */
+1
View File
@@ -35,6 +35,7 @@ SRCS = main.c \
$(BACNET_OBJECT)\bacfile.c \
$(BACNET_OBJECT)\device.c \
$(BACNET_OBJECT)\ai.c \
$(BACNET_OBJECT)\bi.c \
$(BACNET_OBJECT)\ao.c \
$(BACNET_ROOT)\address.c \
$(BACNET_ROOT)\filename.c \
+1
View File
@@ -33,6 +33,7 @@ SRCS = main.c \
$(BACNET_HANDLER)/s_ihave.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+1
View File
@@ -47,6 +47,7 @@ SRCS = main.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\abort.c \
+1
View File
@@ -34,6 +34,7 @@ SRCS = main.c \
$(BACNET_HANDLER)/s_whois.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+4 -5
View File
@@ -148,13 +148,12 @@ int main(int argc, char *argv[])
#endif
if (argc < 2) {
printf("Usage: %s device-instance | device-instance-min device-instance-max\r\n"
printf
("Usage: %s device-instance | device-instance-min device-instance-max\r\n"
"Send BACnet WhoIs request to devices, and wait for responses.\r\n"
"\r\n"
"The device-instance can be 0 to %d, or -1 for ALL.\r\n"
"\r\n" "The device-instance can be 0 to %d, or -1 for ALL.\r\n"
"The device-instance can also be specified as a range.\r\n",
filename_remove_path(argv[0]),
BACNET_MAX_INSTANCE);
filename_remove_path(argv[0]), BACNET_MAX_INSTANCE);
return 0;
}
/* decode the command line parameters */
+1
View File
@@ -34,6 +34,7 @@ SRCS = main.c \
$(BACNET_OBJECT)\bacfile.c \
$(BACNET_OBJECT)\device.c \
$(BACNET_OBJECT)\ai.c \
$(BACNET_OBJECT)\bi.c \
$(BACNET_OBJECT)\ao.c \
$(BACNET_ROOT)\address.c \
$(BACNET_ROOT)\filename.c \
+1
View File
@@ -43,6 +43,7 @@ SRCS = writefile.c \
$(BACNET_ROOT)/address.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/arf.c \
+1
View File
@@ -41,6 +41,7 @@ SRCS = writefile.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\tsm.c \
+1 -2
View File
@@ -338,8 +338,7 @@ int main(int argc, char *argv[])
fclose(pFile);
} else
End_Of_File_Detected = true;
printf("\rSending %d bytes",
(fileStartPosition + len));
printf("\rSending %d bytes", (fileStartPosition + len));
invoke_id =
Send_Atomic_Write_File_Stream
(Target_Device_Object_Instance,
+1
View File
@@ -32,6 +32,7 @@ SRCS = writeprop.c \
$(BACNET_HANDLER)/s_whois.c \
$(BACNET_OBJECT)/device.c \
$(BACNET_OBJECT)/ai.c \
$(BACNET_OBJECT)/bi.c \
$(BACNET_OBJECT)/ao.c \
$(BACNET_OBJECT)/bacfile.c \
$(BACNET_ROOT)/filename.c \
+1
View File
@@ -44,6 +44,7 @@ SRCS = writeprop.c \
..\..\demo\object\bacfile.c \
..\..\demo\object\device.c \
..\..\demo\object\ai.c \
..\..\demo\object\bi.c \
..\..\demo\object\ao.c \
..\..\datalink.c \
..\..\tsm.c \
+2 -5
View File
@@ -148,10 +148,8 @@ void InterruptHandlerHigh(void)
void InterruptVectorHigh(void)
{
_asm goto InterruptHandlerHigh /*jump to interrupt routine */
_endasm}
_endasm}
#pragma code
/****************************************************************************
* DESCRIPTION: Low priority interrupt vector
* PARAMETERS: none
@@ -163,6 +161,5 @@ _endasm}
void InterruptVectorLow(void)
{
_asm goto InterruptHandlerLow /*jump to interrupt routine */
_endasm}
_endasm}
#pragma code
+3 -3
View File
@@ -624,7 +624,7 @@ void testReadPropertyMultipleAck(Test * pTest)
test_len = bacapp_decode_application_data(&service_request[len],
service_request_len - len, &test_application_data);
ct_test(pTest, test_len > 0);
ct_test(pTest, bacapp_compare(&application_data[0],
ct_test(pTest, bacapp_same_value(&application_data[0],
&test_application_data));
len += test_len;
ct_test(pTest, decode_is_closing_tag_number(&service_request[len], 4));
@@ -643,7 +643,7 @@ void testReadPropertyMultipleAck(Test * pTest)
test_len = bacapp_decode_application_data(&service_request[len],
service_request_len - len, &test_application_data);
ct_test(pTest, test_len > 0);
ct_test(pTest, bacapp_compare(&application_data[1],
ct_test(pTest, bacapp_same_value(&application_data[1],
&test_application_data));
len += test_len;
ct_test(pTest, decode_is_closing_tag_number(&service_request[len], 4));
@@ -679,7 +679,7 @@ void testReadPropertyMultipleAck(Test * pTest)
test_len = bacapp_decode_application_data(&service_request[len],
service_request_len - len, &test_application_data);
ct_test(pTest, test_len > 0);
ct_test(pTest, bacapp_compare(&application_data[2],
ct_test(pTest, bacapp_same_value(&application_data[2],
&test_application_data));
len += test_len;
ct_test(pTest, decode_is_closing_tag_number(&service_request[len], 4));
+22 -40
View File
@@ -41,8 +41,7 @@
/* encode service */
int timesync_encode_apdu_service(uint8_t * apdu,
BACNET_UNCONFIRMED_SERVICE service,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
int len = 0; /* length of each encoding */
int apdu_len = 0; /* total length of the apdu, return value */
@@ -61,30 +60,22 @@ int timesync_encode_apdu_service(uint8_t * apdu,
}
int timesync_utc_encode_apdu(uint8_t * apdu,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
my_date,
my_time);
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION, my_date, my_time);
}
int timesync_encode_apdu(uint8_t * apdu,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
my_date,
my_time);
return timesync_encode_apdu_service(apdu,
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION, my_date, my_time);
}
/* decode the service request only */
int timesync_decode_service_request(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
int len = 0;
uint8_t tag_number = 0;
@@ -114,9 +105,7 @@ int timesync_decode_service_request(uint8_t * apdu,
int timesync_decode_apdu_service(uint8_t * apdu,
BACNET_UNCONFIRMED_SERVICE service,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
int len = 0;
@@ -130,34 +119,26 @@ int timesync_decode_apdu_service(uint8_t * apdu,
/* optional limits - must be used as a pair */
if (apdu_len > 2) {
len = timesync_decode_service_request(&apdu[2], apdu_len - 2,
my_date, my_time);
my_date, my_time);
}
return len;
}
int timesync_utc_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_decode_apdu_service(apdu,
SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
apdu_len,
my_date,
my_time);
apdu_len, my_date, my_time);
}
int timesync_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time)
{
return timesync_decode_apdu_service(apdu,
SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
apdu_len,
my_date,
my_time);
apdu_len, my_date, my_time);
}
#ifdef TEST
@@ -166,8 +147,7 @@ int timesync_decode_apdu(uint8_t * apdu,
#include "ctest.h"
void testTimeSyncData(Test * pTest,
BACNET_DATE *my_date,
BACNET_TIME *my_time)
BACNET_DATE * my_date, BACNET_TIME * my_time)
{
uint8_t apdu[480] = { 0 };
int len = 0;
@@ -186,7 +166,9 @@ void testTimeSyncData(Test * pTest,
len = timesync_utc_encode_apdu(&apdu[0], my_date, my_time);
ct_test(pTest, len != 0);
apdu_len = len;
len = timesync_utc_decode_apdu(&apdu[0], apdu_len, &test_date, &test_time);
len =
timesync_utc_decode_apdu(&apdu[0], apdu_len, &test_date,
&test_time);
ct_test(pTest, len != -1);
ct_test(pTest, bacapp_same_time(my_time, &test_time));
ct_test(pTest, bacapp_same_date(my_date, &test_date));
@@ -197,10 +179,10 @@ void testTimeSync(Test * pTest)
BACNET_DATE bdate;
BACNET_TIME btime;
bdate.year = 2006; /* AD */
bdate.month = 4; /* 1=Jan */
bdate.day = 11; /* 1..31 */
bdate.wday = 1; /* 1=Monday */
bdate.year = 2006; /* AD */
bdate.month = 4; /* 1=Jan */
bdate.day = 11; /* 1..31 */
bdate.wday = 1; /* 1=Monday */
btime.hour = 7;
btime.min = 0;
+5 -13
View File
@@ -44,24 +44,16 @@ extern "C" {
/* encode service */
int timesync_utc_encode_apdu(uint8_t * apdu,
BACNET_DATE *my_date,
BACNET_TIME *my_time);
BACNET_DATE * my_date, BACNET_TIME * my_time);
int timesync_encode_apdu(uint8_t * apdu,
BACNET_DATE *my_date,
BACNET_TIME *my_time);
BACNET_DATE * my_date, BACNET_TIME * my_time);
/* decode the service request only */
int timesync_decode_service_request(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time);
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time);
int timesync_utc_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time);
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time);
int timesync_decode_apdu(uint8_t * apdu,
unsigned apdu_len,
BACNET_DATE *my_date,
BACNET_TIME *my_time);
unsigned apdu_len, BACNET_DATE * my_date, BACNET_TIME * my_time);
#ifdef TEST
#include "ctest.h"
+1
View File
@@ -11,6 +11,7 @@ SRCS = address.c \
bigend.c \
demo/object/device.c \
demo/object/ai.c \
demo/object/bi.c \
demo/object/ao.c \
iam.c \
dcc.c \
+5
View File
@@ -59,6 +59,11 @@ make -f bacstr.mak
./bacstr >> test.log
make -f bacstr.mak clean
make -f demo/object/bi.mak clean
make -f demo/object/bi.mak
./binary_input >> test.log
make -f demo/object/bi.mak clean
make -f crc.mak clean
make -f crc.mak
./crc >> test.log