Standardized the comments and indentation using the comment.sh and indent.sh scripts.
This commit is contained in:
+13
-20
@@ -173,8 +173,7 @@ int bacapp_decode_application_data(uint8_t * apdu,
|
||||
}
|
||||
|
||||
int bacapp_encode_context_data(uint8_t * apdu,
|
||||
BACNET_APPLICATION_DATA_VALUE * value,
|
||||
BACNET_PROPERTY_ID property)
|
||||
BACNET_APPLICATION_DATA_VALUE * value, BACNET_PROPERTY_ID property)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
@@ -188,8 +187,7 @@ int bacapp_encode_context_data(uint8_t * apdu,
|
||||
value->type.Unsigned_Int);
|
||||
break;
|
||||
case 2:
|
||||
apdu_len = encode_tagged_real(&apdu[0],
|
||||
value->type.Real);
|
||||
apdu_len = encode_tagged_real(&apdu[0], value->type.Real);
|
||||
break;
|
||||
default:
|
||||
apdu_len = 0;
|
||||
@@ -226,12 +224,10 @@ int bacapp_decode_context_data(uint8_t * apdu,
|
||||
case 0:
|
||||
case 1:
|
||||
len += decode_unsigned(&apdu[len],
|
||||
len_value_type,
|
||||
&(value->type.Unsigned_Int));
|
||||
len_value_type, &(value->type.Unsigned_Int));
|
||||
break;
|
||||
case 2:
|
||||
len += decode_real(&apdu[len],
|
||||
&(value->type.Real));
|
||||
len += decode_real(&apdu[len], &(value->type.Real));
|
||||
break;
|
||||
default:
|
||||
len = 0;
|
||||
@@ -277,10 +273,12 @@ bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE * dest_value,
|
||||
dest_value->type.Enumerated = src_value->type.Enumerated;
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
datetime_copy_date(&dest_value->type.Date, &src_value->type.Date);
|
||||
datetime_copy_date(&dest_value->type.Date,
|
||||
&src_value->type.Date);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_TIME:
|
||||
datetime_copy_time(&dest_value->type.Time, &src_value->type.Time);
|
||||
datetime_copy_time(&dest_value->type.Time,
|
||||
&src_value->type.Time);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
dest_value->type.Object_Id.type =
|
||||
@@ -352,8 +350,7 @@ int bacapp_data_len(uint8_t *apdu, int max_apdu_len,
|
||||
if (opening_tag_number_counter)
|
||||
total_len += len;
|
||||
/* ERROR! */
|
||||
if (apdu_len > max_apdu_len)
|
||||
{
|
||||
if (apdu_len > max_apdu_len) {
|
||||
total_len = -1;
|
||||
break;
|
||||
}
|
||||
@@ -609,8 +606,7 @@ void testBACnetApplicationDataLength(Test * pTest)
|
||||
len = encode_closing_tag(&apdu[apdu_len], 3);
|
||||
apdu_len += len;
|
||||
/* verify the length of the data inside the opening/closing tags */
|
||||
len = bacapp_data_len(&apdu[0], apdu_len,
|
||||
PROP_OBJECT_IDENTIFIER);
|
||||
len = bacapp_data_len(&apdu[0], apdu_len, PROP_OBJECT_IDENTIFIER);
|
||||
ct_test(pTest, test_len == len);
|
||||
|
||||
/* 3. application tagged data, multiple elements */
|
||||
@@ -669,8 +665,7 @@ void testBACnetApplicationDataLength(Test * pTest)
|
||||
len = encode_closing_tag(&apdu[apdu_len], 3);
|
||||
apdu_len += len;
|
||||
/* verify the length of the data inside the opening/closing tags */
|
||||
len = bacapp_data_len(&apdu[0], apdu_len,
|
||||
PROP_PRIORITY_ARRAY);
|
||||
len = bacapp_data_len(&apdu[0], apdu_len, PROP_PRIORITY_ARRAY);
|
||||
ct_test(pTest, test_len == len);
|
||||
|
||||
/* 4. complex datatype - one element */
|
||||
@@ -701,8 +696,7 @@ void testBACnetApplicationDataLength(Test * pTest)
|
||||
len = encode_closing_tag(&apdu[apdu_len], 3);
|
||||
apdu_len += len;
|
||||
/* verify the length of the data inside the opening/closing tags */
|
||||
len = bacapp_data_len(&apdu[0], apdu_len,
|
||||
PROP_START_TIME);
|
||||
len = bacapp_data_len(&apdu[0], apdu_len, PROP_START_TIME);
|
||||
ct_test(pTest, test_len == len);
|
||||
|
||||
/* 5. complex datatype - multiple elements */
|
||||
@@ -720,8 +714,7 @@ void testBACnetApplicationDataLength(Test * pTest)
|
||||
len = encode_closing_tag(&apdu[apdu_len], 3);
|
||||
apdu_len += len;
|
||||
/* verify the length of the data inside the opening/closing tags */
|
||||
len = bacapp_data_len(&apdu[0], apdu_len,
|
||||
PROP_REQUESTED_SHED_LEVEL);
|
||||
len = bacapp_data_len(&apdu[0], apdu_len, PROP_REQUESTED_SHED_LEVEL);
|
||||
ct_test(pTest, test_len == len);
|
||||
}
|
||||
|
||||
|
||||
@@ -731,7 +731,8 @@ int encode_tagged_boolean(uint8_t * apdu, bool boolean_value)
|
||||
}
|
||||
|
||||
/* context tagged is encoded differently */
|
||||
int encode_context_boolean(uint8_t * apdu, int tag_number, bool boolean_value)
|
||||
int encode_context_boolean(uint8_t * apdu, int tag_number,
|
||||
bool boolean_value)
|
||||
{
|
||||
int len = 1; /* return value */
|
||||
|
||||
|
||||
+118
-58
@@ -203,13 +203,19 @@ INDTEXT_DATA bacnet_object_type_names[] = {
|
||||
,
|
||||
{OBJECT_ACCUMULATOR, "Accumulator"}
|
||||
,
|
||||
{OBJECT_PULSE_CONVERTER, "Pulse-Converter"},
|
||||
{OBJECT_PULSE_CONVERTER, "Pulse-Converter"}
|
||||
,
|
||||
|
||||
{OBJECT_EVENT_LOG, "Event-Log"},
|
||||
{OBJECT_GLOBAL_GROUP, "Global-Group"},
|
||||
{OBJECT_TREND_LOG_MULTIPLE, "Trend-Log-Multiple"},
|
||||
{OBJECT_LOAD_CONTROL, "Load-Control"},
|
||||
{OBJECT_STRUCTURED_VIEW, "Structured-View"},
|
||||
{OBJECT_EVENT_LOG, "Event-Log"}
|
||||
,
|
||||
{OBJECT_GLOBAL_GROUP, "Global-Group"}
|
||||
,
|
||||
{OBJECT_TREND_LOG_MULTIPLE, "Trend-Log-Multiple"}
|
||||
,
|
||||
{OBJECT_LOAD_CONTROL, "Load-Control"}
|
||||
,
|
||||
{OBJECT_STRUCTURED_VIEW, "Structured-View"}
|
||||
,
|
||||
|
||||
{0, NULL}
|
||||
/* Enumerated values 0-127 are reserved for definition by ASHRAE.
|
||||
@@ -566,58 +572,112 @@ INDTEXT_DATA bacnet_property_names[] = {
|
||||
,
|
||||
{PROP_PROFILE_NAME, "profile-name"}
|
||||
,
|
||||
{PROP_AUTO_SLAVE_DISCOVERY, "auto-slave-discovery"},
|
||||
{PROP_MANUAL_SLAVE_ADDRESS_BINDING, "manual-slave-address-binding"},
|
||||
{PROP_SLAVE_ADDRESS_BINDING, "slave-address-binding"},
|
||||
{PROP_SLAVE_PROXY_ENABLE, "slave-proxy-enable"},
|
||||
{PROP_LAST_NOTIFY_TIME, "last-notify-time"},
|
||||
{PROP_SCHEDULE_DEFAULT, "schedule-default"},
|
||||
{PROP_ACCEPTED_MODES, "accepted-modes"},
|
||||
{PROP_ADJUST_VALUE, "adjust-value"},
|
||||
{PROP_COUNT, "count"},
|
||||
{PROP_COUNT_BEFORE_CHANGE, "count-before-change"},
|
||||
{PROP_COUNT_CHANGE_TIME, "count-change-time"},
|
||||
{PROP_COV_PERIOD, "COV-period"},
|
||||
{PROP_INPUT_REFERENCE, "input-reference"},
|
||||
{PROP_LIMIT_MONITORING_INTERVAL, "limit-monitoring-interval"},
|
||||
{PROP_LOGGING_DEVICE, "logging-device"},
|
||||
{PROP_LOGGING_RECORD, "logging-record"},
|
||||
{PROP_PRESCALE, "prescale"},
|
||||
{PROP_PULSE_RATE, "pulse-rate"},
|
||||
{PROP_SCALE, "scale"},
|
||||
{PROP_SCALE_FACTOR, "scale-factor"},
|
||||
{PROP_UPDATE_TIME, "update-time"},
|
||||
{PROP_VALUE_BEFORE_CHANGE, "value-before-change"},
|
||||
{PROP_VALUE_SET, "value-set"},
|
||||
{PROP_VALUE_CHANGE_TIME, "value-change-time"},
|
||||
{PROP_ALIGN_INTERVALS, "align-intervals"},
|
||||
{PROP_GROUP_MEMBER_NAMES, "group-member-names"},
|
||||
{PROP_INTERVAL_OFFSET, "interval-offset"},
|
||||
{PROP_LAST_RESTART_REASON, "last-restart-reason"},
|
||||
{PROP_LOGGING_TYPE, "logging-type"},
|
||||
{PROP_MEMBER_STATUS_FLAGS, "member-status-flags"},
|
||||
{PROP_NOTIFICATION_PERIOD, "notification-period"},
|
||||
{PROP_PREVIOUS_NOTIFY_RECORD, "previous-notify-record"},
|
||||
{PROP_REQUESTED_UPDATE_INTERVAL, "requested-update-interval"},
|
||||
{PROP_RESTART_NOTIFICATION_RECIPIENTS, "restart-notification-recipients"},
|
||||
{PROP_TIME_OF_DEVICE_RESTART, "time-of-device-restart"},
|
||||
{PROP_TIME_SYNCHRONIZATION_INTERVAL, "time-synchronization-interval"},
|
||||
{PROP_TRIGGER, "trigger"},
|
||||
{PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS, "UTC-time-synchronization-recipients"},
|
||||
{PROP_NODE_SUBTYPE, "node-subtype"},
|
||||
{PROP_NODE_TYPE, "node-type"},
|
||||
{PROP_STRUCTURED_OBJECT_LIST, "structured-object-list"},
|
||||
{PROP_SUBORDINATE_ANNOTATIONS, "subordinate-annotations"},
|
||||
{PROP_SUBORDINATE_LIST, "subordinate-list"},
|
||||
{PROP_ACTUAL_SHED_LEVEL, "actual-shed-level"},
|
||||
{PROP_DUTY_WINDOW, "duty-window"},
|
||||
{PROP_EXPECTED_SHED_LEVEL, "expected-shed-level"},
|
||||
{PROP_FULL_DUTY_BASELINE, "full-duty-baseline"},
|
||||
{PROP_REQUESTED_SHED_LEVEL, "requested-shed-level"},
|
||||
{PROP_SHED_DURATION, "shed-duration"},
|
||||
{PROP_SHED_LEVEL_DESCRIPTIONS, "shed-level-descriptions"},
|
||||
{PROP_SHED_LEVELS, "shed-levels"},
|
||||
{PROP_STATE_DESCRIPTION, "state-descriptions"},
|
||||
{PROP_AUTO_SLAVE_DISCOVERY, "auto-slave-discovery"}
|
||||
,
|
||||
{PROP_MANUAL_SLAVE_ADDRESS_BINDING, "manual-slave-address-binding"}
|
||||
,
|
||||
{PROP_SLAVE_ADDRESS_BINDING, "slave-address-binding"}
|
||||
,
|
||||
{PROP_SLAVE_PROXY_ENABLE, "slave-proxy-enable"}
|
||||
,
|
||||
{PROP_LAST_NOTIFY_TIME, "last-notify-time"}
|
||||
,
|
||||
{PROP_SCHEDULE_DEFAULT, "schedule-default"}
|
||||
,
|
||||
{PROP_ACCEPTED_MODES, "accepted-modes"}
|
||||
,
|
||||
{PROP_ADJUST_VALUE, "adjust-value"}
|
||||
,
|
||||
{PROP_COUNT, "count"}
|
||||
,
|
||||
{PROP_COUNT_BEFORE_CHANGE, "count-before-change"}
|
||||
,
|
||||
{PROP_COUNT_CHANGE_TIME, "count-change-time"}
|
||||
,
|
||||
{PROP_COV_PERIOD, "COV-period"}
|
||||
,
|
||||
{PROP_INPUT_REFERENCE, "input-reference"}
|
||||
,
|
||||
{PROP_LIMIT_MONITORING_INTERVAL, "limit-monitoring-interval"}
|
||||
,
|
||||
{PROP_LOGGING_DEVICE, "logging-device"}
|
||||
,
|
||||
{PROP_LOGGING_RECORD, "logging-record"}
|
||||
,
|
||||
{PROP_PRESCALE, "prescale"}
|
||||
,
|
||||
{PROP_PULSE_RATE, "pulse-rate"}
|
||||
,
|
||||
{PROP_SCALE, "scale"}
|
||||
,
|
||||
{PROP_SCALE_FACTOR, "scale-factor"}
|
||||
,
|
||||
{PROP_UPDATE_TIME, "update-time"}
|
||||
,
|
||||
{PROP_VALUE_BEFORE_CHANGE, "value-before-change"}
|
||||
,
|
||||
{PROP_VALUE_SET, "value-set"}
|
||||
,
|
||||
{PROP_VALUE_CHANGE_TIME, "value-change-time"}
|
||||
,
|
||||
{PROP_ALIGN_INTERVALS, "align-intervals"}
|
||||
,
|
||||
{PROP_GROUP_MEMBER_NAMES, "group-member-names"}
|
||||
,
|
||||
{PROP_INTERVAL_OFFSET, "interval-offset"}
|
||||
,
|
||||
{PROP_LAST_RESTART_REASON, "last-restart-reason"}
|
||||
,
|
||||
{PROP_LOGGING_TYPE, "logging-type"}
|
||||
,
|
||||
{PROP_MEMBER_STATUS_FLAGS, "member-status-flags"}
|
||||
,
|
||||
{PROP_NOTIFICATION_PERIOD, "notification-period"}
|
||||
,
|
||||
{PROP_PREVIOUS_NOTIFY_RECORD, "previous-notify-record"}
|
||||
,
|
||||
{PROP_REQUESTED_UPDATE_INTERVAL, "requested-update-interval"}
|
||||
,
|
||||
{PROP_RESTART_NOTIFICATION_RECIPIENTS,
|
||||
"restart-notification-recipients"}
|
||||
,
|
||||
{PROP_TIME_OF_DEVICE_RESTART, "time-of-device-restart"}
|
||||
,
|
||||
{PROP_TIME_SYNCHRONIZATION_INTERVAL, "time-synchronization-interval"}
|
||||
,
|
||||
{PROP_TRIGGER, "trigger"}
|
||||
,
|
||||
{PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS,
|
||||
"UTC-time-synchronization-recipients"}
|
||||
,
|
||||
{PROP_NODE_SUBTYPE, "node-subtype"}
|
||||
,
|
||||
{PROP_NODE_TYPE, "node-type"}
|
||||
,
|
||||
{PROP_STRUCTURED_OBJECT_LIST, "structured-object-list"}
|
||||
,
|
||||
{PROP_SUBORDINATE_ANNOTATIONS, "subordinate-annotations"}
|
||||
,
|
||||
{PROP_SUBORDINATE_LIST, "subordinate-list"}
|
||||
,
|
||||
{PROP_ACTUAL_SHED_LEVEL, "actual-shed-level"}
|
||||
,
|
||||
{PROP_DUTY_WINDOW, "duty-window"}
|
||||
,
|
||||
{PROP_EXPECTED_SHED_LEVEL, "expected-shed-level"}
|
||||
,
|
||||
{PROP_FULL_DUTY_BASELINE, "full-duty-baseline"}
|
||||
,
|
||||
{PROP_REQUESTED_SHED_LEVEL, "requested-shed-level"}
|
||||
,
|
||||
{PROP_SHED_DURATION, "shed-duration"}
|
||||
,
|
||||
{PROP_SHED_LEVEL_DESCRIPTIONS, "shed-level-descriptions"}
|
||||
,
|
||||
{PROP_SHED_LEVELS, "shed-levels"}
|
||||
,
|
||||
{PROP_STATE_DESCRIPTION, "state-descriptions"}
|
||||
,
|
||||
|
||||
{0, NULL}
|
||||
/* Enumerated values 0-511 are reserved for definition by ASHRAE.
|
||||
|
||||
+28
-22
@@ -273,6 +273,7 @@ int cov_notify_decode_service_request(uint8_t * apdu,
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
12.11.38Active_COV_Subscriptions
|
||||
The Active_COV_Subscriptions property is a List of BACnetCOVSubscription, each of which consists of a Recipient, a
|
||||
@@ -291,10 +292,8 @@ SubscribeCOV-Request ::= SEQUENCE {
|
||||
}
|
||||
*/
|
||||
|
||||
int cov_subscribe_encode_adpu(
|
||||
uint8_t * apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
int cov_subscribe_encode_adpu(uint8_t * apdu,
|
||||
uint8_t invoke_id, BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
{
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
@@ -412,10 +411,8 @@ BACnetPropertyReference ::= SEQUENCE {
|
||||
|
||||
*/
|
||||
|
||||
int cov_subscribe_property_encode_adpu(
|
||||
uint8_t * apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
int cov_subscribe_property_encode_adpu(uint8_t * apdu,
|
||||
uint8_t invoke_id, BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
{
|
||||
int len = 0; /* length of each encoding */
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
@@ -648,7 +645,8 @@ int ucov_notify_decode_apdu(uint8_t * apdu,
|
||||
}
|
||||
|
||||
int cov_subscribe_decode_apdu(uint8_t * apdu,
|
||||
unsigned apdu_len, uint8_t * invoke_id, BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
unsigned apdu_len, uint8_t * invoke_id,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
{
|
||||
int len = 0;
|
||||
unsigned offset = 0;
|
||||
@@ -675,7 +673,8 @@ int cov_subscribe_decode_apdu(uint8_t * apdu,
|
||||
}
|
||||
|
||||
int cov_subscribe_property_decode_apdu(uint8_t * apdu,
|
||||
unsigned apdu_len, uint8_t * invoke_id, BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
unsigned apdu_len, uint8_t * invoke_id,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data)
|
||||
{
|
||||
int len = 0;
|
||||
unsigned offset = 0;
|
||||
@@ -716,11 +715,8 @@ void npdu_encode_npdu_data(BACNET_NPDU_DATA * npdu,
|
||||
}
|
||||
|
||||
/* dummy function stubs */
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
unsigned pdu_len)
|
||||
int datalink_send_pdu(BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data, uint8_t * pdu, unsigned pdu_len)
|
||||
{
|
||||
(void) dest;
|
||||
(void) npdu_data;
|
||||
@@ -825,7 +821,8 @@ void testCOVNotify(Test * pTest)
|
||||
}
|
||||
|
||||
void testCOVSubscribeData(Test * pTest,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data, BACNET_SUBSCRIBE_COV_DATA * test_data)
|
||||
BACNET_SUBSCRIBE_COV_DATA * data,
|
||||
BACNET_SUBSCRIBE_COV_DATA * test_data)
|
||||
{
|
||||
ct_test(pTest,
|
||||
test_data->subscriberProcessIdentifier ==
|
||||
@@ -836,20 +833,29 @@ void testCOVSubscribeData(Test * pTest,
|
||||
ct_test(pTest,
|
||||
test_data->monitoredObjectIdentifier.instance ==
|
||||
data->monitoredObjectIdentifier.instance);
|
||||
ct_test(pTest, test_data->cancellationRequest == data->cancellationRequest);
|
||||
ct_test(pTest,
|
||||
test_data->cancellationRequest == data->cancellationRequest);
|
||||
if (!test_data->cancellationRequest) {
|
||||
ct_test(pTest, test_data->issueConfirmedNotifications == data->issueConfirmedNotifications);
|
||||
ct_test(pTest,
|
||||
test_data->issueConfirmedNotifications ==
|
||||
data->issueConfirmedNotifications);
|
||||
ct_test(pTest, test_data->lifetime == data->lifetime);
|
||||
}
|
||||
}
|
||||
|
||||
void testCOVSubscribePropertyData(Test * pTest,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data, BACNET_SUBSCRIBE_COV_DATA * test_data)
|
||||
BACNET_SUBSCRIBE_COV_DATA * data,
|
||||
BACNET_SUBSCRIBE_COV_DATA * test_data)
|
||||
{
|
||||
testCOVSubscribeData(pTest, data, test_data);
|
||||
ct_test(pTest, test_data->monitoredProperty.propertyIdentifier == data->monitoredProperty.propertyIdentifier);
|
||||
ct_test(pTest, test_data->monitoredProperty.propertyArrayIndex == data->monitoredProperty.propertyArrayIndex);
|
||||
ct_test(pTest, test_data->covIncrementPresent == data->covIncrementPresent);
|
||||
ct_test(pTest,
|
||||
test_data->monitoredProperty.propertyIdentifier ==
|
||||
data->monitoredProperty.propertyIdentifier);
|
||||
ct_test(pTest,
|
||||
test_data->monitoredProperty.propertyArrayIndex ==
|
||||
data->monitoredProperty.propertyArrayIndex);
|
||||
ct_test(pTest,
|
||||
test_data->covIncrementPresent == data->covIncrementPresent);
|
||||
if (test_data->covIncrementPresent) {
|
||||
ct_test(pTest, test_data->covIncrement == data->covIncrement);
|
||||
}
|
||||
|
||||
+4
-8
@@ -97,18 +97,14 @@ extern "C" {
|
||||
int cov_subscribe_property_decode_service_request(uint8_t * apdu,
|
||||
unsigned apdu_len, BACNET_SUBSCRIBE_COV_DATA * data);
|
||||
|
||||
int cov_subscribe_property_encode_adpu(
|
||||
uint8_t * apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data);
|
||||
int cov_subscribe_property_encode_adpu(uint8_t * apdu,
|
||||
uint8_t invoke_id, BACNET_SUBSCRIBE_COV_DATA * data);
|
||||
|
||||
int cov_subscribe_decode_service_request(uint8_t * apdu,
|
||||
unsigned apdu_len, BACNET_SUBSCRIBE_COV_DATA * data);
|
||||
|
||||
int cov_subscribe_encode_adpu(
|
||||
uint8_t * apdu,
|
||||
uint8_t invoke_id,
|
||||
BACNET_SUBSCRIBE_COV_DATA * data);
|
||||
int cov_subscribe_encode_adpu(uint8_t * apdu,
|
||||
uint8_t invoke_id, BACNET_SUBSCRIBE_COV_DATA * data);
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
+4
-10
@@ -73,16 +73,10 @@
|
||||
#elif defined(BACDL_TEST)
|
||||
#include "npdu.h"
|
||||
|
||||
extern int datalink_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
unsigned pdu_len);
|
||||
extern uint16_t datalink_receive(
|
||||
BACNET_ADDRESS * src,
|
||||
uint8_t * pdu,
|
||||
uint16_t max_pdu,
|
||||
unsigned timeout);
|
||||
extern int datalink_send_pdu(BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data, uint8_t * pdu, unsigned pdu_len);
|
||||
extern uint16_t datalink_receive(BACNET_ADDRESS * src,
|
||||
uint8_t * pdu, uint16_t max_pdu, unsigned timeout);
|
||||
extern void datalink_cleanup(void);
|
||||
extern void datalink_get_broadcast_address(BACNET_ADDRESS * dest);
|
||||
extern void bip_get_my_address(BACNET_ADDRESS * my_address);
|
||||
|
||||
+26
-46
@@ -57,7 +57,8 @@ static uint8_t month_days(uint16_t year, uint8_t month)
|
||||
{
|
||||
/* note: start with a zero in the first element to save us from a
|
||||
month - 1 calculation in the lookup */
|
||||
int month_days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
int month_days[13] =
|
||||
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
/* February */
|
||||
if ((month == 2) && is_leap_year(year))
|
||||
@@ -76,17 +77,13 @@ static uint32_t days_since_epoch(uint16_t year, uint8_t month, uint8_t day)
|
||||
uint8_t months = 0; /* loop counter for months */
|
||||
|
||||
monthdays = month_days(year, month);
|
||||
if ((year >= 1900) && (monthdays) &&
|
||||
(day >= 1) && (day <= monthdays))
|
||||
{
|
||||
for (years = 1900; years < year; years++)
|
||||
{
|
||||
if ((year >= 1900) && (monthdays) && (day >= 1) && (day <= monthdays)) {
|
||||
for (years = 1900; years < year; years++) {
|
||||
days += 365;
|
||||
if (is_leap_year(years))
|
||||
days++;
|
||||
}
|
||||
for (months = 1; months < month; months++)
|
||||
{
|
||||
for (months = 1; months < month; months++) {
|
||||
days += month_days(years, months);
|
||||
}
|
||||
days += (day - 1);
|
||||
@@ -95,18 +92,14 @@ static uint32_t days_since_epoch(uint16_t year, uint8_t month, uint8_t day)
|
||||
return (days);
|
||||
}
|
||||
|
||||
static void days_since_epoch_into_ymd(
|
||||
uint32_t days,
|
||||
uint16_t *pYear,
|
||||
uint8_t *pMonth,
|
||||
uint8_t *pDay)
|
||||
static void days_since_epoch_into_ymd(uint32_t days,
|
||||
uint16_t * pYear, uint8_t * pMonth, uint8_t * pDay)
|
||||
{
|
||||
int year = 1900;
|
||||
int month = 1;
|
||||
int day = 1;
|
||||
|
||||
while (days >= 365)
|
||||
{
|
||||
while (days >= 365) {
|
||||
if ((is_leap_year(year)) && days == 365)
|
||||
break;
|
||||
days -= 365;
|
||||
@@ -115,8 +108,7 @@ static void days_since_epoch_into_ymd(
|
||||
year++;
|
||||
}
|
||||
|
||||
while (days >= month_days(year, month))
|
||||
{
|
||||
while (days >= month_days(year, month)) {
|
||||
days -= month_days(year, month);
|
||||
month++;
|
||||
}
|
||||
@@ -175,7 +167,8 @@ int datetime_compare_time(BACNET_TIME * time1, BACNET_TIME * time2)
|
||||
if (diff == 0) {
|
||||
diff = (int) time1->sec - (int) time2->sec;
|
||||
if (diff == 0) {
|
||||
diff = (int)time1->hundredths - (int)time2->hundredths;
|
||||
diff =
|
||||
(int) time1->hundredths - (int) time2->hundredths;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,8 +213,7 @@ void datetime_copy_time(BACNET_TIME * dest_time, BACNET_TIME * src_time)
|
||||
}
|
||||
}
|
||||
|
||||
void datetime_copy(
|
||||
BACNET_DATE_TIME * dest_datetime,
|
||||
void datetime_copy(BACNET_DATE_TIME * dest_datetime,
|
||||
BACNET_DATE_TIME * src_datetime)
|
||||
{
|
||||
datetime_copy_time(&dest_datetime->time, &src_datetime->time);
|
||||
@@ -251,8 +243,7 @@ void datetime_set_time(BACNET_TIME * btime,
|
||||
}
|
||||
|
||||
void datetime_set(BACNET_DATE_TIME * bdatetime,
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime)
|
||||
BACNET_DATE * bdate, BACNET_TIME * btime)
|
||||
{
|
||||
if (bdate && btime && bdatetime) {
|
||||
bdatetime->time.hour = btime->hour;
|
||||
@@ -289,9 +280,7 @@ static uint32_t seconds_since_midnight(uint8_t hours, uint8_t minutes,
|
||||
}
|
||||
|
||||
static void seconds_since_midnight_into_hms(uint32_t seconds,
|
||||
uint8_t * pHours,
|
||||
uint8_t *pMinutes,
|
||||
uint8_t *pSeconds)
|
||||
uint8_t * pHours, uint8_t * pMinutes, uint8_t * pSeconds)
|
||||
{
|
||||
uint8_t hour = 0;
|
||||
uint8_t minute = 0;
|
||||
@@ -316,14 +305,10 @@ void datetime_add_minutes(BACNET_DATE_TIME * bdatetime, uint32_t minutes)
|
||||
uint32_t days = 0;
|
||||
|
||||
/* convert bdatetime to seconds and days */
|
||||
bdatetime_minutes = seconds_since_midnight(
|
||||
bdatetime->time.hour,
|
||||
bdatetime->time.min,
|
||||
bdatetime->time.sec) / 60;
|
||||
bdatetime_days = days_since_epoch(
|
||||
bdatetime->date.year,
|
||||
bdatetime->date.month,
|
||||
bdatetime->date.day);
|
||||
bdatetime_minutes = seconds_since_midnight(bdatetime->time.hour,
|
||||
bdatetime->time.min, bdatetime->time.sec) / 60;
|
||||
bdatetime_days = days_since_epoch(bdatetime->date.year,
|
||||
bdatetime->date.month, bdatetime->date.day);
|
||||
|
||||
/* add */
|
||||
days = minutes / (24 * 60);
|
||||
@@ -335,18 +320,12 @@ void datetime_add_minutes(BACNET_DATE_TIME * bdatetime, uint32_t minutes)
|
||||
|
||||
/* convert bdatetime from seconds and days */
|
||||
seconds_since_midnight_into_hms(bdatetime_minutes * 60,
|
||||
&bdatetime->time.hour,
|
||||
&bdatetime->time.min,
|
||||
&bdatetime->time.sec);
|
||||
days_since_epoch_into_ymd(
|
||||
bdatetime_days,
|
||||
&bdatetime->time.hour, &bdatetime->time.min, &bdatetime->time.sec);
|
||||
days_since_epoch_into_ymd(bdatetime_days,
|
||||
&bdatetime->date.year,
|
||||
&bdatetime->date.month,
|
||||
&bdatetime->date.day);
|
||||
bdatetime->date.wday = day_of_week(
|
||||
bdatetime->date.year,
|
||||
bdatetime->date.month,
|
||||
bdatetime->date.day);
|
||||
&bdatetime->date.month, &bdatetime->date.day);
|
||||
bdatetime->date.wday = day_of_week(bdatetime->date.year,
|
||||
bdatetime->date.month, bdatetime->date.day);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
@@ -399,8 +378,9 @@ void testBACnetDateTimeSeconds(Test * pTest)
|
||||
seconds = seconds_since_midnight(hour, minute, second);
|
||||
seconds_since_midnight_into_hms(seconds,
|
||||
&test_hour, &test_minute, &test_second);
|
||||
test_seconds = seconds_since_midnight(
|
||||
test_hour, test_minute, test_second);
|
||||
test_seconds =
|
||||
seconds_since_midnight(test_hour, test_minute,
|
||||
test_second);
|
||||
ct_test(pTest, seconds == test_seconds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ extern "C" {
|
||||
void datetime_set_time(BACNET_TIME * btime,
|
||||
uint8_t hour, uint8_t minute, uint8_t seconds, uint8_t hundredths);
|
||||
void datetime_set(BACNET_DATE_TIME * bdatetime,
|
||||
BACNET_DATE * bdate,
|
||||
BACNET_TIME * btime);
|
||||
BACNET_DATE * bdate, BACNET_TIME * btime);
|
||||
void datetime_set_values(BACNET_DATE_TIME * bdatetime,
|
||||
uint16_t year, uint8_t month, uint8_t day,
|
||||
uint8_t hour, uint8_t minute, uint8_t seconds, uint8_t hundredths);
|
||||
@@ -80,23 +79,20 @@ extern "C" {
|
||||
if date1 is after date2, returns positive */
|
||||
int datetime_compare_date(BACNET_DATE * date1, BACNET_DATE * date2);
|
||||
int datetime_compare_time(BACNET_TIME * time1, BACNET_TIME * time2);
|
||||
int datetime_compare(
|
||||
BACNET_DATE_TIME * datetime1,
|
||||
int datetime_compare(BACNET_DATE_TIME * datetime1,
|
||||
BACNET_DATE_TIME * datetime2);
|
||||
|
||||
/* utility copy functions */
|
||||
void datetime_copy_date(BACNET_DATE * date1, BACNET_DATE * date2);
|
||||
void datetime_copy_time(BACNET_TIME * time1, BACNET_TIME * time2);
|
||||
void datetime_copy(
|
||||
BACNET_DATE_TIME * datetime1,
|
||||
void datetime_copy(BACNET_DATE_TIME * datetime1,
|
||||
BACNET_DATE_TIME * datetime2);
|
||||
|
||||
/* utility add function */
|
||||
void datetime_add_minutes(BACNET_DATE_TIME * bdatetime, uint32_t minutes);
|
||||
void datetime_add_minutes(BACNET_DATE_TIME * bdatetime,
|
||||
uint32_t minutes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* DATE_TIME_H */
|
||||
|
||||
|
||||
@@ -54,8 +54,7 @@ static uint8_t Temp_Buf[MAX_APDU] = { 0 };
|
||||
|
||||
void handler_read_property(uint8_t * service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS * src,
|
||||
BACNET_CONFIRMED_SERVICE_DATA * service_data)
|
||||
BACNET_ADDRESS * src, BACNET_CONFIRMED_SERVICE_DATA * service_data)
|
||||
{
|
||||
BACNET_READ_PROPERTY_DATA data;
|
||||
int len = 0;
|
||||
|
||||
@@ -259,7 +259,8 @@ void handler_write_property(uint8_t * service_request,
|
||||
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
|
||||
error_code);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Sending Write Access Error for Load Control!\n");
|
||||
fprintf(stderr,
|
||||
"Sending Write Access Error for Load Control!\n");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -89,7 +89,8 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
|
||||
&npdu_data, &Handler_Transmit_Buffer[0],
|
||||
(uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
|
||||
@@ -81,8 +81,8 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */
|
||||
data.object_property = object_property;
|
||||
data.array_index = array_index;
|
||||
data.application_data_len =
|
||||
bacapp_encode_application_data(
|
||||
&data.application_data[0],object_value);
|
||||
bacapp_encode_application_data(&data.application_data[0],
|
||||
object_value);
|
||||
data.priority = priority;
|
||||
len = wp_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
invoke_id, &data);
|
||||
@@ -94,7 +94,8 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len);
|
||||
&npdu_data, &Handler_Transmit_Buffer[0],
|
||||
(uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
|
||||
@@ -285,10 +285,8 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
@@ -300,8 +298,7 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
object. */
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */ ) &&
|
||||
(value.type.Real >= 0.0) &&
|
||||
(value.type.Real <= 100.0)) {
|
||||
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
|
||||
level = (uint8_t) value.type.Real;
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index(wp_data->
|
||||
|
||||
@@ -282,10 +282,8 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
@@ -297,8 +295,7 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
object. */
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */ ) &&
|
||||
(value.type.Real >= 0.0) &&
|
||||
(value.type.Real <= 100.0)) {
|
||||
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
|
||||
level = (uint8_t) value.type.Real;
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(wp_data->
|
||||
@@ -349,8 +346,7 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
object_index =
|
||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
||||
Analog_Value_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
Analog_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -232,10 +232,8 @@ bool bacfile_write_property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
}
|
||||
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
|
||||
@@ -283,10 +283,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
|
||||
@@ -280,10 +280,8 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
@@ -347,8 +345,7 @@ bool Binary_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
object_index =
|
||||
Binary_Value_Instance_To_Index(wp_data->object_instance);
|
||||
Binary_Value_Out_Of_Service[object_index] =
|
||||
value.type.Boolean;
|
||||
Binary_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -796,18 +796,16 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(
|
||||
value.type.Object_Id.instance))) {
|
||||
(Device_Set_Object_Instance_Number(value.type.Object_Id.
|
||||
instance))) {
|
||||
/* FIXME: we could send an I-Am broadcast to let the world know */
|
||||
status = true;
|
||||
} else {
|
||||
@@ -835,8 +833,7 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
case PROP_APDU_TIMEOUT:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
/* FIXME: bounds check? */
|
||||
Device_Set_APDU_Timeout((uint16_t) value.type.
|
||||
Unsigned_Int);
|
||||
Device_Set_APDU_Timeout((uint16_t) value.type.Unsigned_Int);
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -870,12 +867,11 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||
uint8_t encoding;
|
||||
encoding =
|
||||
characterstring_encoding(&value.type.
|
||||
Character_String);
|
||||
characterstring_encoding(&value.type.Character_String);
|
||||
if (encoding == CHARACTER_ANSI_X34) {
|
||||
status =
|
||||
Device_Set_Object_Name(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
Device_Set_Object_Name(characterstring_value(&value.
|
||||
type.Character_String),
|
||||
characterstring_length(&value.type.Character_String));
|
||||
if (!status) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -123,7 +123,8 @@ void Load_Control_Init(void)
|
||||
Requested_Shed_Level[i].type = BACNET_SHED_TYPE_LEVEL;
|
||||
Requested_Shed_Level[i].value.level = 0;
|
||||
datetime_set_values(&Start_Time[i], 0, 0, 0, 0, 0, 0, 0);
|
||||
datetime_set_values(&Previous_Start_Time[i],0,0,0,0,0,0,0);
|
||||
datetime_set_values(&Previous_Start_Time[i], 0, 0, 0, 0, 0, 0,
|
||||
0);
|
||||
Shed_Duration[i] = 0;
|
||||
Duty_Window[i] = 0;
|
||||
Load_Control_Enable[i] = true;
|
||||
@@ -186,7 +187,8 @@ unsigned Load_Control_Instance_To_Index(uint32_t object_instance)
|
||||
return index;
|
||||
}
|
||||
|
||||
static BACNET_SHED_STATE Load_Control_Present_Value(uint32_t object_instance)
|
||||
static BACNET_SHED_STATE Load_Control_Present_Value(uint32_t
|
||||
object_instance)
|
||||
{
|
||||
BACNET_SHED_STATE value = BACNET_SHED_INACTIVE;
|
||||
unsigned index = 0;
|
||||
@@ -234,19 +236,14 @@ struct tm {
|
||||
|
||||
timer = time(NULL);
|
||||
tblock = localtime(&timer);
|
||||
datetime_set_values(
|
||||
bdatetime,
|
||||
datetime_set_values(bdatetime,
|
||||
tblock->tm_year,
|
||||
tblock->tm_mon,
|
||||
tblock->tm_mday,
|
||||
tblock->tm_hour,
|
||||
tblock->tm_min,
|
||||
tblock->tm_sec,
|
||||
0);
|
||||
tblock->tm_hour, tblock->tm_min, tblock->tm_sec, 0);
|
||||
}
|
||||
|
||||
typedef enum load_control_state
|
||||
{
|
||||
typedef enum load_control_state {
|
||||
SHED_INACTIVE,
|
||||
SHED_REQUEST_PENDING,
|
||||
SHED_NON_COMPLIANT,
|
||||
@@ -267,12 +264,12 @@ void Load_Control_State_Machine(int object_index)
|
||||
}
|
||||
}
|
||||
|
||||
switch (state[object_index])
|
||||
{
|
||||
switch (state[object_index]) {
|
||||
case SHED_REQUEST_PENDING:
|
||||
Update_Current_Time(&Current_Time);
|
||||
datetime_copy(&End_Time[object_index], &Start_Time[object_index]);
|
||||
datetime_add_minutes(&End_Time[object_index], Shed_Duration[object_index]);
|
||||
datetime_add_minutes(&End_Time[object_index],
|
||||
Shed_Duration[object_index]);
|
||||
diff = datetime_compare(&End_Time[object_index], &Current_Time);
|
||||
if (diff < 0) {
|
||||
/* CancelShed */
|
||||
@@ -301,8 +298,7 @@ void Load_Control_State_Machine(int object_index)
|
||||
/* FIXME: calculate your Actual Shed Level */
|
||||
Expected_Shed_Level[object_index].type =
|
||||
Requested_Shed_Level[object_index].type;
|
||||
switch (Requested_Shed_Level[object_index].type)
|
||||
{
|
||||
switch (Requested_Shed_Level[object_index].type) {
|
||||
case BACNET_SHED_TYPE_PERCENT:
|
||||
Actual_Shed_Level[object_index].value.percent =
|
||||
Expected_Shed_Level[object_index].value.percent =
|
||||
@@ -400,8 +396,7 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_REQUESTED_SHED_LEVEL:
|
||||
switch (Requested_Shed_Level[object_index].type)
|
||||
{
|
||||
switch (Requested_Shed_Level[object_index].type) {
|
||||
case BACNET_SHED_TYPE_PERCENT:
|
||||
apdu_len = encode_context_unsigned(&apdu[0], 0,
|
||||
Requested_Shed_Level[object_index].value.percent);
|
||||
@@ -418,8 +413,7 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
}
|
||||
break;
|
||||
case PROP_START_TIME:
|
||||
len = encode_tagged_date(&apdu[0],
|
||||
&Start_Time[object_index].date);
|
||||
len = encode_tagged_date(&apdu[0], &Start_Time[object_index].date);
|
||||
apdu_len = len;
|
||||
len = encode_tagged_time(&apdu[apdu_len],
|
||||
&Start_Time[object_index].time);
|
||||
@@ -442,8 +436,7 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
Full_Duty_Baseline[object_index]);
|
||||
break;
|
||||
case PROP_EXPECTED_SHED_LEVEL:
|
||||
switch (Expected_Shed_Level[object_index].type)
|
||||
{
|
||||
switch (Expected_Shed_Level[object_index].type) {
|
||||
case BACNET_SHED_TYPE_PERCENT:
|
||||
apdu_len = encode_context_unsigned(&apdu[0], 0,
|
||||
Expected_Shed_Level[object_index].value.percent);
|
||||
@@ -460,8 +453,7 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
}
|
||||
break;
|
||||
case PROP_ACTUAL_SHED_LEVEL:
|
||||
switch (Actual_Shed_Level[object_index].type)
|
||||
{
|
||||
switch (Actual_Shed_Level[object_index].type) {
|
||||
case BACNET_SHED_TYPE_PERCENT:
|
||||
apdu_len = encode_context_unsigned(&apdu[0], 0,
|
||||
Actual_Shed_Level[object_index].value.percent);
|
||||
@@ -480,15 +472,16 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
case PROP_SHED_LEVELS:
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (array_index == BACNET_ARRAY_LENGTH_INDEX)
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], MAX_SHED_LEVELS);
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], MAX_SHED_LEVELS);
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (array_index == BACNET_ARRAY_ALL) {
|
||||
apdu_len = 0;
|
||||
for (i = 0; i < MAX_SHED_LEVELS; i++) {
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
len = encode_tagged_unsigned(&apdu[apdu_len], Shed_Levels[object_index][i]);
|
||||
len =
|
||||
encode_tagged_unsigned(&apdu[apdu_len],
|
||||
Shed_Levels[object_index][i]);
|
||||
/* add it if we have room */
|
||||
if ((apdu_len + len) < MAX_APDU)
|
||||
apdu_len += len;
|
||||
@@ -513,8 +506,7 @@ int Load_Control_Encode_Property_APDU(uint8_t * apdu,
|
||||
case PROP_SHED_LEVEL_DESCRIPTIONS:
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (array_index == BACNET_ARRAY_LENGTH_INDEX)
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], MAX_SHED_LEVELS);
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], MAX_SHED_LEVELS);
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (array_index == BACNET_ARRAY_ALL) {
|
||||
@@ -574,17 +566,15 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
object_index = Load_Control_Instance_To_Index(wp_data->object_instance);
|
||||
object_index =
|
||||
Load_Control_Instance_To_Index(wp_data->object_instance);
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_REQUESTED_SHED_LEVEL:
|
||||
len = bacapp_decode_context_data(
|
||||
wp_data->application_data,
|
||||
len = bacapp_decode_context_data(wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value, PROP_REQUESTED_SHED_LEVEL);
|
||||
if (value.tag == 0) {
|
||||
@@ -619,10 +609,9 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
}
|
||||
if (!status)
|
||||
break;
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data + len,
|
||||
wp_data->application_data_len - len,
|
||||
&value);
|
||||
len =
|
||||
bacapp_decode_application_data(wp_data->application_data + len,
|
||||
wp_data->application_data_len - len, &value);
|
||||
if (len && value.tag == BACNET_APPLICATION_TAG_TIME) {
|
||||
memcpy(&Start_Time[object_index].time,
|
||||
&value.type.Time, sizeof(value.type.Time));
|
||||
@@ -635,8 +624,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
break;
|
||||
case PROP_SHED_DURATION:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
Shed_Duration[object_index] =
|
||||
value.type.Unsigned_Int;
|
||||
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -645,8 +633,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
break;
|
||||
case PROP_DUTY_WINDOW:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||
Duty_Window[object_index] =
|
||||
value.type.Unsigned_Int;
|
||||
Duty_Window[object_index] = value.type.Unsigned_Int;
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -659,12 +646,10 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
if (wp_data->array_index == 0) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
}
|
||||
else if (wp_data->array_index == BACNET_ARRAY_ALL) {
|
||||
} else if (wp_data->array_index == BACNET_ARRAY_ALL) {
|
||||
/* FIXME: write entire array */
|
||||
status = true;
|
||||
}
|
||||
else if (wp_data->array_index <= MAX_SHED_LEVELS) {
|
||||
} else if (wp_data->array_index <= MAX_SHED_LEVELS) {
|
||||
Shed_Levels[object_index][wp_data->array_index - 1] =
|
||||
value.type.Unsigned_Int;
|
||||
status = true;
|
||||
@@ -677,8 +662,7 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
break;
|
||||
case PROP_ENABLE:
|
||||
if (value.tag == BACNET_APPLICATION_TAG_BOOLEAN) {
|
||||
Load_Control_Enable[object_index] =
|
||||
value.type.Boolean;
|
||||
Load_Control_Enable[object_index] = value.type.Boolean;
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -254,10 +254,8 @@ bool Life_Safety_Point_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
|
||||
@@ -237,15 +237,15 @@ int Multistate_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(object_instance);
|
||||
if (array_index <= BACNET_MAX_PRIORITY) {
|
||||
if (Multistate_Output_Level[object_index][array_index-1] ==
|
||||
MULTISTATE_NULL)
|
||||
if (Multistate_Output_Level[object_index][array_index -
|
||||
1] == MULTISTATE_NULL)
|
||||
apdu_len = encode_tagged_null(&apdu[0]);
|
||||
else {
|
||||
present_value =
|
||||
Multistate_Output_Level[object_index][array_index-1];
|
||||
Multistate_Output_Level[object_index][array_index -
|
||||
1];
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0],
|
||||
present_value);
|
||||
encode_tagged_unsigned(&apdu[0], present_value);
|
||||
}
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -292,10 +292,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
@@ -307,14 +305,14 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
object. */
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */ ) &&
|
||||
(value.type.Unsigned_Int <=
|
||||
MULTISTATE_NUMBER_OF_STATES)) {
|
||||
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
|
||||
level = value.type.Unsigned_Int;
|
||||
object_index =
|
||||
Multistate_Output_Instance_To_Index(wp_data->
|
||||
object_instance);
|
||||
priority--;
|
||||
Multistate_Output_Level[object_index][priority] = (uint8_t)level;
|
||||
Multistate_Output_Level[object_index][priority] =
|
||||
(uint8_t) level;
|
||||
/* Note: you could set the physical output here if we
|
||||
are the highest priority.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
@@ -339,7 +337,8 @@ bool Multistate_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
priority = wp_data->priority;
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
Multistate_Output_Level[object_index][priority] = (uint8_t)level;
|
||||
Multistate_Output_Level[object_index][priority] =
|
||||
(uint8_t) level;
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
priorities are set.
|
||||
|
||||
@@ -227,7 +227,8 @@ int main(int argc, char *argv[])
|
||||
"%s 123 1 0 85 4 100\r\n"
|
||||
"You could also send a relinquish command:\r\n"
|
||||
"%s 123 1 0 85 0 0\r\n",
|
||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||
filename_remove_path(argv[0]),
|
||||
filename_remove_path(argv[0]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-5
@@ -218,11 +218,8 @@ void testIAm(Test * pTest)
|
||||
|
||||
#ifdef TEST_IAM
|
||||
/* dummy function stubs */
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
unsigned pdu_len)
|
||||
int datalink_send_pdu(BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data, uint8_t * pdu, unsigned pdu_len)
|
||||
{
|
||||
(void) dest;
|
||||
(void) npdu_data;
|
||||
|
||||
+2
-1
@@ -337,7 +337,8 @@ void npdu_handler(BACNET_ADDRESS * src, /* source address */
|
||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||
/* only handle the version that we know how to handle */
|
||||
if (npdu_data.protocol_version == BACNET_PROTOCOL_VERSION)
|
||||
apdu_handler(src, &pdu[apdu_offset], (uint16_t)(pdu_len - apdu_offset));
|
||||
apdu_handler(src, &pdu[apdu_offset],
|
||||
(uint16_t) (pdu_len - apdu_offset));
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -78,8 +78,7 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
|
||||
{
|
||||
bool status = true; /* return value */
|
||||
|
||||
if (object_id <= BACNET_MAX_INSTANCE)
|
||||
{
|
||||
if (object_id <= BACNET_MAX_INSTANCE) {
|
||||
Object_Instance_Number = object_id;
|
||||
/* FIXME: Write the data to the eeprom */
|
||||
/* I2C_Write_Block(
|
||||
@@ -87,8 +86,7 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
|
||||
(char *)&Object_Instance_Number,
|
||||
sizeof(Object_Instance_Number),
|
||||
EEPROM_BACNET_ID_ADDR); */
|
||||
}
|
||||
else
|
||||
} else
|
||||
status = false;
|
||||
|
||||
return status;
|
||||
@@ -271,7 +269,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], Device_System_Status());
|
||||
apdu_len =
|
||||
encode_tagged_enumerated(&apdu[0], Device_System_Status());
|
||||
break;
|
||||
case PROP_VENDOR_NAME:
|
||||
(void) strcpypgm2ram(&string_buffer[0], "ASHRAE");
|
||||
@@ -279,7 +278,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_VENDOR_IDENTIFIER:
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], Device_Vendor_Identifier());
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], Device_Vendor_Identifier());
|
||||
break;
|
||||
case PROP_MODEL_NAME:
|
||||
(void) strcpypgm2ram(&string_buffer[0], "GNU Demo");
|
||||
@@ -399,16 +399,19 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
break;
|
||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], Device_Number_Of_APDU_Retries());
|
||||
encode_tagged_unsigned(&apdu[0],
|
||||
Device_Number_Of_APDU_Retries());
|
||||
break;
|
||||
case PROP_DEVICE_ADDRESS_BINDING:
|
||||
/* FIXME: encode the list here, if it exists */
|
||||
break;
|
||||
case PROP_DATABASE_REVISION:
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], Device_Database_Revision());
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], Device_Database_Revision());
|
||||
break;
|
||||
case PROP_MAX_INFO_FRAMES:
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], dlmstp_max_info_frames());
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], dlmstp_max_info_frames());
|
||||
break;
|
||||
case PROP_MAX_MASTER:
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], dlmstp_max_master());
|
||||
@@ -463,10 +466,8 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data,
|
||||
wp_data->application_data_len,
|
||||
&value);
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
switch (wp_data->object_property) {
|
||||
@@ -564,4 +565,3 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "rs485.h"
|
||||
#include "npdu.h"
|
||||
|
||||
// Number of MS/TP Packets Rx/Tx
|
||||
/* Number of MS/TP Packets Rx/Tx
*/
|
||||
uint16_t MSTP_Packets = 0;
|
||||
|
||||
/* receive buffer */
|
||||
@@ -49,7 +49,7 @@ volatile struct mstp_port_struct_t MSTP_Port;
|
||||
|
||||
#define INCREMENT_AND_LIMIT_UINT16(x) {if (x < 0xFFFF) x++;}
|
||||
|
||||
// This defines the number of edit fields for this module
|
||||
/* This defines the number of edit fields for this module
*/
|
||||
#define MAX_EDIT_FIELD 1
|
||||
static uint8_t EditField = 0;
|
||||
/* *************************************************************************
|
||||
@@ -59,22 +59,17 @@ static uint8_t EditField = 0;
|
||||
ALGORITHM: none
|
||||
NOTES: Pass a #>0 to increment #<0 to decrement
|
||||
*************************************************************************** */
|
||||
void dlmstp_SetEditField(
|
||||
signed char state) /* direction our editfield is moving */
|
||||
{
|
||||
if (state > 0)
|
||||
{
|
||||
void dlmstp_SetEditField(signed char state)
|
||||
{ /* direction our editfield is moving */
|
||||
if (state > 0) {
|
||||
if (++EditField > MAX_EDIT_FIELD)
|
||||
EditField = 0;
|
||||
}
|
||||
else if (state < 0)
|
||||
{
|
||||
} else if (state < 0) {
|
||||
if (EditField)
|
||||
EditField--;
|
||||
else
|
||||
EditField = MAX_EDIT_FIELD;
|
||||
}
|
||||
else
|
||||
} else
|
||||
EditField = 0;
|
||||
}
|
||||
|
||||
@@ -179,8 +174,7 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
|
||||
(uint8_t *) & MSTP_Port.TxBuffer[0],
|
||||
sizeof(MSTP_Port.TxBuffer),
|
||||
MSTP_Port.TxFrameType,
|
||||
destination,
|
||||
MSTP_Port.This_Station, pdu, pdu_len);
|
||||
destination, MSTP_Port.This_Station, pdu, pdu_len);
|
||||
MSTP_Port.TxLength = bytes_sent;
|
||||
MSTP_Port.TxReady = true;
|
||||
MSTP_Packets++;
|
||||
@@ -196,8 +190,7 @@ void dlmstp_task(void)
|
||||
|
||||
/* only do receive state machine while we don't have a frame */
|
||||
if ((MSTP_Port.ReceivedValidFrame == false) &&
|
||||
(MSTP_Port.ReceivedInvalidFrame == false))
|
||||
{
|
||||
(MSTP_Port.ReceivedInvalidFrame == false)) {
|
||||
do {
|
||||
bytes_remaining = RS485_Check_UART_Data(&MSTP_Port);
|
||||
MSTP_Receive_Frame_FSM(&MSTP_Port);
|
||||
@@ -209,18 +202,17 @@ void dlmstp_task(void)
|
||||
}
|
||||
/* only do master state machine while rx is idle */
|
||||
if (MSTP_Port.receive_state == MSTP_RECEIVE_STATE_IDLE) {
|
||||
while (MSTP_Master_Node_FSM(&MSTP_Port)) {};
|
||||
//MSTP_Master_Node_FSM(&MSTP_Port);
|
||||
while (MSTP_Master_Node_FSM(&MSTP_Port)) {
|
||||
};
|
||||
/*MSTP_Master_Node_FSM(&MSTP_Port);
*/
|
||||
}
|
||||
/* see if there is a packet available, and a place
|
||||
to put the reply (if necessary) and process it */
|
||||
if (Receive_Buffer.ready && !MSTP_Port.TxReady) {
|
||||
if (Receive_Buffer.pdu_len) {
|
||||
MSTP_Packets++;
|
||||
npdu_handler(
|
||||
&Receive_Buffer.address,
|
||||
&Receive_Buffer.pdu[0],
|
||||
Receive_Buffer.pdu_len);
|
||||
npdu_handler(&Receive_Buffer.address,
|
||||
&Receive_Buffer.pdu[0], Receive_Buffer.pdu_len);
|
||||
}
|
||||
Receive_Buffer.ready = false;
|
||||
}
|
||||
@@ -252,11 +244,10 @@ void dlmstp_fill_bacnet_address(BACNET_ADDRESS * src, uint8_t mstp_address)
|
||||
}
|
||||
|
||||
/* for the MS/TP state machine to use for putting received data */
|
||||
uint16_t dlmstp_put_receive(
|
||||
uint8_t src, /* source MS/TP address */
|
||||
uint16_t dlmstp_put_receive(uint8_t src, /* source MS/TP address */
|
||||
uint8_t * pdu, /* PDU data */
|
||||
uint16_t pdu_len) /* amount of PDU data */
|
||||
{
|
||||
uint16_t pdu_len)
|
||||
{ /* amount of PDU data */
|
||||
/* PDU is already in the Receive_Buffer */
|
||||
dlmstp_fill_bacnet_address(&Receive_Buffer.address, src);
|
||||
Receive_Buffer.pdu_len = pdu_len;
|
||||
|
||||
@@ -121,10 +121,8 @@
|
||||
#define CLICK() Hardware_Sound_Piezo(SHORT_BEEP);
|
||||
#define BEEP() Hardware_Sound_Piezo(LONG_BEEP);
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t:1;
|
||||
uint8_t:1;
|
||||
uint8_t Thursday:1;
|
||||
@@ -179,8 +177,7 @@ typedef union
|
||||
uint8_t Saturday:1;
|
||||
uint8_t Friday:1;
|
||||
};
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
uint8_t row1;
|
||||
uint8_t row2;
|
||||
uint8_t row3;
|
||||
@@ -190,10 +187,8 @@ typedef union
|
||||
};
|
||||
} LED_REGS;
|
||||
|
||||
union SWITCH_REGS
|
||||
{
|
||||
struct
|
||||
{
|
||||
union SWITCH_REGS {
|
||||
struct {
|
||||
uint8_t All_On:1;
|
||||
uint8_t All_Off:1;
|
||||
uint8_t Addr:4;
|
||||
@@ -265,4 +260,3 @@ extern uint8_t Piezo_Timer;
|
||||
extern volatile bool DataPortLocked;
|
||||
|
||||
#endif /* HARDWARE_H */
|
||||
|
||||
|
||||
@@ -46,40 +46,30 @@ void INT0_Interrupt(void);
|
||||
void InterruptVectorHigh(void)
|
||||
{
|
||||
_asm goto InterruptHandlerHigh /* jump to interrupt routine */
|
||||
_endasm
|
||||
}
|
||||
_endasm}
|
||||
#pragma code
|
||||
|
||||
#pragma code InterruptVectorLow = 0x318
|
||||
void InterruptVectorLow(void)
|
||||
{
|
||||
_asm goto InterruptHandlerLow /* jump to interrupt routine */
|
||||
_endasm
|
||||
}
|
||||
_endasm}
|
||||
#pragma code
|
||||
|
||||
#pragma interrupt InterruptHandlerHigh
|
||||
void InterruptHandlerHigh(void)
|
||||
{
|
||||
#if 0
|
||||
/* check for USART Rx int */
|
||||
if ((PIR1bits.RCIF) && (PIE1bits.RCIE))
|
||||
{
|
||||
if ((RCSTA1bits.FERR) || (RCSTA1bits.OERR))
|
||||
{
|
||||
if ((PIR1bits.RCIF) && (PIE1bits.RCIE)) {
|
||||
if ((RCSTA1bits.FERR) || (RCSTA1bits.OERR)) {
|
||||
Comstat.Rx_Bufferoverrun = TRUE;
|
||||
PIE1bits.RC1IE = 0; /* Disable Interrupt on receipt */
|
||||
}
|
||||
else if (Comstat.Rx_Bytes++ < RX_BUFFER_SIZE - 1)
|
||||
{
|
||||
} else if (Comstat.Rx_Bytes++ < RX_BUFFER_SIZE - 1) {
|
||||
Rx_Buffer[Comstat.RxHead++] = RCREG1;
|
||||
|
||||
/* Stick a Null on the end to let us use str functions on our
|
||||
* buffer */
|
||||
Rx_Buffer[Comstat.RxHead] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Comstat.Rx_Bufferoverrun = TRUE;
|
||||
PIE1bits.RC1IE = 0; /* Disable Interrupt on receipt */
|
||||
}
|
||||
@@ -87,8 +77,7 @@ void InterruptHandlerHigh (void)
|
||||
#endif
|
||||
|
||||
/* check for timer0 int */
|
||||
if ((INTCONbits.TMR0IF) && (INTCONbits.TMR0IE))
|
||||
{
|
||||
if ((INTCONbits.TMR0IF) && (INTCONbits.TMR0IE)) {
|
||||
INTCONbits.TMR0IF = 0;
|
||||
System_Seconds++;
|
||||
}
|
||||
@@ -100,43 +89,37 @@ void InterruptHandlerHigh (void)
|
||||
void InterruptHandlerLow(void)
|
||||
{
|
||||
/* check for timer2 int */
|
||||
if ((PIR1bits.TMR2IF) && (PIE1bits.TMR2IE))
|
||||
{
|
||||
if ((PIR1bits.TMR2IF) && (PIE1bits.TMR2IE)) {
|
||||
PIR1bits.TMR2IF = 0;
|
||||
Interrupt_Timer2();
|
||||
}
|
||||
|
||||
/* check for timer3 int */
|
||||
if ((PIR2bits.TMR3IF) && (PIE2bits.TMR3IE))
|
||||
{
|
||||
if ((PIR2bits.TMR3IF) && (PIE2bits.TMR3IE)) {
|
||||
PIR2bits.TMR3IF = 0;
|
||||
Interrupt_Timer3();
|
||||
}
|
||||
|
||||
/* check for timer4 int */
|
||||
if ((PIR3bits.TMR4IF) && (PIE3bits.TMR4IE))
|
||||
{
|
||||
if ((PIR3bits.TMR4IF) && (PIE3bits.TMR4IE)) {
|
||||
PIR3bits.TMR4IF = 0;
|
||||
dlmstp_millisecond_timer();
|
||||
Interrupt_Timer4();
|
||||
}
|
||||
|
||||
/* check for compare int */
|
||||
if ((PIR2bits.CCP2IF) && (PIE2bits.CCP2IE))
|
||||
{
|
||||
if ((PIR2bits.CCP2IF) && (PIE2bits.CCP2IE)) {
|
||||
PIR2bits.CCP2IF = 0;
|
||||
Interrupt_CCP2();
|
||||
}
|
||||
|
||||
/* check for USART Tx int */
|
||||
if ((PIR3bits.TX2IF) && (PIE3bits.TX2IE))
|
||||
{
|
||||
if ((PIR3bits.TX2IF) && (PIE3bits.TX2IE)) {
|
||||
RS485_Interrupt_Tx();
|
||||
}
|
||||
|
||||
/* check for USART Rx int */
|
||||
if ((PIR3bits.RC2IF) && (PIE3bits.RC2IE))
|
||||
{
|
||||
if ((PIR3bits.RC2IF) && (PIE3bits.RC2IE)) {
|
||||
RS485_Interrupt_Rx();
|
||||
}
|
||||
|
||||
@@ -207,4 +190,3 @@ void Interrupt_CCP2(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,15 +52,15 @@ static void BACnet_Service_Handlers_Init(void)
|
||||
/* We must implement read property - it's required! */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
handler_read_property);
|
||||
//apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
// handler_write_property);
|
||||
/*apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
*/
|
||||
/* handler_write_property);
*/
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
||||
handler_reinitialize_device);
|
||||
//apdu_set_unconfirmed_handler
|
||||
// (SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
|
||||
// handler_timesync_utc);
|
||||
//apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
|
||||
// handler_timesync);
|
||||
/*apdu_set_unconfirmed_handler
*/
|
||||
/* (SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
*/
|
||||
/* handler_timesync_utc);
*/
|
||||
/*apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
*/
|
||||
/* handler_timesync);
*/
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler
|
||||
(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
@@ -72,16 +72,11 @@ void Reinitialize(void)
|
||||
uint8_t i;
|
||||
char name = 0;
|
||||
|
||||
_asm reset _endasm
|
||||
}
|
||||
|
||||
void Global_Int(
|
||||
enum INT_STATE state) /* FIX ME: add comment */
|
||||
{
|
||||
_asm reset _endasm} void Global_Int(enum INT_STATE state)
|
||||
{ /* FIX ME: add comment */
|
||||
static uint8_t intstate = 0;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
switch (state) {
|
||||
case INT_DISABLED:
|
||||
intstate >>= 2;
|
||||
intstate |= (INTCON & 0xC0);
|
||||
@@ -134,13 +129,11 @@ void Verify_Ints(void)
|
||||
void MainTasks(void)
|
||||
{
|
||||
/* Handle our millisecond counters */
|
||||
while (Milliseconds)
|
||||
{
|
||||
while (Milliseconds) {
|
||||
--Milliseconds;
|
||||
}
|
||||
/* Handle our seconds counters */
|
||||
while (System_Seconds)
|
||||
{
|
||||
while (System_Seconds) {
|
||||
dcc_timer_seconds(1);
|
||||
System_Seconds--;
|
||||
}
|
||||
@@ -159,8 +152,7 @@ void main(void)
|
||||
/* Greet the BACnet world! */
|
||||
iam_send(&Handler_Transmit_Buffer[0]);
|
||||
/* Main loop */
|
||||
while (TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
RESTART_WDT();
|
||||
Verify_Ints();
|
||||
dlmstp_task();
|
||||
|
||||
@@ -450,7 +450,8 @@ void MSTP_Receive_Frame_FSM(volatile struct mstp_port_struct_t *mstp_port)
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
} else {
|
||||
if ((mstp_port->DestinationAddress == mstp_port->This_Station)
|
||||
if ((mstp_port->DestinationAddress ==
|
||||
mstp_port->This_Station)
|
||||
|| (mstp_port->DestinationAddress ==
|
||||
MSTP_BROADCAST_ADDRESS)) {
|
||||
/* FrameTooLong */
|
||||
@@ -459,21 +460,24 @@ void MSTP_Receive_Frame_FSM(volatile struct mstp_port_struct_t *mstp_port)
|
||||
/* unacceptable data length has been received */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
mstp_port->receive_state =
|
||||
MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
/* NoData */
|
||||
else if (mstp_port->DataLength == 0) {
|
||||
/* indicate that a frame with no data has been received */
|
||||
mstp_port->ReceivedValidFrame = true;
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
mstp_port->receive_state =
|
||||
MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
/* Data */
|
||||
else {
|
||||
mstp_port->Index = 0;
|
||||
mstp_port->DataCRC = 0xFFFF;
|
||||
/* receive the data portion of the frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_DATA;
|
||||
mstp_port->receive_state =
|
||||
MSTP_RECEIVE_STATE_DATA;
|
||||
}
|
||||
}
|
||||
/* NotForUs */
|
||||
@@ -766,7 +770,7 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
|
||||
mstp_port->DataLength);
|
||||
break;
|
||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||
//mstp_port->ReplyPostponedTimer = 0;
|
||||
/*mstp_port->ReplyPostponedTimer = 0;
*/
|
||||
/* indicate successful reception to the higher layers */
|
||||
dlmstp_put_receive(mstp_port->SourceAddress,
|
||||
(uint8_t *) & mstp_port->InputBuffer[0],
|
||||
@@ -1213,12 +1217,12 @@ void MSTP_Init(volatile struct mstp_port_struct_t *mstp_port)
|
||||
mstp_port->ReceivedValidFrame = false;
|
||||
mstp_port->RetryCount = 0;
|
||||
mstp_port->SilenceTimer = 0;
|
||||
// mstp_port->ReplyPostponedTimer = 0;
|
||||
/* mstp_port->ReplyPostponedTimer = 0;
*/
|
||||
mstp_port->SoleMaster = false;
|
||||
mstp_port->SourceAddress = 0;
|
||||
mstp_port->TokenCount = 0;
|
||||
#if 0
|
||||
// these are adjustable, so should already be set
|
||||
/* these are adjustable, so should already be set
*/
|
||||
mstp_port->Nmax_info_frames = DEFAULT_MAX_INFO_FRAMES;
|
||||
mstp_port->Nmax_master = DEFAULT_MAX_MASTER;
|
||||
#endif
|
||||
|
||||
@@ -162,7 +162,7 @@ struct mstp_port_struct_t {
|
||||
/* Machine when a Data Expecting Reply Answer activity is completed. */
|
||||
/* note: we always send a reply postponed since a message other than
|
||||
the reply may be in the transmit queue */
|
||||
// uint16_t ReplyPostponedTimer;
|
||||
/* uint16_t ReplyPostponedTimer;
*/
|
||||
|
||||
/* Used to store the Source Address of a received frame. */
|
||||
uint8_t SourceAddress;
|
||||
|
||||
@@ -43,7 +43,7 @@ uint32_t RS485_Baud_Rate = 9600;
|
||||
/* the ISR and other use this for status and control */
|
||||
COMSTAT RS485_Comstat;
|
||||
|
||||
//#pragma udata MSTPPortData
|
||||
/*#pragma udata MSTPPortData
*/
|
||||
/* the buffer for receiving characters */
|
||||
volatile uint8_t RS485_Rx_Buffer[MAX_MPDU];
|
||||
|
||||
@@ -58,8 +58,8 @@ volatile uint8_t RS485_Tx_Buffer[MAX_MPDU];
|
||||
*****************************************************************************/
|
||||
void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes) /* number of bytes of data (up to 501) */
|
||||
{
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint16_t i = 0; /* loop counter */
|
||||
uint8_t turnaround_time;
|
||||
|
||||
@@ -71,7 +71,8 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port
|
||||
return;
|
||||
|
||||
/* buffer is full. Wait for ISR to transmit. */
|
||||
while (RS485_Comstat.Tx_Bytes) {};
|
||||
while (RS485_Comstat.Tx_Bytes) {
|
||||
};
|
||||
|
||||
/* wait 40 bit times since reception */
|
||||
if (RS485_Baud_Rate == 9600)
|
||||
@@ -81,16 +82,17 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port
|
||||
else
|
||||
turnaround_time = 1;
|
||||
|
||||
while (mstp_port->SilenceTimer < turnaround_time) {};
|
||||
while (mstp_port->SilenceTimer < turnaround_time) {
|
||||
};
|
||||
|
||||
RS485_Comstat.TxHead = 0;
|
||||
memcpy((void *) &RS485_Tx_Buffer[0], (void *) buffer, nbytes);
|
||||
|
||||
//for (i = 0; i < nbytes; i++) {
|
||||
// /* put the data into the buffer */
|
||||
// RS485_Tx_Buffer[i] = *buffer;
|
||||
// buffer++;
|
||||
//}
|
||||
/*for (i = 0; i < nbytes; i++) {
*/
|
||||
/* /* put the data into the buffer */
*/
|
||||
/* RS485_Tx_Buffer[i] = *buffer;
*/
|
||||
/* buffer++;
*/
|
||||
/*}
*/
|
||||
RS485_Comstat.Tx_Bytes = nbytes;
|
||||
/* disable the receiver */
|
||||
PIE3bits.RC2IE = 0;
|
||||
@@ -113,11 +115,11 @@ void RS485_Send_Frame(volatile struct mstp_port_struct_t *mstp_port, /* port
|
||||
* ALGORITHM: none
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
uint8_t RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
||||
uint8_t RS485_Check_UART_Data(volatile struct mstp_port_struct_t *
|
||||
mstp_port)
|
||||
{
|
||||
/* check for data */
|
||||
if (RS485_Comstat.Rx_Bytes)
|
||||
{
|
||||
if (RS485_Comstat.Rx_Bytes) {
|
||||
mstp_port->DataRegister = RS485_Rx_Buffer[RS485_Comstat.RxTail];
|
||||
if (RS485_Comstat.RxTail >= (sizeof(RS485_Rx_Buffer) - 1))
|
||||
RS485_Comstat.RxTail = 0;
|
||||
@@ -125,8 +127,7 @@ uint8_t RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
||||
RS485_Comstat.RxTail++;
|
||||
RS485_Comstat.Rx_Bytes--;
|
||||
/* errors? let the state machine know */
|
||||
if (RS485_Comstat.Rx_Bufferoverrun)
|
||||
{
|
||||
if (RS485_Comstat.Rx_Bufferoverrun) {
|
||||
RS485_Comstat.Rx_Bufferoverrun = FALSE;
|
||||
mstp_port->ReceiveError = TRUE;
|
||||
}
|
||||
@@ -137,6 +138,7 @@ uint8_t RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
||||
|
||||
return RS485_Comstat.Rx_Bytes;
|
||||
}
|
||||
|
||||
/* *************************************************************************
|
||||
DESCRIPTION: Receives RS485 data stream
|
||||
|
||||
@@ -150,25 +152,20 @@ void RS485_Interrupt_Rx(void)
|
||||
{
|
||||
char dummy;
|
||||
|
||||
if ((RCSTA2bits.FERR) || (RCSTA2bits.OERR))
|
||||
{
|
||||
if ((RCSTA2bits.FERR) || (RCSTA2bits.OERR)) {
|
||||
/* Clear the error */
|
||||
RCSTA2bits.CREN = 0;
|
||||
RCSTA2bits.CREN = 1;
|
||||
RS485_Comstat.Rx_Bufferoverrun = TRUE;
|
||||
dummy = RCREG2;
|
||||
}
|
||||
else if (RS485_Comstat.Rx_Bytes < sizeof(RS485_Rx_Buffer))
|
||||
{
|
||||
} else if (RS485_Comstat.Rx_Bytes < sizeof(RS485_Rx_Buffer)) {
|
||||
RS485_Rx_Buffer[RS485_Comstat.RxHead] = RCREG2;
|
||||
if (RS485_Comstat.RxHead >= (sizeof(RS485_Rx_Buffer) - 1))
|
||||
RS485_Comstat.RxHead = 0;
|
||||
else
|
||||
RS485_Comstat.RxHead++;
|
||||
RS485_Comstat.Rx_Bytes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
RS485_Comstat.Rx_Bufferoverrun = TRUE;
|
||||
dummy = RCREG2;
|
||||
(void) dummy;
|
||||
@@ -186,17 +183,14 @@ void RS485_Interrupt_Rx(void)
|
||||
*************************************************************************** */
|
||||
void RS485_Interrupt_Tx(void)
|
||||
{
|
||||
if (RS485_Comstat.Tx_Bytes)
|
||||
{
|
||||
if (RS485_Comstat.Tx_Bytes) {
|
||||
/* Get the data byte */
|
||||
TXREG2 = RS485_Tx_Buffer[RS485_Comstat.TxHead];
|
||||
/* point to the next byte */
|
||||
RS485_Comstat.TxHead++;
|
||||
/* reduce the buffer size */
|
||||
RS485_Comstat.Tx_Bytes--;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* wait for the USART to be empty */
|
||||
while (!TXSTA2bits.TRMT);
|
||||
/* disable this interrupt */
|
||||
@@ -204,7 +198,7 @@ void RS485_Interrupt_Tx(void)
|
||||
/* enable the receiver */
|
||||
RS485_TX_ENABLE = 0;
|
||||
RS485_RX_DISABLE = 0;
|
||||
// FIXME: might not be necessary
|
||||
/* FIXME: might not be necessary
*/
|
||||
PIE3bits.RC2IE = 1;
|
||||
RCSTA2bits.CREN = 1;
|
||||
}
|
||||
@@ -231,8 +225,7 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
|
||||
{
|
||||
bool valid = true;
|
||||
|
||||
switch (baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case 9600:
|
||||
case 19200:
|
||||
case 38400:
|
||||
@@ -294,8 +287,7 @@ void RS485_Initialize_Port(void)
|
||||
625000 1
|
||||
1250000 0
|
||||
*/
|
||||
switch (RS485_Baud_Rate)
|
||||
{
|
||||
switch (RS485_Baud_Rate) {
|
||||
case 19200:
|
||||
SPBRG2 = 64;
|
||||
TXSTA2bits.BRGH = 1;
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
#include <stdint.h>
|
||||
#include "mstp.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t RxHead;
|
||||
uint8_t RxTail;
|
||||
uint8_t Rx_Bytes;
|
||||
|
||||
+2
-5
@@ -298,11 +298,8 @@ bool tsm_invoke_id_failed(uint8_t invokeID)
|
||||
bool I_Am_Request = true;
|
||||
|
||||
/* dummy function stubs */
|
||||
int datalink_send_pdu(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data,
|
||||
uint8_t * pdu,
|
||||
unsigned pdu_len)
|
||||
int datalink_send_pdu(BACNET_ADDRESS * dest,
|
||||
BACNET_NPDU_DATA * npdu_data, uint8_t * pdu, unsigned pdu_len)
|
||||
{
|
||||
(void) dest;
|
||||
(void) npdu_data;
|
||||
|
||||
+11
-19
@@ -195,7 +195,8 @@ int wp_decode_apdu(uint8_t * apdu,
|
||||
return len;
|
||||
}
|
||||
|
||||
void testWritePropertyTag(Test * pTest, BACNET_APPLICATION_DATA_VALUE * value)
|
||||
void testWritePropertyTag(Test * pTest,
|
||||
BACNET_APPLICATION_DATA_VALUE * value)
|
||||
{
|
||||
BACNET_WRITE_PROPERTY_DATA data = { 0 };
|
||||
BACNET_WRITE_PROPERTY_DATA test_data = { 0 };
|
||||
@@ -219,17 +220,14 @@ void testWritePropertyTag(Test * pTest, BACNET_APPLICATION_DATA_VALUE * value)
|
||||
ct_test(pTest, test_data.object_property == data.object_property);
|
||||
ct_test(pTest, test_data.array_index == data.array_index);
|
||||
/* decode the application value of the request */
|
||||
len = bacapp_decode_application_data(
|
||||
test_data.application_data,
|
||||
test_data.application_data_len,
|
||||
&test_value);
|
||||
len = bacapp_decode_application_data(test_data.application_data,
|
||||
test_data.application_data_len, &test_value);
|
||||
ct_test(pTest, test_value.tag == value->tag);
|
||||
switch (test_value.tag) {
|
||||
case BACNET_APPLICATION_TAG_NULL:
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_BOOLEAN:
|
||||
ct_test(pTest, test_value.type.Boolean ==
|
||||
value->type.Boolean);
|
||||
ct_test(pTest, test_value.type.Boolean == value->type.Boolean);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
ct_test(pTest, test_value.type.Unsigned_Int ==
|
||||
@@ -247,22 +245,16 @@ void testWritePropertyTag(Test * pTest, BACNET_APPLICATION_DATA_VALUE * value)
|
||||
value->type.Enumerated);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_DATE:
|
||||
ct_test(pTest, test_value.type.Date.year ==
|
||||
value->type.Date.year);
|
||||
ct_test(pTest, test_value.type.Date.year == value->type.Date.year);
|
||||
ct_test(pTest, test_value.type.Date.month ==
|
||||
value->type.Date.month);
|
||||
ct_test(pTest, test_value.type.Date.day ==
|
||||
value->type.Date.day);
|
||||
ct_test(pTest, test_value.type.Date.wday ==
|
||||
value->type.Date.wday);
|
||||
ct_test(pTest, test_value.type.Date.day == value->type.Date.day);
|
||||
ct_test(pTest, test_value.type.Date.wday == value->type.Date.wday);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_TIME:
|
||||
ct_test(pTest, test_value.type.Time.hour ==
|
||||
value->type.Time.hour);
|
||||
ct_test(pTest, test_value.type.Time.min ==
|
||||
value->type.Time.min);
|
||||
ct_test(pTest, test_value.type.Time.sec ==
|
||||
value->type.Time.sec);
|
||||
ct_test(pTest, test_value.type.Time.hour == value->type.Time.hour);
|
||||
ct_test(pTest, test_value.type.Time.min == value->type.Time.min);
|
||||
ct_test(pTest, test_value.type.Time.sec == value->type.Time.sec);
|
||||
ct_test(pTest, test_value.type.Time.hundredths ==
|
||||
value->type.Time.hundredths);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user