indented to standard from script

This commit is contained in:
skarg
2012-05-13 15:07:12 +00:00
parent 173e9fb9a9
commit 48e2c60ce2
130 changed files with 1931 additions and 2014 deletions
+45 -40
View File
@@ -129,7 +129,8 @@ static int32_t Property_List[MAX_PROPS + 2];
#define INIT_ID_PROPLIST_SIZE 5
/* Define Enums to match the property and value arrays below */
enum init_ids { INIT_VENDOR_NAME, INIT_MODEL_NAME, INIT_DESCRIPTION, INIT_OBJ_TYPES };
enum init_ids { INIT_VENDOR_NAME, INIT_MODEL_NAME, INIT_DESCRIPTION,
INIT_OBJ_TYPES };
static int32_t InitIdPropList[INIT_ID_PROPLIST_SIZE] = {
PROP_VENDOR_NAME,
PROP_MODEL_NAME, /* Have to use this twice, for Model Name and Number */
@@ -137,6 +138,7 @@ static int32_t InitIdPropList[INIT_ID_PROPLIST_SIZE] = {
PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED,
-1
};
/* Will hold GET_HEADING_RESPONSE results here: */
static BACNET_APPLICATION_DATA_VALUE *InitIdValues[INIT_ID_PROPLIST_SIZE] =
{ NULL, NULL, NULL, NULL, NULL };
@@ -245,8 +247,8 @@ void MyReadPropertyAckHandler(
rp_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
if (rp_data) {
len =
rp_ack_fully_decode_service_request(service_request, service_len,
rp_data);
rp_ack_fully_decode_service_request(service_request,
service_len, rp_data);
}
if (len > 0) {
memmove(&Read_Property_Multiple_Data.service_data, service_data,
@@ -303,8 +305,7 @@ static void Init_Service_Handlers(
/* Put this client Device into the Routing table (first entry) */
Object_Instance = Device_Object_Instance_Number();
Device_Object_Name(Object_Instance, &name_string);
Add_Routed_Device(Object_Instance, &name_string,
Device_Description());
Add_Routed_Device(Object_Instance, &name_string, Device_Description());
#endif
/* we need to handle who-is
@@ -442,10 +443,8 @@ bool PrettyPrintPropertyValue(
* clearer, international form. */
strncpy(short_month, bactext_month_name(value->type.Date.month), 3);
short_month[3] = 0;
fprintf(stream, "(%u-%3s-%u, %u)",
(unsigned) value->type.Date.day,
short_month,
(unsigned) value->type.Date.year,
fprintf(stream, "(%u-%3s-%u, %u)", (unsigned) value->type.Date.day,
short_month, (unsigned) value->type.Date.year,
(unsigned) value->type.Date.wday);
} else if (value != NULL) {
assert(false); /* How did I get here? Fix your code. */
@@ -637,8 +636,8 @@ void PrintReadPropertyData(
default:
/* First, if this is a date type, it needs a different format
* for VTS, so pretty print it. */
if (ShowValues && (object_value.value->tag == BACNET_APPLICATION_TAG_DATE))
{
if (ShowValues &&
(object_value.value->tag == BACNET_APPLICATION_TAG_DATE)) {
/* This would be PROP_LOCAL_DATE, or OBJECT_DATETIME_VALUE,
* or OBJECT_DATE_VALUE */
PrettyPrintPropertyValue(stdout, &object_value);
@@ -712,7 +711,9 @@ void Print_Property_Identifier(
* @param rpm_object [out] The structure holding our linked list of properties to request.
* @param propList [in] Simple list of properties (ptr to array), terminated with -1
*/
void BuildPropRequest( BACNET_READ_ACCESS_DATA *rpm_object, int32_t *propList )
void BuildPropRequest(
BACNET_READ_ACCESS_DATA * rpm_object,
int32_t * propList)
{
int i;
/* To start with, StartNextObject() has prepopulated one propEntry,
@@ -720,8 +721,7 @@ void BuildPropRequest( BACNET_READ_ACCESS_DATA *rpm_object, int32_t *propList )
*/
BACNET_PROPERTY_REFERENCE *propEntry = rpm_object->listOfProperties;
BACNET_PROPERTY_REFERENCE *oldEntry = rpm_object->listOfProperties;
for( i = 0; propList[i] != -1; i++ )
{
for (i = 0; propList[i] != -1; i++) {
if (propEntry == NULL) {
propEntry = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
assert(propEntry);
@@ -761,7 +761,8 @@ static uint8_t Read_Properties(
*/
property_list_special(pMyObject->type, &PropertyListStruct);
if (Optional_Properties) {
Property_List_Length = PropertyListStruct.Required.count +
Property_List_Length =
PropertyListStruct.Required.count +
PropertyListStruct.Optional.count;
} else {
Property_List_Length = PropertyListStruct.Required.count;
@@ -923,7 +924,8 @@ EPICS_STATES ProcessRPMData(
void PrintUsage(
)
{
printf("bacepics -- Generates Full EPICS file, including Object and Property List \r\n");
printf
("bacepics -- Generates Full EPICS file, including Object and Property List \r\n");
printf("Usage: \r\n");
printf
(" bacepics [-v] [-p sport] [-t target_mac [-n dnet]] device-instance \r\n");
@@ -935,13 +937,12 @@ void PrintUsage(
(" -t: declare target's MAC instead of using Who-Is to bind to \r\n");
printf
(" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n");
printf
(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n");
printf
(" -n: specify target's DNET if not local BACnet network \r\n");
printf(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n");
printf(" -n: specify target's DNET if not local BACnet network \r\n");
printf(" or on routed Virtual Network \r\n");
printf("\r\n");
printf("You may want to redirect the output to a .tpi file for VTS use,\r\n");
printf
("You may want to redirect the output to a .tpi file for VTS use,\r\n");
printf(" eg, bacepics -v 2701876 > epics-2701876.tpi \r\n");
printf("\r\n");
exit(0);
@@ -1040,7 +1041,8 @@ int CheckCommandLineArgs(
}
void PrintHeading( )
void PrintHeading(
)
{
BACNET_APPLICATION_DATA_VALUE *value;
char *relation = "for"; /* Text for Gateways */
@@ -1058,15 +1060,18 @@ void PrintHeading( )
value = InitIdValues[INIT_VENDOR_NAME];
if (value != NULL)
printf("Vendor Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) );
printf("Vendor Name: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
else
printf("Vendor Name: \"bacnet-stack\"\r\n");
value = InitIdValues[INIT_MODEL_NAME];
/* Best we can do with Product Name and Model Number is use the same text */
if (value != NULL) {
printf("Product Name: \"%s\"\r\n", characterstring_value( &value->type.Character_String) );
printf("Product Model Number: \"%s\"\r\n", characterstring_value( &value->type.Character_String) );
printf("Product Name: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
printf("Product Model Number: \"%s\"\r\n",
characterstring_value(&value->type.Character_String));
} else {
printf("Product Name: \"bacnet-stack Device\"\r\n");
printf("Product Model Number: \"Model XXX\"\r\n");
@@ -1074,7 +1079,8 @@ void PrintHeading( )
value = InitIdValues[INIT_DESCRIPTION];
if (value != NULL)
printf("Product Description: \"%s\"\r\n\r\n", characterstring_value( &value->type.Character_String) );
printf("Product Description: \"%s\"\r\n\r\n",
characterstring_value(&value->type.Character_String));
else
printf("Product Description: \"bacnet-stack Demo Device\"\r\n\r\n");
@@ -1113,8 +1119,7 @@ void PrintHeading( )
printf(" I-Am Initiate\r\n");
printf(" ReinitializeDevice Execute\r\n");
#ifdef BAC_ROUTING
if ( Target_Address.net == 0 )
{
if (Target_Address.net == 0) {
printf(" -- Note: The following Routing Services are Supported:\r\n");
printf(" -- Who-Is-Router-To-Network Initiate Execute\r\n");
printf(" -- I-Am-Router-To-Network Initiate Execute\r\n");
@@ -1143,8 +1148,7 @@ void PrintHeading( )
/* We have to process this bit string and determine which Object Types we have,
* and show them
*/
if ( ( value != NULL ) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING) )
{
if ((value != NULL) && (value->tag == BACNET_APPLICATION_TAG_BIT_STRING)) {
int i, len = bitstring_bits_used(&value->type.Bit_String);
for (i = 0; i < len; i++) {
if (bitstring_bit(&value->type.Bit_String, (uint8_t) i))
@@ -1500,11 +1504,11 @@ int main(
(Request_Invoke_ID ==
Read_Property_Multiple_Data.service_data.invoke_id)) {
Read_Property_Multiple_Data.new_data = false;
PrintReadPropertyData(Read_Property_Multiple_Data.
rpm_data->object_type,
PrintReadPropertyData
(Read_Property_Multiple_Data.rpm_data->object_type,
Read_Property_Multiple_Data.rpm_data->object_instance,
Read_Property_Multiple_Data.rpm_data->
listOfProperties);
Read_Property_Multiple_Data.
rpm_data->listOfProperties);
if (tsm_invoke_id_free(Request_Invoke_ID)) {
Request_Invoke_ID = 0;
} else {
@@ -1538,12 +1542,13 @@ int main(
} else {
/* OK, skip this one and try the next property. */
fprintf(stdout, " -- Failed to get ");
Print_Property_Identifier(
Property_List[Property_List_Index]);
Print_Property_Identifier(Property_List
[Property_List_Index]);
fprintf(stdout, " \r\n");
Error_Count++;
Property_List_Index++;
if (Property_List_Index >= Property_List_Length) {
if (Property_List_Index >=
Property_List_Length) {
/* Give up and move on to the next. */
myState = NEXT_OBJECT;
}
@@ -1636,10 +1641,10 @@ int main(
fprintf(stdout, "\r-- Found %d Errors \r\n", Error_Count);
/* Closing brace for all Objects, if we got any, and closing footer */
if (myState != INITIAL_BINDING)
{
if (myState != INITIAL_BINDING) {
printf("} \r\n");
printf("End of BACnet Protocol Implementation Conformance Statement\r\n");
printf
("End of BACnet Protocol Implementation Conformance Statement\r\n");
printf("\r\n");
}
+1 -2
View File
@@ -132,8 +132,7 @@ static void Init_Service_Handlers(
*/
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
handler_who_is_unicast);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
handler_who_has);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
/* set the handler for all the services we don't implement */
/* It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler
+13 -10
View File
@@ -55,7 +55,8 @@ static int bbmd_result = 0;
* @param address - IPv4 address (long) of BBMD to register with,
* in network byte order.
*/
void dlenv_bbmd_address_set( long address )
void dlenv_bbmd_address_set(
long address)
{
bbmd_address = address;
}
@@ -64,7 +65,8 @@ void dlenv_bbmd_address_set( long address )
* Default if not set is 0xBAC0.
* @param port - The port number (provided in network byte order).
*/
void dlenv_bbmd_port_set( int port )
void dlenv_bbmd_port_set(
int port)
{
bbmd_port = port;
}
@@ -73,7 +75,8 @@ void dlenv_bbmd_port_set( int port )
* Default if not set is 60000 (1000 minutes).
* @param ttl_secs - The Lease Time, in seconds.
*/
void dlenv_bbmd_ttl_set( int ttl_secs )
void dlenv_bbmd_ttl_set(
int ttl_secs)
{
bbmd_timetolive_seconds = ttl_secs;
}
@@ -86,7 +89,8 @@ void dlenv_bbmd_ttl_set( int ttl_secs )
* 0 if no registration request was made, or
* -1 if registration attempt failed.
*/
int dlenv_bbmd_result( void )
int dlenv_bbmd_result(
void)
{
if ((bbmd_result > 0) &&
(bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK))
@@ -138,15 +142,14 @@ int dlenv_register_as_foreign_device(
if (bbmd_address) {
struct in_addr addr;
addr.s_addr = bbmd_address;
fprintf(stderr,
"Registering with BBMD at %s:%ld for %ld seconds\n",
fprintf(stderr, "Registering with BBMD at %s:%ld for %ld seconds\n",
inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds);
retval = bvlc_register_with_bbmd(bbmd_address,
htons((uint16_t) bbmd_port),
retval =
bvlc_register_with_bbmd(bbmd_address, htons((uint16_t) bbmd_port),
(uint16_t) bbmd_timetolive_seconds);
if (retval < 0)
fprintf(stderr,
"FAILED to Register with BBMD at %s \n", inet_ntoa(addr) );
fprintf(stderr, "FAILED to Register with BBMD at %s \n",
inet_ntoa(addr));
BBMD_Timer_Seconds = bbmd_timetolive_seconds;
}
+4 -3
View File
@@ -106,7 +106,8 @@ void handler_ccov_notification(
fprintf(stderr, "CCOV: Segmented message. Sending Abort!\n");
#endif
goto CCOV_ABORT;
} /* decode the service request only */
}
/* decode the service request only */
/* decode the service request only */
len =
cov_notify_decode_service_request(service_request, service_len,
@@ -125,8 +126,8 @@ void handler_ccov_notification(
fprintf(stderr, "CCOV: ");
if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ",
bactext_property_name
(pProperty_value->propertyIdentifier));
bactext_property_name(pProperty_value->
propertyIdentifier));
} else {
fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier);
+22 -18
View File
@@ -390,8 +390,8 @@ static void cov_lifetime_expiration_handler(
if (lifetime_seconds >= elapsed_seconds) {
COV_Subscriptions[index].lifetime -= elapsed_seconds;
#if 0
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
index, (unsigned long) COV_Subscriptions[index].lifetime);
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n", index,
(unsigned long) COV_Subscriptions[index].lifetime);
#endif
} else {
COV_Subscriptions[index].lifetime = 0;
@@ -443,8 +443,7 @@ void handler_cov_timer_seconds(
lifetime_seconds = COV_Subscriptions[index].lifetime;
if (lifetime_seconds) {
/* only expire COV with definite lifetimes */
cov_lifetime_expiration_handler(index,
elapsed_seconds,
cov_lifetime_expiration_handler(index, elapsed_seconds,
lifetime_seconds);
}
}
@@ -452,7 +451,8 @@ void handler_cov_timer_seconds(
}
}
void handler_cov_task(void)
void handler_cov_task(
void)
{
static int index = 0;
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
@@ -461,8 +461,7 @@ void handler_cov_task(void)
bool send = false;
BACNET_PROPERTY_VALUE value_list[2];
/* states for transmitting */
static enum
{
static enum {
COV_STATE_IDLE = 0,
COV_STATE_MARK,
COV_STATE_CLEAR,
@@ -481,7 +480,8 @@ void handler_cov_task(void)
object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
status = Device_COV(object_type, object_instance);
if (status) {
COV_Subscriptions[index].flag.send_requested = true;
@@ -500,7 +500,8 @@ void handler_cov_task(void)
object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
Device_COV_Clear(object_type, object_instance);
}
index++;
@@ -516,8 +517,8 @@ void handler_cov_task(void)
(COV_Subscriptions[index].invokeID)) {
if (tsm_invoke_id_free(COV_Subscriptions[index].invokeID)) {
COV_Subscriptions[index].invokeID = 0;
} else if (tsm_invoke_id_failed(
COV_Subscriptions[index].invokeID)) {
} else if (tsm_invoke_id_failed(COV_Subscriptions[index].
invokeID)) {
tsm_free_invoke_id(COV_Subscriptions[index].invokeID);
COV_Subscriptions[index].invokeID = 0;
}
@@ -545,16 +546,18 @@ void handler_cov_task(void)
}
if (send) {
object_type = (BACNET_OBJECT_TYPE)
COV_Subscriptions[index].monitoredObjectIdentifier.type;
COV_Subscriptions[index].monitoredObjectIdentifier.
type;
object_instance =
COV_Subscriptions[index].monitoredObjectIdentifier.instance;
COV_Subscriptions[index].monitoredObjectIdentifier.
instance;
/* configure the linked list for the two properties */
value_list[0].next = &value_list[1];
value_list[1].next = NULL;
(void)Device_Encode_Value_List(object_type, object_instance,
&value_list[0]);
status = cov_send_request(
&COV_Subscriptions[index],
(void) Device_Encode_Value_List(object_type,
object_instance, &value_list[0]);
status =
cov_send_request(&COV_Subscriptions[index],
&value_list[0]);
if (status) {
COV_Subscriptions[index].flag.send_requested = false;
@@ -584,7 +587,8 @@ static bool cov_subscribe(
BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE;
uint32_t object_instance = 0;
object_type = (BACNET_OBJECT_TYPE)cov_data->monitoredObjectIdentifier.type;
object_type =
(BACNET_OBJECT_TYPE) cov_data->monitoredObjectIdentifier.type;
object_instance = cov_data->monitoredObjectIdentifier.instance;
status = Device_Valid_Object_Id(object_type, object_instance);
if (status) {
+3 -2
View File
@@ -157,8 +157,9 @@ void handler_device_communication_control(
} else {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval(
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state,
len =
Routed_Device_Service_Approval
(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
if (len > 0)
goto DCC_ABORT;
+10 -13
View File
@@ -90,9 +90,9 @@ void handler_get_alarm_summary(
}
/* init header */
apdu_len = get_alarm_summary_ack_encode_apdu_init(
&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id);
apdu_len =
get_alarm_summary_ack_encode_apdu_init(&Handler_Transmit_Buffer
[pdu_len], service_data->invoke_id);
for (i = 0; i < MAX_BACNET_OBJECT_TYPE; i++) {
@@ -100,18 +100,16 @@ void handler_get_alarm_summary(
for (j = 0; j < 0xffff; j++) {
alarm_value = Get_Alarm_Summary[i] (j, &getalarm_data);
if (alarm_value > 0) {
len = get_alarm_sumary_ack_encode_apdu_data(
&Handler_Transmit_Buffer[pdu_len + apdu_len],
service_data->max_resp - apdu_len,
&getalarm_data);
len =
get_alarm_sumary_ack_encode_apdu_data
(&Handler_Transmit_Buffer[pdu_len + apdu_len],
service_data->max_resp - apdu_len, &getalarm_data);
if (len <= 0) {
error = true;
goto GET_ALARM_SUMMARY_ERROR;
}
else
} else
apdu_len += len;
}
else if (alarm_value < 0) {
} else if (alarm_value < 0) {
break;
}
}
@@ -135,8 +133,7 @@ GET_ALARM_SUMMARY_ERROR:
fprintf(stderr,
"GetAlarmSummary: Reply too big to fit into APDU!\n");
#endif
}
else {
} else {
apdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_GET_ALARM_SUMMARY,
+3 -2
View File
@@ -131,8 +131,9 @@ void handler_reinitialize_device(
} else {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval(
SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state,
len =
Routed_Device_Service_Approval
(SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id);
if (len > 0)
goto RD_ABORT;
+2 -1
View File
@@ -296,7 +296,8 @@ void handler_read_property_multiple(
&Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) {
#if PRINT_ENABLED
fprintf(stderr, "RPM: Too full to encode property!\r\n");
fprintf(stderr,
"RPM: Too full to encode property!\r\n");
#endif
rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
+6 -6
View File
@@ -221,8 +221,8 @@ void rpm_ack_print_data(
#if PRINT_ENABLED
if (listOfProperties->propertyIdentifier < 512) {
fprintf(stdout, " %s: ",
bactext_property_name(listOfProperties->
propertyIdentifier));
bactext_property_name
(listOfProperties->propertyIdentifier));
} else {
fprintf(stdout, " proprietary %u: ",
(unsigned) listOfProperties->propertyIdentifier);
@@ -269,10 +269,10 @@ void rpm_ack_print_data(
#if PRINT_ENABLED
/* AccessError */
fprintf(stdout, "BACnet Error: %s: %s\r\n",
bactext_error_class_name((int) listOfProperties->
error.error_class),
bactext_error_code_name((int) listOfProperties->
error.error_code));
bactext_error_class_name((int) listOfProperties->error.
error_class),
bactext_error_code_name((int) listOfProperties->error.
error_code));
#endif
}
listOfProperties = listOfProperties->next;
+2 -2
View File
@@ -104,8 +104,8 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: ");
if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ",
bactext_property_name
(pProperty_value->propertyIdentifier));
bactext_property_name(pProperty_value->
propertyIdentifier));
} else {
fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier);
+3 -3
View File
@@ -56,8 +56,9 @@ void handler_unconfirmed_private_transfer(
#if PRINT_ENABLED
fprintf(stderr, "Received Unconfirmed Private Transfer Request!\n");
#endif
len = ptransfer_decode_service_request(
service_request, service_len, &private_data);
len =
ptransfer_decode_service_request(service_request, service_len,
&private_data);
if (len >= 0) {
#if PRINT_ENABLED
printf("PrivateTransfer:vendorID=%u\r\n",
@@ -107,4 +108,3 @@ void handler_unconfirmed_private_transfer(
#endif
}
}
+2 -3
View File
@@ -65,9 +65,8 @@ static void match_name_or_object(
} else {
/* valid object_name copy in my device? */
found =
Device_Object_Name_Copy(
(BACNET_OBJECT_TYPE)data->object.identifier.type,
data->object.identifier.instance, &object_name);
Device_Object_Name_Copy((BACNET_OBJECT_TYPE) data->object.
identifier.type, data->object.identifier.instance, &object_name);
if (found) {
Send_I_Have(Device_Object_Instance_Number(),
(BACNET_OBJECT_TYPE) data->object.identifier.type,
+2 -2
View File
@@ -181,8 +181,8 @@ bool WPValidateString(
(!characterstring_printable(&pValue->type.Character_String))) {
/* assumption: non-empty also means must be "printable" */
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (characterstring_length(&pValue->
type.Character_String) > iMaxLen) {
} else if (characterstring_length(&pValue->type.Character_String) >
iMaxLen) {
*pErrorClass = ERROR_CLASS_RESOURCES;
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
} else
+2 -3
View File
@@ -157,9 +157,8 @@ uint8_t Send_Write_Property_Request(
#if PRINT_ENABLED_DEBUG
fprintf(stderr, "WriteProperty service: " "%s tag=%d\n",
(object_value->context_specific ? "context" : "application"),
(int) (object_value->
context_specific ? object_value->context_tag : object_value->
tag));
(int) (object_value->context_specific ? object_value->
context_tag : object_value->tag));
#endif
len = bacapp_encode_data(&application_data[apdu_len], object_value);
if ((len + apdu_len) < MAX_APDU) {
+10 -5
View File
@@ -73,7 +73,9 @@ static FILE *pFile = NULL; /* stream pointer */
* RETURN: number of arguments parsed
* NOTES: none
******************************************************************/
static void Parse_Arguments(int argc, char *argv[])
static void Parse_Arguments(
int argc,
char *argv[])
{
int i = 0;
long long_value = 0;
@@ -173,7 +175,9 @@ static void write_global_header(
}
}
static void write_received_packet(uint8_t *buffer, unsigned length)
static void write_received_packet(
uint8_t * buffer,
unsigned length)
{
uint32_t ts_sec; /* timestamp seconds */
uint32_t ts_usec; /* timestamp microseconds */
@@ -197,7 +201,9 @@ static void write_received_packet(uint8_t *buffer, unsigned length)
}
}
static void Write_Pcap(uint8_t *buffer, unsigned length)
static void Write_Pcap(
uint8_t * buffer,
unsigned length)
{
filename_create(&Capture_Filename[0]);
write_global_header(&Capture_Filename[0]);
@@ -220,8 +226,7 @@ int main(
/* initialize our interface */
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
printf("mstpcrc [options] <00 00 00 00...>\r\n"
"perform MS/TP CRC on data bytes.\r\n"
"options:\r\n"
"perform MS/TP CRC on data bytes.\r\n" "options:\r\n"
"[-x] interprete the arguments as ascii hex (default)\r\n"
"[-d] interprete the argument as ascii decimal\r\n"
"[-m] Write the bytes to Wireshark capture file\r\n"
+73 -66
View File
@@ -352,11 +352,11 @@ int Analog_Input_Read_Property(
case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0,
(CurrentAI->
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
(CurrentAI->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true :
false);
bitstring_set_bit(&bit_string, 1,
(CurrentAI->
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
(CurrentAI->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -364,14 +364,14 @@ int Analog_Input_Read_Property(
case PROP_EVENT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAI->
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(CurrentAI->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -379,8 +379,8 @@ int Analog_Input_Read_Property(
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
@@ -909,17 +909,17 @@ void Analog_Input_Intrinsic_Reporting(
event_data.notificationParams.outOfRange.exceedingValue =
PresentVal;
/* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange.
statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_IN_ALARM,
bitstring_init(&event_data.notificationParams.
outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAI->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAI->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband =
@@ -939,24 +939,30 @@ void Analog_Input_Intrinsic_Reporting(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
false;
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_FAULT].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
false;
CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked = false;
CurrentAI->Acked_Transitions[TRANSITION_TO_NORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
false;
CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
}
}
@@ -983,12 +989,12 @@ int Analog_Input_Event_Information(
/* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions =
(AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked ==
false) | (AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked == false);
(AI_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked ==
false) | (AI_Descr[index].
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) | (AI_Descr[index].
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
} else
return -1; /* end of list */
@@ -1003,8 +1009,8 @@ int Analog_Input_Event_Information(
bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AI_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
@@ -1022,14 +1028,14 @@ int Analog_Input_Event_Information(
/* Event Enable */
bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AI_Descr[index].
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(AI_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
/* Event Priorities */
Notification_Class_Get_Priorities(AI_Descr[index].Notification_Class,
getevent_data->eventPriorities);
@@ -1049,8 +1055,8 @@ int Analog_Input_Alarm_Ack(
object_index =
Analog_Input_Instance_To_Index(alarmack_data->eventObjectIdentifier.
instance);
Analog_Input_Instance_To_Index(alarmack_data->
eventObjectIdentifier.instance);
if (object_index < MAX_ANALOG_INPUTS)
CurrentAI = &AI_Descr[object_index];
@@ -1063,22 +1069,22 @@ int Analog_Input_Alarm_Ack(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
if (CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked == false) {
if (CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
if (datetime_compare(&CurrentAI->Acked_Transitions
[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* FIXME: Send ack notification */
CurrentAI->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = true;
CurrentAI->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
@@ -1092,8 +1098,8 @@ int Analog_Input_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
if (datetime_compare(&CurrentAI->Acked_Transitions
[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1115,8 +1121,8 @@ int Analog_Input_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAI->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
if (datetime_compare(&CurrentAI->Acked_Transitions
[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1159,18 +1165,19 @@ int Analog_Input_Alarm_Summary(
bitstring_init(&getalarm_data->acknowledgedTransitions);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AI_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
AI_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL,
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
AI_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked);
return 1; /* active alarm */
}
else
} else
return 0; /* no active alarm at this index */
} else
return -1; /* end of list */
-1
View File
@@ -149,5 +149,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+4 -4
View File
@@ -447,11 +447,11 @@ bool Analog_Output_Write_Property(
if (status) {
level = AO_LEVEL_NULL;
object_index =
Analog_Output_Instance_To_Index
(wp_data->object_instance);
Analog_Output_Instance_To_Index(wp_data->
object_instance);
status =
Analog_Output_Present_Value_Relinquish
(wp_data->object_instance, wp_data->priority);
Analog_Output_Present_Value_Relinquish(wp_data->
object_instance, wp_data->priority);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -100,5 +100,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+73 -66
View File
@@ -424,11 +424,11 @@ int Analog_Value_Read_Property(
case PROP_LIMIT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, 0,
(CurrentAV->
Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true : false);
(CurrentAV->Limit_Enable & EVENT_LOW_LIMIT_ENABLE) ? true :
false);
bitstring_set_bit(&bit_string, 1,
(CurrentAV->
Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true : false);
(CurrentAV->Limit_Enable & EVENT_HIGH_LIMIT_ENABLE) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -436,14 +436,14 @@ int Analog_Value_Read_Property(
case PROP_EVENT_ENABLE:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
(CurrentAV->
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(CurrentAV->Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
break;
@@ -451,8 +451,8 @@ int Analog_Value_Read_Property(
case PROP_ACKED_TRANSITIONS:
bitstring_init(&bit_string);
bitstring_set_bit(&bit_string, TRANSITION_TO_OFFNORMAL,
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_FAULT,
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
bitstring_set_bit(&bit_string, TRANSITION_TO_NORMAL,
@@ -1004,17 +1004,17 @@ void Analog_Value_Intrinsic_Reporting(
event_data.notificationParams.outOfRange.exceedingValue =
PresentVal;
/* Status_Flags of the referenced object. */
bitstring_init(&event_data.notificationParams.outOfRange.
statusFlags);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_IN_ALARM,
bitstring_init(&event_data.notificationParams.
outOfRange.statusFlags);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_IN_ALARM,
CurrentAV->Event_State ? true : false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.outOfRange.
statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_FAULT, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OVERRIDDEN, false);
bitstring_set_bit(&event_data.notificationParams.
outOfRange.statusFlags, STATUS_FLAG_OUT_OF_SERVICE,
CurrentAV->Out_Of_Service);
/* Deadband used for limit checking. */
event_data.notificationParams.outOfRange.deadband =
@@ -1034,24 +1034,30 @@ void Analog_Value_Intrinsic_Reporting(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked =
false;
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_FAULT:
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_FAULT].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked =
false;
CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
case EVENT_STATE_NORMAL:
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked = false;
CurrentAV->Acked_Transitions[TRANSITION_TO_NORMAL].
Time_Stamp = event_data.timeStamp.value.dateTime;
CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked =
false;
CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp =
event_data.timeStamp.value.dateTime;
break;
}
}
@@ -1078,12 +1084,12 @@ int Analog_Value_Event_Information(
/* Acked_Transitions property, which has at least one of the bits
(TO-OFFNORMAL, TO-FAULT, TONORMAL) set to FALSE. */
IsNotAckedTransitions =
(AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked ==
false) | (AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked == false);
(AV_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked ==
false) | (AV_Descr[index].
Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked ==
false) | (AV_Descr[index].
Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked == false);
} else
return -1; /* end of list */
@@ -1098,8 +1104,8 @@ int Analog_Value_Event_Information(
bitstring_init(&getevent_data->acknowledgedTransitions);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AV_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getevent_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
@@ -1117,14 +1123,14 @@ int Analog_Value_Event_Information(
/* Event Enable */
bitstring_init(&getevent_data->eventEnable);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_OFFNORMAL,
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true : false);
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_OFFNORMAL) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_FAULT,
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_FAULT) ? true : false);
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_FAULT) ? true :
false);
bitstring_set_bit(&getevent_data->eventEnable, TRANSITION_TO_NORMAL,
(AV_Descr[index].
Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true : false);
(AV_Descr[index].Event_Enable & EVENT_ENABLE_TO_NORMAL) ? true :
false);
/* Event Priorities */
Notification_Class_Get_Priorities(AV_Descr[index].Notification_Class,
getevent_data->eventPriorities);
@@ -1143,8 +1149,8 @@ int Analog_Value_Alarm_Ack(
object_index =
Analog_Value_Instance_To_Index(alarmack_data->eventObjectIdentifier.
instance);
Analog_Value_Instance_To_Index(alarmack_data->
eventObjectIdentifier.instance);
if (object_index < MAX_ANALOG_VALUES)
CurrentAV = &AV_Descr[object_index];
@@ -1157,22 +1163,22 @@ int Analog_Value_Alarm_Ack(
case EVENT_STATE_OFFNORMAL:
case EVENT_STATE_HIGH_LIMIT:
case EVENT_STATE_LOW_LIMIT:
if (CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked == false) {
if (CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked == false) {
if (alarmack_data->eventTimeStamp.tag != TIME_STAMP_DATETIME) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].Time_Stamp,
if (datetime_compare(&CurrentAV->Acked_Transitions
[TRANSITION_TO_OFFNORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
/* Clean transitions flag. */
CurrentAV->Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked = true;
CurrentAV->
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked = true;
} else {
*error_code = ERROR_CODE_INVALID_EVENT_STATE;
return -1;
@@ -1186,8 +1192,8 @@ int Analog_Value_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_NORMAL].Time_Stamp,
if (datetime_compare(&CurrentAV->Acked_Transitions
[TRANSITION_TO_NORMAL].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1209,8 +1215,8 @@ int Analog_Value_Alarm_Ack(
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
}
if (datetime_compare(&CurrentAV->
Acked_Transitions[TRANSITION_TO_FAULT].Time_Stamp,
if (datetime_compare(&CurrentAV->Acked_Transitions
[TRANSITION_TO_FAULT].Time_Stamp,
&alarmack_data->eventTimeStamp.value.dateTime) > 0) {
*error_code = ERROR_CODE_INVALID_TIME_STAMP;
return -1;
@@ -1258,18 +1264,19 @@ int Analog_Value_Alarm_Summary(
bitstring_init(&getalarm_data->acknowledgedTransitions);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_OFFNORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_OFFNORMAL].
bIsAcked);
AV_Descr[index].
Acked_Transitions[TRANSITION_TO_OFFNORMAL].bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_FAULT,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].bIsAcked);
AV_Descr[index].Acked_Transitions[TRANSITION_TO_FAULT].
bIsAcked);
bitstring_set_bit(&getalarm_data->acknowledgedTransitions,
TRANSITION_TO_NORMAL,
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].bIsAcked);
AV_Descr[index].Acked_Transitions[TRANSITION_TO_NORMAL].
bIsAcked);
return 1; /* active alarm */
}
else
} else
return 0; /* no active alarm at this index */
} else
return -1; /* end of list */
-1
View File
@@ -132,5 +132,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+2 -1
View File
@@ -474,7 +474,8 @@ bool bacfile_write_stream_data(
}
if (pFile) {
if (data->type.stream.fileStartPosition != -1) {
(void) fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
(void) fseek(pFile, data->type.stream.fileStartPosition,
SEEK_SET);
}
if (fwrite(octetstring_value(&data->fileData),
octetstring_length(&data->fileData), 1, pFile) != 1) {
-1
View File
@@ -98,5 +98,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
-1
View File
@@ -114,5 +114,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+4 -4
View File
@@ -376,8 +376,8 @@ bool Binary_Output_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index =
Binary_Output_Instance_To_Index
(wp_data->object_instance);
Binary_Output_Instance_To_Index(wp_data->
object_instance);
priority--;
Binary_Output_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we
@@ -403,8 +403,8 @@ bool Binary_Output_Write_Property(
if (status) {
level = BINARY_NULL;
object_index =
Binary_Output_Instance_To_Index
(wp_data->object_instance);
Binary_Output_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
-1
View File
@@ -116,5 +116,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+4 -4
View File
@@ -359,8 +359,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Binary_Value_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we
@@ -386,8 +386,8 @@ bool Binary_Value_Write_Property(
if (status) {
level = BINARY_NULL;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
-1
View File
@@ -71,5 +71,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+10 -14
View File
@@ -152,9 +152,7 @@ bool CharacterString_Value_Present_Value(
index = CharacterString_Value_Instance_To_Index(object_instance);
if (object_name && (index < MAX_CHARACTERSTRING_VALUES)) {
status = characterstring_copy(
object_name,
&Present_Value[index]);
status = characterstring_copy(object_name, &Present_Value[index]);
}
return status;
@@ -169,9 +167,7 @@ bool CharacterString_Value_Present_Value_Set(
index = CharacterString_Value_Instance_To_Index(object_instance);
if (index < MAX_CHARACTERSTRING_VALUES) {
status = characterstring_copy(
&Present_Value[index],
object_name);
status = characterstring_copy(&Present_Value[index], object_name);
}
return status;
@@ -361,7 +357,8 @@ int CharacterString_Value_Read_Property(
break;
case PROP_OUT_OF_SERVICE:
object_index =
CharacterString_Value_Instance_To_Index(rpdata->object_instance);
CharacterString_Value_Instance_To_Index(rpdata->
object_instance);
state = Out_Of_Service[object_index];
apdu_len = encode_application_boolean(&apdu[0], state);
break;
@@ -405,13 +402,12 @@ bool CharacterString_Value_Write_Property(
case PROP_PRESENT_VALUE:
status =
WPValidateArgType(&value,
BACNET_APPLICATION_TAG_CHARACTER_STRING,
&wp_data->error_class, &wp_data->error_code);
BACNET_APPLICATION_TAG_CHARACTER_STRING, &wp_data->error_class,
&wp_data->error_code);
if (status) {
status =
CharacterString_Value_Present_Value_Set
(wp_data->object_instance,
&value.type.Character_String);
CharacterString_Value_Present_Value_Set(wp_data->
object_instance, &value.type.Character_String);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -423,8 +419,8 @@ bool CharacterString_Value_Write_Property(
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
&wp_data->error_class, &wp_data->error_code);
if (status) {
CharacterString_Value_Out_Of_Service_Set(
wp_data->object_instance, value.type.Boolean);
CharacterString_Value_Out_Of_Service_Set(wp_data->
object_instance, value.type.Boolean);
}
break;
default:
-1
View File
@@ -92,5 +92,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+1 -2
View File
@@ -906,6 +906,7 @@ bool Device_Write_Property(
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
return (status);
}
/* Ditto for the local version; always returns false */
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data)
@@ -941,5 +942,3 @@ void Device_Init(
pObject++;
}
}
+13 -14
View File
@@ -1419,8 +1419,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
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 */
} else {
status = false;
@@ -1453,8 +1453,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
/* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t) value.
type.Unsigned_Int);
Device_Set_Vendor_Identifier((uint16_t) value.type.
Unsigned_Int);
}
break;
case PROP_SYSTEM_STATUS:
@@ -1500,8 +1500,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Location(characterstring_value(&value.
type.Character_String),
Device_Set_Location(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1511,8 +1511,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Description(characterstring_value(&value.
type.Character_String),
Device_Set_Description(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1521,8 +1521,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Model_Name(characterstring_value(&value.
type.Character_String),
Device_Set_Model_Name(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -1534,8 +1534,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames((uint8_t) value.
type.Unsigned_Int);
dlmstp_set_max_info_frames((uint8_t) value.type.
Unsigned_Int);
} else {
status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1650,8 +1650,7 @@ bool Device_COV(
if (pObject->Object_Valid_Instance &&
pObject->Object_Valid_Instance(object_instance)) {
if (pObject->Object_COV) {
status = pObject->Object_COV(
object_instance);
status = pObject->Object_COV(object_instance);
}
}
}
+2 -7
View File
@@ -431,7 +431,6 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
/** @defgroup ObjFrmwk Object Framework
* The modules in this section describe the BACnet-stack's framework for
* BACnet-defined Objects (Device, Analog Input, etc). There are two submodules
@@ -441,15 +440,11 @@ extern "C" {
* - The interface between the implemented Objects and the BAC-stack services,
* specifically the handlers, which are mediated through function calls to
* the Device object.
*/
/** @defgroup ObjHelpers Object Helper Functions
*//** @defgroup ObjHelpers Object Helper Functions
* @ingroup ObjFrmwk
* This section describes the function templates for the helper functions that
* provide common object support.
*/
/** @defgroup ObjIntf Handler-to-Object Interface Functions
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
* @ingroup ObjFrmwk
* This section describes the fairly limited set of functions that link the
* BAC-stack handlers to the BACnet Object instances. All of these calls are
+13 -11
View File
@@ -407,7 +407,8 @@ bool Routed_Device_Name(
{
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if (object_instance == pDev->bacObj.Object_Instance_Number) {
return characterstring_init_ansi(object_name, pDev->bacObj.Object_Name);
return characterstring_init_ansi(object_name,
pDev->bacObj.Object_Name);
}
return NULL;
@@ -485,8 +486,8 @@ bool Routed_Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Routed_Device_Set_Object_Instance_Number(value.type.
Object_Id.instance))) {
(Routed_Device_Set_Object_Instance_Number(value.
type.Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */
} else {
status = false;
@@ -500,8 +501,8 @@ bool Routed_Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Routed_Device_Set_Object_Name(characterstring_encoding(&value.
type.Character_String),
Routed_Device_Set_Object_Name(characterstring_encoding
(&value.type.Character_String),
characterstring_value(&value.type.Character_String),
characterstring_length(&value.type.Character_String));
}
@@ -617,14 +618,14 @@ int Routed_Device_Service_Approval(
uint8_t invoke_id)
{
int len = 0;
switch(service)
{
switch (service) {
case SERVICE_CONFIRMED_REINITIALIZE_DEVICE:
/* If not the gateway device, we don't support RD */
if (iCurrent_Device_Idx > 0) {
if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
len =
reject_encode_apdu(apdu_buff, invoke_id,
REJECT_REASON_UNRECOGNIZED_SERVICE);
else
len = 1; /* Non-zero return */
}
@@ -633,8 +634,9 @@ int Routed_Device_Service_Approval(
/* If not the gateway device, we don't support DCC */
if (iCurrent_Device_Idx > 0) {
if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
len =
reject_encode_apdu(apdu_buff, invoke_id,
REJECT_REASON_UNRECOGNIZED_SERVICE);
else
len = 1; /* Non-zero return */
}
-1
View File
@@ -76,5 +76,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+8 -8
View File
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
object_index =
Lighting_Output_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Lighting_Output_Level[object_index][rpdata->array_index
- 1] == LIGHTING_LEVEL_NULL)
if (Lighting_Output_Level[object_index][rpdata->
array_index - 1] == LIGHTING_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]);
else {
real_value = Lighting_Output_Level[object_index]
@@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property(
if (status) {
level = LIGHTING_LEVEL_NULL;
object_index =
Lighting_Output_Instance_To_Index
(wp_data->object_instance);
Lighting_Output_Instance_To_Index(wp_data->
object_instance);
status =
Lighting_Output_Present_Value_Relinquish
(wp_data->object_instance, wp_data->priority);
Lighting_Output_Present_Value_Relinquish(wp_data->
object_instance, wp_data->priority);
if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
@@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Lighting_Output_Instance_To_Index
(wp_data->object_instance);
Lighting_Output_Instance_To_Index(wp_data->
object_instance);
Lighting_Output_Out_Of_Service[object_index] =
value.type.Boolean;
}
+4 -4
View File
@@ -332,8 +332,8 @@ bool Life_Safety_Point_Write_Property(
if (status) {
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
object_index =
Life_Safety_Point_Instance_To_Index
(wp_data->object_instance);
Life_Safety_Point_Instance_To_Index(wp_data->
object_instance);
Life_Safety_Point_Mode[object_index] =
value.type.Enumerated;
} else {
@@ -349,8 +349,8 @@ bool Life_Safety_Point_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Life_Safety_Point_Instance_To_Index
(wp_data->object_instance);
Life_Safety_Point_Instance_To_Index(wp_data->
object_instance);
Life_Safety_Point_Out_Of_Service[object_index] =
value.type.Boolean;
}
-1
View File
@@ -69,5 +69,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+6 -6
View File
@@ -436,8 +436,8 @@ int Multistate_Input_Read_Property(
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
object_index =
Multistate_Input_Instance_To_Index
(rpdata->object_instance);
Multistate_Input_Instance_To_Index(rpdata->
object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance,
@@ -458,8 +458,8 @@ int Multistate_Input_Read_Property(
}
} else {
object_index =
Multistate_Input_Instance_To_Index
(rpdata->object_instance);
Multistate_Input_Instance_To_Index(rpdata->
object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance,
@@ -517,8 +517,8 @@ bool Multistate_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
status =
Multistate_Input_Present_Value_Set
(wp_data->object_instance, value.type.Unsigned_Int);
Multistate_Input_Present_Value_Set(wp_data->
object_instance, value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -103,5 +103,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+10 -10
View File
@@ -268,8 +268,8 @@ int Multistate_Output_Read_Property(
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index =
Multistate_Output_Instance_To_Index
(rpdata->object_instance);
Multistate_Output_Instance_To_Index(rpdata->
object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] ==
@@ -294,8 +294,8 @@ int Multistate_Output_Read_Property(
}
} else {
object_index =
Multistate_Output_Instance_To_Index
(rpdata->object_instance);
Multistate_Output_Instance_To_Index(rpdata->
object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Multistate_Output_Level[object_index]
[rpdata->array_index - 1] == MULTISTATE_NULL)
@@ -377,8 +377,8 @@ bool Multistate_Output_Write_Property(
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
level = value.type.Unsigned_Int;
object_index =
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
priority--;
Multistate_Output_Level[object_index][priority] =
(uint8_t) level;
@@ -405,8 +405,8 @@ bool Multistate_Output_Write_Property(
if (status) {
level = MULTISTATE_NULL;
object_index =
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
@@ -432,8 +432,8 @@ bool Multistate_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
object_index =
Multistate_Output_Instance_To_Index
(wp_data->object_instance);
Multistate_Output_Instance_To_Index(wp_data->
object_instance);
Multistate_Output_Out_Of_Service[object_index] =
value.type.Boolean;
}
-1
View File
@@ -71,5 +71,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+6 -6
View File
@@ -438,8 +438,8 @@ int Multistate_Value_Read_Property(
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
object_index =
Multistate_Value_Instance_To_Index
(rpdata->object_instance);
Multistate_Value_Instance_To_Index(rpdata->
object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string,
Multistate_Value_State_Text(rpdata->object_instance,
@@ -460,8 +460,8 @@ int Multistate_Value_Read_Property(
}
} else {
object_index =
Multistate_Value_Instance_To_Index
(rpdata->object_instance);
Multistate_Value_Instance_To_Index(rpdata->
object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string,
Multistate_Value_State_Text(rpdata->object_instance,
@@ -519,8 +519,8 @@ bool Multistate_Value_Write_Property(
&wp_data->error_class, &wp_data->error_code);
if (status) {
status =
Multistate_Value_Present_Value_Set
(wp_data->object_instance, value.type.Unsigned_Int);
Multistate_Value_Present_Value_Set(wp_data->
object_instance, value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
-1
View File
@@ -103,5 +103,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+56 -61
View File
@@ -189,8 +189,8 @@ int Notification_Class_Read_Property(
apdu = rpdata->application_data;
CurrentNotify =
&NC_Info[Notification_Class_Instance_To_Index(rpdata->
object_instance)];
&NC_Info[Notification_Class_Instance_To_Index
(rpdata->object_instance)];
switch (rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER:
@@ -400,8 +400,8 @@ bool Notification_Class_Write_Property(
CurrentNotify =
&NC_Info[Notification_Class_Instance_To_Index(wp_data->
object_instance)];
&NC_Info[Notification_Class_Instance_To_Index
(wp_data->object_instance)];
/* decode the some of the request
*/
@@ -455,9 +455,8 @@ bool Notification_Class_Write_Property(
while (iOffset < wp_data->application_data_len) {
/* Decode Valid Days */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
@@ -480,9 +479,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Decode From Time */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
/* Bad decode, wrong tag or following required parameter missing */
@@ -496,9 +494,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Decode To Time */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) || (value.tag != BACNET_APPLICATION_TAG_TIME)) {
/* Bad decode, wrong tag or following required parameter missing */
@@ -517,9 +514,8 @@ bool Notification_Class_Write_Property(
RECIPIENT_TYPE_DEVICE;
/* Decode Network Number */
len =
bacapp_decode_context_data(&wp_data->
application_data[iOffset],
wp_data->application_data_len, &value,
bacapp_decode_context_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value,
PROP_RECIPIENT_LIST);
if ((len == 0) ||
@@ -530,21 +526,21 @@ bool Notification_Class_Write_Property(
return false;
}
/* store value */
TmpNotify.Recipient_List[idx].Recipient._.
DeviceIdentifier = value.type.Object_Id.instance;
TmpNotify.Recipient_List[idx].Recipient.
_.DeviceIdentifier = value.type.Object_Id.instance;
iOffset += len;
}
/* opening tag [1] - Recipient */
else if (decode_is_opening_tag_number(&wp_data->
application_data[iOffset], 1)) {
else if (decode_is_opening_tag_number
(&wp_data->application_data[iOffset], 1)) {
iOffset++;
TmpNotify.Recipient_List[idx].Recipient.RecipientType =
RECIPIENT_TYPE_ADDRESS;
/* Decode Network Number */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset],
bacapp_decode_application_data
(&wp_data->application_data[iOffset],
wp_data->application_data_len, &value);
if ((len == 0) ||
@@ -561,8 +557,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Decode Address */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset],
bacapp_decode_application_data
(&wp_data->application_data[iOffset],
wp_data->application_data_len, &value);
if ((len == 0) ||
@@ -573,16 +569,16 @@ bool Notification_Class_Write_Property(
return false;
}
/* store value */
if (TmpNotify.Recipient_List[idx].Recipient._.Address.
net == 0) {
memcpy(TmpNotify.Recipient_List[idx].Recipient._.
Address.mac, value.type.Octet_String.value,
if (TmpNotify.Recipient_List[idx].Recipient._.
Address.net == 0) {
memcpy(TmpNotify.Recipient_List[idx].Recipient.
_.Address.mac, value.type.Octet_String.value,
value.type.Octet_String.length);
TmpNotify.Recipient_List[idx].Recipient._.Address.
mac_len = value.type.Octet_String.length;
TmpNotify.Recipient_List[idx].Recipient._.
Address.mac_len = value.type.Octet_String.length;
} else {
memcpy(TmpNotify.Recipient_List[idx].Recipient._.
Address.adr, value.type.Octet_String.value,
memcpy(TmpNotify.Recipient_List[idx].Recipient.
_.Address.adr, value.type.Octet_String.value,
value.type.Octet_String.length);
TmpNotify.Recipient_List[idx].Recipient._.Address.len =
value.type.Octet_String.length;
@@ -590,8 +586,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* closing tag [1] - Recipient */
if (decode_is_closing_tag_number(&wp_data->
application_data[iOffset], 1))
if (decode_is_closing_tag_number(&wp_data->application_data
[iOffset], 1))
iOffset++;
else {
/* Bad decode, wrong tag or following required parameter missing */
@@ -608,9 +604,8 @@ bool Notification_Class_Write_Property(
/* Process Identifier */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
@@ -626,9 +621,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Issue Confirmed Notifications */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BOOLEAN)) {
@@ -644,9 +638,8 @@ bool Notification_Class_Write_Property(
iOffset += len;
/* Transitions */
len =
bacapp_decode_application_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value);
bacapp_decode_application_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value);
if ((len == 0) ||
(value.tag != BACNET_APPLICATION_TAG_BIT_STRING)) {
@@ -687,16 +680,16 @@ bool Notification_Class_Write_Property(
CurrentNotify->Recipient_List[idx] =
TmpNotify.Recipient_List[idx];
if (CurrentNotify->Recipient_List[idx].Recipient.
RecipientType == RECIPIENT_TYPE_DEVICE) {
if (CurrentNotify->Recipient_List[idx].
Recipient.RecipientType == RECIPIENT_TYPE_DEVICE) {
/* copy Device_ID */
DeviceID =
CurrentNotify->Recipient_List[idx].Recipient._.
DeviceIdentifier;
CurrentNotify->Recipient_List[idx].Recipient.
_.DeviceIdentifier;
address_bind_request(DeviceID, &max_apdu, &src);
} else if (CurrentNotify->Recipient_List[idx].Recipient.
RecipientType == RECIPIENT_TYPE_ADDRESS) {
} else if (CurrentNotify->Recipient_List[idx].
Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
/* copy Address */
/* src = CurrentNotify->Recipient_List[idx].Recipient._.Address; */
/* address_bind_request(BACNET_MAX_INSTANCE, &max_apdu, &src); */
@@ -816,17 +809,19 @@ void Notification_Class_common_reporting_function(
/* Priority and AckRequired */
switch (event_data->toState) {
case EVENT_STATE_NORMAL:
event_data->priority = CurrentNotify->Priority[TRANSITION_TO_NORMAL];
event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_NORMAL];
event_data->ackRequired =
(CurrentNotify->
Ack_Required & TRANSITION_TO_NORMAL_MASKED) ? true : false;
(CurrentNotify->Ack_Required & TRANSITION_TO_NORMAL_MASKED) ?
true : false;
break;
case EVENT_STATE_FAULT:
event_data->priority = CurrentNotify->Priority[TRANSITION_TO_FAULT];
event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_FAULT];
event_data->ackRequired =
(CurrentNotify->
Ack_Required & TRANSITION_TO_FAULT_MASKED) ? true : false;
(CurrentNotify->Ack_Required & TRANSITION_TO_FAULT_MASKED) ?
true : false;
break;
case EVENT_STATE_OFFNORMAL:
@@ -835,8 +830,8 @@ void Notification_Class_common_reporting_function(
event_data->priority =
CurrentNotify->Priority[TRANSITION_TO_OFFNORMAL];
event_data->ackRequired =
(CurrentNotify->
Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED) ? true : false;
(CurrentNotify->Ack_Required & TRANSITION_TO_OFFNORMAL_MASKED)
? true : false;
break;
default: /* shouldn't happen */
@@ -911,13 +906,13 @@ void Notification_Class_find_recipient(
RECIPIENT_TYPE_DEVICE) {
/* Device ID */
DeviceID =
CurrentNotify->Recipient_List[idx].Recipient._.
DeviceIdentifier;
CurrentNotify->Recipient_List[idx].Recipient.
_.DeviceIdentifier;
/* Send who_ is request only when address of device is unknown. */
if (!address_bind_request(DeviceID, &max_apdu, &src))
Send_WhoIs(DeviceID, DeviceID);
} else if (CurrentNotify->Recipient_List[idx].Recipient.
RecipientType == RECIPIENT_TYPE_ADDRESS) {
} else if (CurrentNotify->Recipient_List[idx].
Recipient.RecipientType == RECIPIENT_TYPE_ADDRESS) {
}
}
-1
View File
@@ -138,5 +138,4 @@ BACnetRecipient ::= CHOICE {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* NC_H */
+7 -7
View File
@@ -736,9 +736,9 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) {
iOffset += len;
len =
bacapp_decode_context_data(&wp_data->application_data
[iOffset], wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY);
bacapp_decode_context_data(&wp_data->
application_data[iOffset], wp_data->application_data_len,
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || ((value.context_tag != 2) &&
(value.context_tag != 3))) {
/* Bad decode or wrong tag */
@@ -755,8 +755,8 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) {
iOffset += len;
len =
bacapp_decode_context_data
(&wp_data->application_data[iOffset],
bacapp_decode_context_data(&wp_data->
application_data[iOffset],
wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || (value.context_tag != 3)) {
@@ -1098,8 +1098,8 @@ int rr_trend_log_encode(
pRequest->ItemCount = 0; /* Start out with nothing */
/* Bail out now if nowt - should never happen for a Trend Log but ... */
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->
object_instance)].ulRecordCount == 0)
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
ulRecordCount == 0)
return (0);
if ((pRequest->RequestType == RR_BY_POSITION) ||
-1
View File
@@ -197,5 +197,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
+194 -214
View File
@@ -27,18 +27,24 @@ static bool isAtomicReadFileHandlerRegistered = false;
#define MAX_ERROR_STRING 128
#define NO_ERROR "No Error"
static char Last_Error[MAX_ERROR_STRING] = NO_ERROR;
static void LogError(const char *msg)
static void LogError(
const char *msg)
{
strcpy(Last_Error, msg);
Error_Detected = true;
}
void BacnetGetError(SV *errorMsg)
void BacnetGetError(
SV * errorMsg)
{
sv_setpv(errorMsg, Last_Error);
strcpy(Last_Error, NO_ERROR);
Error_Detected = false;
}
static void __LogAnswer(const char *msg, unsigned append)
static void __LogAnswer(
const char *msg,
unsigned append)
{
dSP;
ENTER;
@@ -63,10 +69,10 @@ static void MyAbortHandler(
{
(void) server;
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Abort: %s", bactext_abort_reason_name((int) abort_reason));
sprintf(msg, "BACnet Abort: %s",
bactext_abort_reason_name((int) abort_reason));
LogError(msg);
}
}
@@ -77,10 +83,10 @@ static void MyRejectHandler(
uint8_t reject_reason)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Reject: %s", bactext_reject_reason_name((int) reject_reason));
sprintf(msg, "BACnet Reject: %s",
bactext_reject_reason_name((int) reject_reason));
LogError(msg);
}
}
@@ -92,10 +98,11 @@ static void My_Error_Handler(
BACNET_ERROR_CODE error_code)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
char msg[MAX_ERROR_STRING];
sprintf(msg, "BACnet Error: %s: %s", bactext_error_class_name((int) error_class), bactext_error_code_name((int) error_code));
sprintf(msg, "BACnet Error: %s: %s",
bactext_error_class_name((int) error_class),
bactext_error_code_name((int) error_code));
LogError(msg);
}
}
@@ -108,7 +115,8 @@ static void My_Error_Handler(
// Decode the ReadProperty Ack and pass to perl
/****************************************/
#define MAX_ACK_STRING 512
void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
void rp_ack_extract_data(
BACNET_READ_PROPERTY_DATA * data)
{
char ackString[MAX_ACK_STRING] = "";
char *pAckString = &ackString[0];
@@ -120,8 +128,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
bool first_value = true;
bool print_brace = false;
if (data)
{
if (data) {
application_data = data->application_data;
application_data_len = data->application_data_len;
/* FIXME: what if application_data_len is bigger than 255? */
@@ -130,8 +137,7 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
len =
bacapp_decode_application_data(application_data,
(uint8_t) application_data_len, &value);
if (first_value && (len < application_data_len))
{
if (first_value && (len < application_data_len)) {
first_value = false;
strncat(pAckString, "{", 1);
pAckString += 1;
@@ -142,7 +148,8 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
object_value.object_property = data->object_property;
object_value.array_index = data->array_index;
object_value.value = &value;
bacapp_snprintf_value(pAckString, MAX_ACK_STRING - (pAckString - ackString), &object_value);
bacapp_snprintf_value(pAckString,
MAX_ACK_STRING - (pAckString - ackString), &object_value);
if (len > 0) {
if (len < application_data_len) {
application_data += len;
@@ -157,12 +164,10 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
break;
}
}
if (print_brace)
{
if (print_brace) {
strncat(pAckString, "}", 1);
pAckString += 1;
}
// Now let's call a Perl function to display the data
__LogAnswer(ackString, 0);
}
@@ -171,7 +176,8 @@ void rp_ack_extract_data(BACNET_READ_PROPERTY_DATA * data)
/*****************************************/
// Decode the ReadPropertyMultiple Ack and pass to perl
/****************************************/
void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
void rpm_ack_extract_data(
BACNET_READ_ACCESS_DATA * rpm_data)
{
BACNET_OBJECT_PROPERTY_VALUE object_value; /* for bacapp printing */
BACNET_PROPERTY_REFERENCE *listOfProperties;
@@ -195,10 +201,14 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
object_value.object_type = rpm_data->object_type;
object_value.object_instance = rpm_data->object_instance;
while (value) {
object_value.object_property = listOfProperties->propertyIdentifier;
object_value.array_index = listOfProperties->propertyArrayIndex;
object_value.object_property =
listOfProperties->propertyIdentifier;
object_value.array_index =
listOfProperties->propertyArrayIndex;
object_value.value = value;
bacapp_snprintf_value(pAckString, MAX_ACK_STRING - (pAckString - ackString), &object_value);
bacapp_snprintf_value(pAckString,
MAX_ACK_STRING - (pAckString - ackString),
&object_value);
if (value->next) {
strncat(pAckString, ",", 1);
pAckString++;
@@ -213,10 +223,10 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA * rpm_data)
} else {
/* AccessError */
sprintf(ackString, "BACnet Error: %s: %s",
bactext_error_class_name((int) listOfProperties->
error.error_class),
bactext_error_code_name((int) listOfProperties->
error.error_code));
bactext_error_class_name((int) listOfProperties->error.
error_class),
bactext_error_code_name((int) listOfProperties->error.
error_code));
LogError(ackString);
}
listOfProperties = listOfProperties->next;
@@ -241,31 +251,30 @@ static void AtomicReadFileAckHandler(
int len = 0;
BACNET_ATOMIC_READ_FILE_DATA data;
if (address_match(&Target_Address, src) && (service_data->invoke_id == Request_Invoke_ID))
{
len = arf_ack_decode_service_request(service_request, service_len, &data);
if (len > 0)
{
if (address_match(&Target_Address, src) &&
(service_data->invoke_id == Request_Invoke_ID)) {
len =
arf_ack_decode_service_request(service_request, service_len,
&data);
if (len > 0) {
/* validate the parameters before storing data */
if ((data.access == FILE_STREAM_ACCESS) && (service_data->invoke_id == Request_Invoke_ID))
{
if ((data.access == FILE_STREAM_ACCESS) &&
(service_data->invoke_id == Request_Invoke_ID)) {
char msg[32];
uint8_t *pFileData;
int i;
sprintf(msg, "EOF=%d,start=%d,", data.endOfFile, data.type.stream.fileStartPosition);
sprintf(msg, "EOF=%d,start=%d,", data.endOfFile,
data.type.stream.fileStartPosition);
__LogAnswer(msg, 0);
pFileData = octetstring_value(&data.fileData);
for (i=0; i<octetstring_length(&data.fileData); i++)
{
for (i = 0; i < octetstring_length(&data.fileData); i++) {
sprintf(msg, "%02x ", *pFileData);
__LogAnswer(msg, 1);
pFileData++;
}
}
else
{
} else {
LogError("Bad stream access reported");
}
}
@@ -295,9 +304,9 @@ static void My_Read_Property_Ack_Handler(
if (address_match(&Target_Address, src) &&
(service_data->invoke_id == Request_Invoke_ID)) {
len = rp_ack_decode_service_request(service_request, service_len, &data);
if (len > 0)
{
len =
rp_ack_decode_service_request(service_request, service_len, &data);
if (len > 0) {
rp_ack_extract_data(&data);
}
}
@@ -383,14 +392,14 @@ void My_Write_Property_SimpleAck_Handler(
uint8_t invoke_id)
{
if (address_match(&Target_Address, src) &&
(invoke_id == Request_Invoke_ID))
{
(invoke_id == Request_Invoke_ID)) {
__LogAnswer("WriteProperty Acknowledged!", 0);
}
}
static void Init_Service_Handlers()
static void Init_Service_Handlers(
)
{
Device_Init(NULL);
@@ -402,23 +411,26 @@ static void Init_Service_Handlers()
/* set the handler for all the services we don't implement
It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler (handler_unrecognized_service);
apdu_set_unrecognized_service_handler_handler
(handler_unrecognized_service);
/* 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_READ_PROPERTY,
handler_read_property);
/* handle generic errors coming back */
apdu_set_abort_handler(MyAbortHandler);
apdu_set_reject_handler(MyRejectHandler);
}
typedef enum
{
typedef enum {
waitAnswer,
waitBind,
} waitAction;
static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
static void Wait_For_Answer_Or_Timeout(
unsigned timeout_ms,
waitAction action)
{
// Wait for timeout, failure, or success
time_t last_seconds = time(NULL);
@@ -428,59 +440,46 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
BACNET_ADDRESS src = { 0 }; /* address where message came from */
uint8_t Rx_Buf[MAX_MPDU] = { 0 };
while (true)
{
while (true) {
time_t current_seconds = time(NULL);
// If error was detected then bail out
if (Error_Detected)
{
if (Error_Detected) {
LogError("Some other error occurred");
break;
}
if (elapsed_seconds > timeout_seconds)
{
if (elapsed_seconds > timeout_seconds) {
LogError("APDU Timeout");
break;
}
/* Process PDU if one comes in */
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout_ms);
if (pdu_len)
{
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
}
/* at least one second has passed */
if (current_seconds != last_seconds)
{
if (current_seconds != last_seconds) {
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
}
if (action == waitAnswer)
{
if (action == waitAnswer) {
// Response was received. Exit.
if (tsm_invoke_id_free(Request_Invoke_ID))
{
if (tsm_invoke_id_free(Request_Invoke_ID)) {
break;
}
else if (tsm_invoke_id_failed(Request_Invoke_ID))
{
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
LogError("TSM Timeout!");
tsm_free_invoke_id(Request_Invoke_ID);
break;
}
}
else if (action == waitBind)
{
if (address_bind_request(Target_Device_Object_Instance, &Target_Max_APDU, &Target_Address))
{
} else if (action == waitBind) {
if (address_bind_request(Target_Device_Object_Instance,
&Target_Max_APDU, &Target_Address)) {
break;
}
}
else
{
} else {
LogError("Invalid waitAction requested");
break;
}
@@ -498,7 +497,8 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
/****************************************************/
// This is the most fundamental setup needed to start communication
/****************************************************/
void BacnetPrepareComm()
void BacnetPrepareComm(
)
{
/* setup my info */
Device_Set_Object_Instance_Number(BACNET_MAX_INSTANCE);
@@ -511,7 +511,8 @@ void BacnetPrepareComm()
// Try to bind to a device. If successful, return zero. If failure, return
// non-zero and log the error details
/****************************************************/
int BacnetBindToDevice(int deviceInstanceNumber)
int BacnetBindToDevice(
int deviceInstanceNumber)
{
int isFailure = 0;
@@ -520,14 +521,14 @@ int BacnetBindToDevice(int deviceInstanceNumber)
Target_Device_Object_Instance = deviceInstanceNumber;
/* try to bind with the device */
if (! address_bind_request(deviceInstanceNumber, &Target_Max_APDU, &Target_Address))
{
Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance);
if (!address_bind_request(deviceInstanceNumber, &Target_Max_APDU,
&Target_Address)) {
Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
// Wait for timeout, failure, or success
Wait_For_Answer_Or_Timeout(100, waitBind);
}
// Clean up after ourselves
isFailure = Error_Detected;
Error_Detected = false;
@@ -537,22 +538,29 @@ int BacnetBindToDevice(int deviceInstanceNumber)
/****************************************************/
// This is the interface to ReadProperty
/****************************************************/
int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInstanceNumber, int objectProperty, int objectIndex)
{
if (!isReadPropertyHandlerRegistered)
int BacnetReadProperty(
int deviceInstanceNumber,
int objectType,
int objectInstanceNumber,
int objectProperty,
int objectIndex)
{
if (!isReadPropertyHandlerRegistered) {
/* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY, My_Read_Property_Ack_Handler);
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY,
My_Read_Property_Ack_Handler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY,
My_Error_Handler);
// indicate that handlers are now registered
isReadPropertyHandlerRegistered = true;
}
// Send the message out
Request_Invoke_ID = Send_Read_Property_Request(deviceInstanceNumber, objectType, objectInstanceNumber, objectProperty, objectIndex);
Request_Invoke_ID =
Send_Read_Property_Request(deviceInstanceNumber, objectType,
objectInstanceNumber, objectProperty, objectIndex);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
int isFailure = Error_Detected;
@@ -563,34 +571,31 @@ int BacnetReadProperty(int deviceInstanceNumber, int objectType, int objectInsta
/************************************************/
// This is the interface to ReadPropertyMultiple
/************************************************/
int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
int BacnetReadPropertyMultiple(
int deviceInstanceNumber,
...)
{
// Get the variable argument list from the stack
Inline_Stack_Vars;
int rpmIndex = 1;
BACNET_READ_ACCESS_DATA *rpm_object = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
BACNET_READ_ACCESS_DATA *rpm_object =
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
BACNET_READ_ACCESS_DATA *Read_Access_Data = rpm_object;
BACNET_PROPERTY_REFERENCE *rpm_property;
uint8_t buffer[MAX_PDU] = { 0 };
while (rpmIndex < Inline_Stack_Items)
{
while (rpmIndex < Inline_Stack_Items) {
SV *pSV = Inline_Stack_Item(rpmIndex++);
// Make sure the argument is an Array Reference
if (SvTYPE(SvRV(pSV)) != SVt_PVAV)
{
if (SvTYPE(SvRV(pSV)) != SVt_PVAV) {
LogError("Argument is not an Array reference");
break;
}
// Make sure we can access the memory
if (rpm_object)
{
if (rpm_object) {
rpm_object->listOfProperties = NULL;
}
else
{
} else {
LogError("Memory Allocation Issue");
break;
}
@@ -600,107 +605,84 @@ int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
// The 0th argument is the object type
ppSV = av_fetch(pAV, 0, 0);
if (ppSV)
{
if (ppSV) {
rpm_object->object_type = SvIV(*ppSV);
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// The 1st argument is the object instance
ppSV = av_fetch(pAV, 1, 0);
if (ppSV)
{
if (ppSV) {
rpm_object->object_instance = SvIV(*ppSV);
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// The 2nd argument is the property type
ppSV = av_fetch(pAV, 2, 0);
if (ppSV)
{
if (ppSV) {
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
rpm_object->listOfProperties = rpm_property;
if (rpm_property)
{
if (rpm_property) {
rpm_property->propertyIdentifier = SvIV(*ppSV);
}
else
{
} else {
LogError("Memory allocation error");
break;
}
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// The 3rd argument is the property index
ppSV = av_fetch(pAV, 3, 0);
if (ppSV)
{
if (ppSV) {
rpm_property->propertyArrayIndex = SvIV(*ppSV);
}
else
{
} else {
LogError("Problem parsing the Array of arguments");
break;
}
// Advance to the next RPM index
if (rpmIndex < Inline_Stack_Items)
{
if (rpmIndex < Inline_Stack_Items) {
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
rpm_object = rpm_object->next;
}
else
{
} else {
rpm_object->next = NULL;
}
}
if (!isReadPropertyMultipleHandlerRegistered)
{
if (!isReadPropertyMultipleHandlerRegistered) {
/* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
My_Read_Property_Multiple_Ack_Handler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
My_Error_Handler);
// indicate that handlers are now registered
isReadPropertyMultipleHandlerRegistered = true;
}
// Send the message out
if (!Error_Detected)
{
Request_Invoke_ID = Send_Read_Property_Multiple_Request(
&buffer[0], sizeof(buffer),
if (!Error_Detected) {
Request_Invoke_ID =
Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer),
deviceInstanceNumber, Read_Access_Data);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
}
// Clean up allocated memory
BACNET_READ_ACCESS_DATA *old_rpm_object;
BACNET_PROPERTY_REFERENCE *old_rpm_property;
rpm_object = Read_Access_Data;
old_rpm_object = rpm_object;
while (rpm_object)
{
while (rpm_object) {
rpm_property = rpm_object->listOfProperties;
while (rpm_property)
{
while (rpm_property) {
old_rpm_property = rpm_property;
rpm_property = rpm_property->next;
free(old_rpm_property);
@@ -719,7 +701,8 @@ int BacnetReadPropertyMultiple(int deviceInstanceNumber, ... )
/****************************************************/
// This is the interface to WriteProperty
/****************************************************/
int BacnetWriteProperty(int deviceInstanceNumber,
int BacnetWriteProperty(
int deviceInstanceNumber,
int objectType,
int objectInstanceNumber,
int objectProperty,
@@ -731,51 +714,46 @@ int BacnetWriteProperty(int deviceInstanceNumber,
char msg[MAX_ERROR_STRING];
int isFailure = 1;
if (!isWritePropertyHandlerRegistered)
{
if (!isWritePropertyHandlerRegistered) {
/* handle the ack coming back */
apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, My_Write_Property_SimpleAck_Handler);
apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
My_Write_Property_SimpleAck_Handler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
My_Error_Handler);
// indicate that handlers are now registered
isWritePropertyHandlerRegistered = true;
}
if (objectIndex == -1)
{
if (objectIndex == -1) {
objectIndex = BACNET_ARRAY_ALL;
}
// Loop for eary exit;
do
{
do {
// Handle the tag/value pair
uint8_t context_tag = 0;
BACNET_APPLICATION_TAG property_tag;
BACNET_APPLICATION_DATA_VALUE propertyValue;
if (toupper(tag[0]) == 'C')
{
if (toupper(tag[0]) == 'C') {
context_tag = strtol(&tag[1], NULL, 0);
propertyValue.context_tag = context_tag;
propertyValue.context_specific = true;
}
else
{
} else {
propertyValue.context_specific = false;
}
property_tag = strtol(tag, NULL, 0);
if (property_tag >= MAX_BACNET_APPLICATION_TAG)
{
sprintf(msg, "Error: tag=%u - it must be less than %u", property_tag, MAX_BACNET_APPLICATION_TAG);
if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
sprintf(msg, "Error: tag=%u - it must be less than %u",
property_tag, MAX_BACNET_APPLICATION_TAG);
LogError(msg);
break;
}
if (!bacapp_parse_application_data(property_tag, value, &propertyValue))
{
if (!bacapp_parse_application_data(property_tag, value,
&propertyValue)) {
sprintf(msg, "Error: unable to parse the tag value");
LogError(msg);
break;
@@ -783,10 +761,10 @@ int BacnetWriteProperty(int deviceInstanceNumber,
propertyValue.next = NULL;
// Send out the message
Request_Invoke_ID = Send_Write_Property_Request(
deviceInstanceNumber,
objectType, objectInstanceNumber,
objectProperty, &propertyValue, objectPriority, objectIndex);
Request_Invoke_ID =
Send_Write_Property_Request(deviceInstanceNumber, objectType,
objectInstanceNumber, objectProperty, &propertyValue,
objectPriority, objectIndex);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
// If we get here, then there were no explicit failures. However, there
@@ -800,7 +778,8 @@ int BacnetWriteProperty(int deviceInstanceNumber,
}
int BacnetAtomicWriteFile (int deviceInstanceNumber,
int BacnetAtomicWriteFile(
int deviceInstanceNumber,
int fileInstanceNumber,
int blockStartAddr,
int blockNumBytes,
@@ -811,31 +790,24 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
uint8_t byteValue;
unsigned char nibbleValue;
if (!isAtomicWriteFileHandlerRegistered)
{
if (!isAtomicWriteFileHandlerRegistered) {
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE,
My_Error_Handler);
// indicate that handlers are now registered
isAtomicWriteFileHandlerRegistered = true;
}
for (i=0; i<blockNumBytes; i++)
{
for (i = 0; i < blockNumBytes; i++) {
byteValue = 0;
for (nibble=0; nibble<2; nibble++)
{
for (nibble = 0; nibble < 2; nibble++) {
nibbleValue = toupper(nibbleBuffer[i * 2 + nibble]);
if ( (nibbleValue >= '0') && (nibbleValue <= '9') )
{
if ((nibbleValue >= '0') && (nibbleValue <= '9')) {
byteValue += (nibbleValue - '0') << (4 * (1 - nibble));
}
else if ( (nibbleValue >= 'A') && (nibbleValue <= 'F') )
{
} else if ((nibbleValue >= 'A') && (nibbleValue <= 'F')) {
byteValue += (nibbleValue - 'A' + 10) << (4 * (1 - nibble));
}
else
{
} else {
LogError("Bad data in buffer.");
}
}
@@ -844,13 +816,10 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
octetstring_truncate(&fileData, blockNumBytes);
// Send out the message and wait for answer
if (!Error_Detected)
{
Request_Invoke_ID = Send_Atomic_Write_File_Stream(
deviceInstanceNumber,
fileInstanceNumber,
blockStartAddr,
&fileData);
if (!Error_Detected) {
Request_Invoke_ID =
Send_Atomic_Write_File_Stream(deviceInstanceNumber,
fileInstanceNumber, blockStartAddr, &fileData);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
}
@@ -859,7 +828,8 @@ int BacnetAtomicWriteFile (int deviceInstanceNumber,
return isFailure;
}
int BacnetGetMaxApdu()
int BacnetGetMaxApdu(
)
{
unsigned requestedOctetCount = 0;
uint16_t my_max_apdu = 0;
@@ -887,7 +857,8 @@ int BacnetGetMaxApdu()
return requestedOctetCount;
}
int BacnetTimeSync(int deviceInstanceNumber,
int BacnetTimeSync(
int deviceInstanceNumber,
int year,
int month,
int day,
@@ -896,7 +867,6 @@ int BacnetTimeSync(int deviceInstanceNumber,
int second,
int isUTC,
int UTCOffset)
{
BACNET_DATE bdate;
BACNET_TIME btime;
@@ -934,10 +904,8 @@ int BacnetTimeSync(int deviceInstanceNumber,
uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 };
// Loop for eary exit
do
{
if (!dcc_communication_enabled())
{
do {
if (!dcc_communication_enabled()) {
LogError("DCC communicaiton is not enabled");
break;
}
@@ -945,18 +913,25 @@ int BacnetTimeSync(int deviceInstanceNumber,
/* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
datalink_get_my_address(&my_address);
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &Target_Address, &my_address, &npdu_data);
pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &Target_Address,
&my_address, &npdu_data);
/* encode the APDU portion of the packet */
len = timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &bdate, &btime);
len =
timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &bdate,
&btime);
pdu_len += len;
/* send it out the datalink */
bytes_sent = datalink_send_pdu(&Target_Address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0)
{
bytes_sent =
datalink_send_pdu(&Target_Address, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0) {
char errorMsg[64];
sprintf(errorMsg, "Failed to Send Time-Synchronization Request (%s)!", strerror(errno));
sprintf(errorMsg,
"Failed to Send Time-Synchronization Request (%s)!",
strerror(errno));
LogError(errorMsg);
break;
}
@@ -972,26 +947,31 @@ int BacnetTimeSync(int deviceInstanceNumber,
/****************************************************/
// This is the interface to AtomicReadFile
/****************************************************/
int BacnetAtomicReadFile(int deviceInstanceNumber, int fileInstanceNumber, int startOffset, int numBytes)
{
if (!isAtomicReadFileHandlerRegistered)
int BacnetAtomicReadFile(
int deviceInstanceNumber,
int fileInstanceNumber,
int startOffset,
int numBytes)
{
if (!isAtomicReadFileHandlerRegistered) {
/* handle the data coming back from confirmed requests */
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE, AtomicReadFileAckHandler);
apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
AtomicReadFileAckHandler);
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE, My_Error_Handler);
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
My_Error_Handler);
// indicate that handlers are now registered
isAtomicReadFileHandlerRegistered = true;
}
// Send the message out
Request_Invoke_ID = Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber, startOffset, numBytes);
Request_Invoke_ID =
Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber,
startOffset, numBytes);
Wait_For_Answer_Or_Timeout(100, waitAnswer);
int isFailure = Error_Detected;
Error_Detected = 0;
return isFailure;
}
+7 -7
View File
@@ -298,8 +298,7 @@ int main(
"%s 123 1 99 85,87[0],87\r\n"
"If you want read the PRESENT_VALUE property in objects\r\n"
"Analog Input 77 and Analog Input 78 in Device 123\r\n"
"use the following command:\r\n"
"%s 123 0 77 85 0 78 85\r\n"
"use the following command:\r\n" "%s 123 0 77 85 0 78 85\r\n"
"If you want read the ALL property in\r\n"
"Device object 123, you would use the following command:\r\n"
"%s 123 8 123 8\r\n"
@@ -308,8 +307,8 @@ int main(
"%s 123 8 123 80\r\n"
"If you want read the REQUIRED property in\r\n"
"Device object 123, you would use the following command:\r\n"
"%s 123 8 123 105\r\n",
filename, filename, filename, filename, filename);
"%s 123 8 123 105\r\n", filename, filename, filename, filename,
filename);
}
return 0;
}
@@ -356,13 +355,14 @@ int main(
property_token = strtok(argv[tag_value_arg], ",");
/* add all the properties and optional index to our list */
while (rpm_property) {
scan_count = sscanf(property_token, "%u[%u]",
&property_id,
scan_count =
sscanf(property_token, "%u[%u]", &property_id,
&property_array_index);
if (scan_count > 0) {
rpm_property->propertyIdentifier = property_id;
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
fprintf(stderr, "property=%u - it must be less than %u\r\n",
fprintf(stderr,
"property=%u - it must be less than %u\r\n",
rpm_property->propertyIdentifier,
MAX_BACNET_PROPERTY_ID + 1);
return 1;
+17 -30
View File
@@ -187,40 +187,30 @@ int main(
if (print_usage_terse) {
filename = filename_remove_path(argv[0]);
printf("Usage: %s device-id object-type object-instance "
"process-id <[un]confirmed lifetime|cancel>\r\n",
filename);
"process-id <[un]confirmed lifetime|cancel>\r\n", filename);
if (!print_usage_verbose) {
return 0;
}
}
if (print_usage_verbose) {
printf("\r\n"
"device-id:\r\n"
"The subscriber BACnet Device Object Instance number.\r\n"
"\r\n"
printf("\r\n" "device-id:\r\n"
"The subscriber BACnet Device Object Instance number.\r\n" "\r\n"
"object-type:\r\n"
"The monitored object type is the integer value of the\r\n"
"enumeration BACNET_OBJECT_TYPE in bacenum.h. For example,\r\n"
"if you were monitoring Analog Output 2, the object-type\r\n"
"would be 1.\r\n"
"\r\n"
"object-instance:\r\n"
"The monitored object instance number.\r\n"
"\r\n"
"would be 1.\r\n" "\r\n" "object-instance:\r\n"
"The monitored object instance number.\r\n" "\r\n"
"process-id:\r\n"
"Process Identifier for this COV subscription.\r\n"
"\r\n"
"Process Identifier for this COV subscription.\r\n" "\r\n"
"confirmed:\r\n"
"Optional flag to subscribe using Confirmed notifications.\r\n"
"Use the word \'confirmed\' or \'unconfirmed\'.\r\n"
"\r\n"
"Use the word \'confirmed\' or \'unconfirmed\'.\r\n" "\r\n"
"lifetime:\r\n"
"Optional subscription lifetime is conveyed in seconds.\r\n"
"\r\n"
"Optional subscription lifetime is conveyed in seconds.\r\n" "\r\n"
"cancel:\r\n"
"Use the word \'cancel\' instead of confirm and lifetime.\r\n"
"This shall indicate a cancellation request.\r\n"
"\r\n"
"This shall indicate a cancellation request.\r\n" "\r\n"
"Example:\r\n"
"If you want subscribe to Device 123 Analog Input 9 object\r\n"
"using confirmed COV notifications for 5 minutes,\r\n"
@@ -230,8 +220,7 @@ int main(
"notifications, send the following command:\r\n"
"%s 123 0 9 1 unconfirmed 600\r\n"
"To cancel the same COV subscription request,\r\n"
"send the following command:\r\n"
"%s 123 0 9 1 cancel\r\n",
"send the following command:\r\n" "%s 123 0 9 1 cancel\r\n",
filename, filename, filename);
return 0;
}
@@ -247,11 +236,11 @@ int main(
cov_data = COV_Subscribe_Data;
argi = 2;
while (cov_data) {
cov_data->monitoredObjectIdentifier.type =
strtol(argv[argi], NULL, 0);
cov_data->monitoredObjectIdentifier.type = strtol(argv[argi], NULL, 0);
if (cov_data->monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
cov_data->monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE);
cov_data->monitoredObjectIdentifier.type,
MAX_BACNET_OBJECT_TYPE);
return 1;
}
argi++;
@@ -264,8 +253,7 @@ int main(
return 1;
}
argi++;
cov_data->subscriberProcessIdentifier =
strtol(argv[argi], NULL, 0);
cov_data->subscriberProcessIdentifier = strtol(argv[argi], NULL, 0);
argi++;
if (strcmp(argv[argi], "cancel") == 0) {
cov_data->cancellationRequest = true;
@@ -277,8 +265,7 @@ int main(
} else if (strcmp(argv[argi], "unconfirmed") == 0) {
cov_data->issueConfirmedNotifications = false;
} else {
fprintf(stderr, "unknown option: %s\r\n",
argv[argi]);
fprintf(stderr, "unknown option: %s\r\n", argv[argi]);
return 1;
}
argi++;
@@ -342,8 +329,8 @@ int main(
if (Request_Invoke_ID == 0) {
Target_Device_Process_Identifier =
cov_data->subscriberProcessIdentifier;
Request_Invoke_ID = Send_COV_Subscribe(
Target_Device_Object_Instance,
Request_Invoke_ID =
Send_COV_Subscribe(Target_Device_Object_Instance,
cov_data);
if (!cov_data->cancellationRequest &&
(timeout_seconds < cov_data->lifetime)) {
+9 -17
View File
@@ -179,34 +179,26 @@ int main(
"to try and bind with the device using Who-Is and\r\n"
"I-Am services. For example, if you were transferring to\r\n"
"Device Object 123, the device-instance would be 123.\r\n"
"\r\n"
"vendor_id:\r\n"
"\r\n" "vendor_id:\r\n"
"the unique vendor identification code for the type of\r\n"
"vendor proprietary service to be performed.\r\n"
"\r\n"
"vendor proprietary service to be performed.\r\n" "\r\n"
"service-number (Unsigned32):\r\n"
"the desired proprietary service to be performed.\r\n"
"\r\n"
"tag:\r\n"
"Tag is the integer value of the enumeration \r\n"
"the desired proprietary service to be performed.\r\n" "\r\n"
"tag:\r\n" "Tag is the integer value of the enumeration \r\n"
"BACNET_APPLICATION_TAG in bacenum.h.\r\n"
"It is the data type of the value that you are sending.\r\n"
"For example, if you were transfering a REAL value, you would \r\n"
"use a tag of 4.\r\n"
"Context tags are created using two tags in a row.\r\n"
"The context tag is preceded by a C. Ctag tag.\r\n"
"C2 4 creates a context 2 tagged REAL.\r\n"
"\r\n"
"value:\r\n"
"C2 4 creates a context 2 tagged REAL.\r\n" "\r\n" "value:\r\n"
"The value is an ASCII representation of some type of data\r\n"
"that you are transfering.\r\n"
"It is encoded using the tag information provided.\r\n"
"For example, if you were transferring a REAL value of 100.0,\r\n"
"you would use 100.0 as the value.\r\n"
"If you were transferring an object identifier for Device 123,\r\n"
"you would use 8:123 as the value.\r\n"
"\r\n"
"Example:\r\n"
"you would use 8:123 as the value.\r\n" "\r\n" "Example:\r\n"
"If you want to transfer a REAL value of 1.1 to service 23 of \r\n"
"vendor 260 in Device 99, you could send the following command:\r\n"
"%s 99 260 23 4 1.1\r\n", filename);
@@ -310,14 +302,14 @@ int main(
}
if (!sent_message) {
if (found) {
len = bacapp_encode_data(&Service_Parameters[0],
len =
bacapp_encode_data(&Service_Parameters[0],
&Target_Object_Property_Value[0]);
private_data.serviceParameters = &Service_Parameters[0];
private_data.serviceParametersLen = len;
private_data.vendorID = Target_Vendor_Identifier;
private_data.serviceNumber = Target_Service_Number;
Send_UnconfirmedPrivateTransfer(
&Target_Address,
Send_UnconfirmedPrivateTransfer(&Target_Address,
&private_data);
printf("Sent PrivateTransfer. Waiting %u seconds.\r\n",
(unsigned) (timeout_seconds - elapsed_seconds));
-1
View File
@@ -311,4 +311,3 @@ int main(
}
return 0;
}
+4 -2
View File
@@ -94,13 +94,15 @@ struct sockaddr_in; /* Defined elsewhere, needed here. */
/* Returns the last BVLL Result we received, either as the result of a BBMD
* request we sent, or (if not a BBMD or Client), from trying to register
* as a foreign device. */
BACNET_BVLC_RESULT bvlc_get_last_result(void);
BACNET_BVLC_RESULT bvlc_get_last_result(
void);
/* Returns the current BVLL Function Code we are processing.
* We have to store this higher layer code for when the lower layers
* need to know what it is, especially to differentiate between
* BVLC_ORIGINAL_UNICAST_NPDU and BVLC_ORIGINAL_BROADCAST_NPDU. */
BACNET_BVLC_FUNCTION bvlc_get_function_code(void);
BACNET_BVLC_FUNCTION bvlc_get_function_code(
void);
#ifdef __cplusplus
}
+8 -4
View File
@@ -37,10 +37,14 @@ extern "C" {
uint16_t elapsed_seconds);
/* Simple setters and getter. */
void dlenv_bbmd_address_set( long address );
void dlenv_bbmd_port_set( int port );
void dlenv_bbmd_ttl_set( int ttl_secs );
int dlenv_bbmd_result( void );
void dlenv_bbmd_address_set(
long address);
void dlenv_bbmd_port_set(
int port);
void dlenv_bbmd_ttl_set(
int ttl_secs);
int dlenv_bbmd_result(
void);
#ifdef __cplusplus
}
+2 -1
View File
@@ -215,7 +215,8 @@ extern "C" {
uint16_t service_len,
BACNET_ADDRESS * src,
BACNET_CONFIRMED_SERVICE_DATA * service_data);
void handler_cov_task(void);
void handler_cov_task(
void);
void handler_cov_timer_seconds(
uint32_t elapsed_seconds);
void handler_cov_init(
+5 -2
View File
@@ -49,12 +49,15 @@ extern "C" {
/* encode objects */
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id);
int wpm_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id);
int wpm_encode_apdu_object_begin(
uint8_t * apdu,
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance);
int wpm_encode_apdu_object_end (uint8_t * apdu);
int wpm_encode_apdu_object_end(
uint8_t * apdu);
int wpm_encode_apdu_object_property(
uint8_t * apdu,
BACNET_WRITE_PROPERTY_DATA * wpdata);
+2 -2
View File
@@ -360,8 +360,8 @@ bool Analog_Value_Write_Property(
(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->object_instance);
Analog_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -271,8 +271,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+6 -6
View File
@@ -850,8 +850,8 @@ bool Device_Write_Property_Local(
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))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -903,13 +903,13 @@ bool Device_Write_Property_Local(
characterstring_encoding(&value.type.Character_String);
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
/* All the object names in a device must be unique. */
if (Device_Valid_Object_Name(&value.type.
Character_String, NULL, NULL)) {
if (Device_Valid_Object_Name(&value.
type.Character_String, NULL, NULL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else {
Device_Set_Object_Name(&value.type.
Character_String);
Device_Set_Object_Name(&value.
type.Character_String);
status = true;
}
} else {
+1 -2
View File
@@ -1119,8 +1119,7 @@ static bool MSTP_Master_Node_FSM(
Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false;
} else if ((Timer_Silence() > Treply_delay) ||
(pkt != NULL)) {
} else if ((Timer_Silence() > Treply_delay) || (pkt != NULL)) {
/* DeferredReply */
/* If no reply will be available from the higher layers */
/* within Treply_delay after the reception of the */
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+2 -2
View File
@@ -380,8 +380,8 @@ bool Device_Write_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))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) {
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated;
+7 -12
View File
@@ -64,18 +64,13 @@ bool bacnet_name_save(
uint8_t i = 0;
if (bacnet_name_isvalid(encoding, length, str)) {
eeprom_bytes_write(
NV_EEPROM_NAME_LENGTH(offset),
&length, 1);
eeprom_bytes_write(
NV_EEPROM_NAME_ENCODING(offset),
eeprom_bytes_write(NV_EEPROM_NAME_LENGTH(offset), &length, 1);
eeprom_bytes_write(NV_EEPROM_NAME_ENCODING(offset),
(uint8_t *) & encoding, 1);
for (i = 0; i < length; i++) {
buffer[i] = str[i];
}
eeprom_bytes_write(
NV_EEPROM_NAME_STRING(offset),
&buffer[0],
eeprom_bytes_write(NV_EEPROM_NAME_STRING(offset), &buffer[0],
NV_EEPROM_NAME_SIZE);
return true;
}
@@ -118,8 +113,8 @@ bool bacnet_name_write_unique(
} else if (length <= NV_EEPROM_NAME_SIZE) {
encoding = characterstring_encoding(char_string);
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
if (Device_Valid_Object_Name(char_string,
&duplicate_type, &duplicate_instance)) {
if (Device_Valid_Object_Name(char_string, &duplicate_type,
&duplicate_instance)) {
if ((duplicate_type == object_type) &&
(duplicate_instance == object_instance)) {
/* writing same name to same object */
@@ -185,8 +180,8 @@ void bacnet_name_init(
uint16_t offset,
char *default_string)
{
(void)bacnet_name_save(offset, CHARACTER_UTF8,
default_string, strlen(default_string));
(void) bacnet_name_save(offset, CHARACTER_UTF8, default_string,
strlen(default_string));
}
void bacnet_name(
+2 -2
View File
@@ -439,8 +439,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
Binary_Output_Present_Value_Set
(wp_data->object_instance, level, priority);
Binary_Output_Present_Value_Set(wp_data->
object_instance, level, priority);
} else if (priority == 6) {
status = false;
/* Command priority 6 is reserved for use by Minimum On/Off
+6 -8
View File
@@ -856,8 +856,8 @@ bool Device_Write_Property_Local(
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))) {
eeprom_bytes_write(NV_EEPROM_DEVICE_0,
(uint8_t *) & value.type.Object_Id.instance, 4);
/* we could send an I-Am broadcast to let the world know */
@@ -902,12 +902,10 @@ bool Device_Write_Property_Local(
break;
case PROP_OBJECT_NAME:
if (value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
status = bacnet_name_write_unique(
NV_EEPROM_DEVICE_NAME,
value.type.Object_Id.type,
value.type.Object_Id.instance,
&value.type.Character_String,
&wp_data->error_class,
status =
bacnet_name_write_unique(NV_EEPROM_DEVICE_NAME,
value.type.Object_Id.type, value.type.Object_Id.instance,
&value.type.Character_String, &wp_data->error_class,
&wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+5 -2
View File
@@ -273,8 +273,11 @@ typedef struct {
#endif
#elif defined (__CROSSWORKS_AVR)
/* use functions defined in crt0.s to mimic IAR macros */
void __uint8_eeprom_store(unsigned char byte, unsigned addr);
unsigned char __uint8_eeprom_load(unsigned addr);
void __uint8_eeprom_store(
unsigned char byte,
unsigned addr);
unsigned char __uint8_eeprom_load(
unsigned addr);
#define __EEPUT(addr, var) \
__uint8_eeprom_store((unsigned char)(var), (unsigned)(addr))
#define __EEGET(var, addr) \
+6 -3
View File
@@ -165,17 +165,20 @@ void test_task(
case 'e':
seeprom_bytes_read(NV_SEEPROM_TYPE_0, (uint8_t *) & id, 2);
sprintf(Send_Buffer, "\r\n%04X", id);
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break;
case 'b':
sprintf(Send_Buffer, "\r\n%lubps",
(unsigned long) rs485_baud_rate());
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break;
case 'm':
sprintf(Send_Buffer, "\r\nMax:%u",
(unsigned) dlmstp_max_master());
serial_bytes_send((uint8_t *) Send_Buffer, strlen(Send_Buffer));
serial_bytes_send((uint8_t *) Send_Buffer,
strlen(Send_Buffer));
break;
default:
break;
+18 -41
View File
@@ -323,14 +323,9 @@ uint16_t MSTP_Get_Send(
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
/* convert the PDU into the MSTP Frame */
pdu_len = MSTP_Create_Frame(
&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize,
frame_type,
pkt->destination_mac,
mstp_port->This_Station,
(uint8_t *) & pkt->buffer[0],
pkt->length);
pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize, frame_type, pkt->destination_mac,
mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length);
return pdu_len;
}
@@ -369,8 +364,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.network_layer_message) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Request is Network message.\n");
"DLMSTP: DER Compare failed: " "Request is Network message.\n");
#endif
return false;
}
@@ -378,8 +372,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.pdu_type != PDU_TYPE_CONFIRMED_SERVICE_REQUEST) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Not Confirmed Request.\n");
"DLMSTP: DER Compare failed: " "Not Confirmed Request.\n");
#endif
return false;
}
@@ -398,8 +391,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (reply.npdu_data.network_layer_message) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Reply is Network message.\n");
"DLMSTP: DER Compare failed: " "Reply is Network message.\n");
#endif
return false;
}
@@ -446,8 +438,7 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.invoke_id != reply.invoke_id) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Invoke ID mismatch.\n");
"DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n");
#endif
return false;
}
@@ -455,16 +446,14 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.invoke_id != reply.invoke_id) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Invoke ID mismatch.\n");
"DLMSTP: DER Compare failed: " "Invoke ID mismatch.\n");
#endif
return false;
}
if (request.service_choice != reply.service_choice) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"Service choice mismatch.\n");
"DLMSTP: DER Compare failed: " "Service choice mismatch.\n");
#endif
return false;
}
@@ -480,16 +469,14 @@ static bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.priority != reply.npdu_data.priority) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"NPDU Priority mismatch.\n");
"DLMSTP: DER Compare failed: " "NPDU Priority mismatch.\n");
#endif
return false;
}
if (!bacnet_address_same(&request.address, &reply.address)) {
#if PRINT_ENABLED
fprintf(stderr,
"DLMSTP: DER Compare failed: "
"BACnet Address mismatch.\n");
"DLMSTP: DER Compare failed: " "BACnet Address mismatch.\n");
#endif
return false;
}
@@ -514,13 +501,9 @@ uint16_t MSTP_Get_Reply(
pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue);
/* is this the reply to the DER? */
matched =
dlmstp_compare_data_expecting_reply(
&mstp_port->InputBuffer[0],
mstp_port->DataLength,
mstp_port->SourceAddress,
(uint8_t *) & pkt->buffer[0],
pkt->length,
pkt->destination_mac);
dlmstp_compare_data_expecting_reply(&mstp_port->InputBuffer[0],
mstp_port->DataLength, mstp_port->SourceAddress,
(uint8_t *) & pkt->buffer[0], pkt->length, pkt->destination_mac);
if (!matched) {
return 0;
}
@@ -531,14 +514,9 @@ uint16_t MSTP_Get_Reply(
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
}
/* convert the PDU into the MSTP Frame */
pdu_len = MSTP_Create_Frame(
&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize,
frame_type,
pkt->destination_mac,
mstp_port->This_Station,
(uint8_t *) & pkt->buffer[0],
pkt->length);
pdu_len = MSTP_Create_Frame(&mstp_port->OutputBuffer[0], /* <-- loading this */
mstp_port->OutputBufferSize, frame_type, pkt->destination_mac,
mstp_port->This_Station, (uint8_t *) & pkt->buffer[0], pkt->length);
return pdu_len;
}
@@ -678,8 +656,7 @@ bool dlmstp_init(
/* initialize PDU queue */
Ringbuf_Init(&PDU_Queue, (uint8_t *) & PDU_Buffer,
sizeof(struct mstp_pdu_packet),
MSTP_PDU_PACKET_COUNT);
sizeof(struct mstp_pdu_packet), MSTP_PDU_PACKET_COUNT);
/* initialize packet queue */
Receive_Packet.ready = false;
Receive_Packet.pdu_len = 0;
+2 -2
View File
@@ -325,8 +325,8 @@ bool Analog_Value_Write_Property(
(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->object_instance);
Analog_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Present_Value[object_index] = level;
/* Note: you could set the physical output here if we
+2 -2
View File
@@ -237,8 +237,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated;
object_index =
Binary_Value_Instance_To_Index
(wp_data->object_instance);
Binary_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
/* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level;
+2 -2
View File
@@ -533,8 +533,8 @@ bool Device_Write_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))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
+3 -7
View File
@@ -115,13 +115,9 @@ int dlmstp_send_pdu(
return -4;
}
bytes_sent =
MSTP_Create_Frame(
(uint8_t *) & MSTP_Port.TxBuffer[0],
sizeof(MSTP_Port.TxBuffer),
MSTP_Port.TxFrameType,
MSTP_Port.TxDestination,
MSTP_Port.This_Station,
pdu, pdu_len);
MSTP_Create_Frame((uint8_t *) & MSTP_Port.TxBuffer[0],
sizeof(MSTP_Port.TxBuffer), MSTP_Port.TxFrameType,
MSTP_Port.TxDestination, MSTP_Port.This_Station, pdu, pdu_len);
MSTP_Port.TxLength = bytes_sent;
MSTP_Port.TxReady = true;
MSTP_Packets++;
+5 -9
View File
@@ -1145,13 +1145,10 @@ bool MSTP_Master_Node_FSM(
see if the message is that same APDU type
along with the matching src/dest and invoke ID */
matched =
mstp_compare_data_expecting_reply(
&mstp_port->InputBuffer[0],
mstp_port->DataLength,
mstp_port->SourceAddress,
&mstp_port->TxBuffer[0],
mstp_port->TxLength,
mstp_port->TxDestination);
mstp_compare_data_expecting_reply(&mstp_port->
InputBuffer[0], mstp_port->DataLength,
mstp_port->SourceAddress, &mstp_port->TxBuffer[0],
mstp_port->TxLength, mstp_port->TxDestination);
}
if (matched && mstp_port->TxReady) {
/* Reply */
@@ -1162,8 +1159,7 @@ bool MSTP_Master_Node_FSM(
/* then call MSTP_Create_And_Send_Frame to transmit the reply frame */
/* and enter the IDLE state to wait for the next frame. */
RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->TxBuffer[0],
mstp_port->TxLength);
(uint8_t *) & mstp_port->TxBuffer[0], mstp_port->TxLength);
mstp_port->TxReady = false;
mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
} else {
+1 -2
View File
@@ -261,8 +261,7 @@ bool bip_init(
bip_set_port(htons((0xBAC0));
/* assumes that the driver has already been initialized */
sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP);
bip_set_socket(sock_fd);
if (sock_fd < 0)
bip_set_socket(sock_fd); if (sock_fd < 0)
return false;
/* bind the socket to the local port number and IP address */
sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY);
+2 -2
View File
@@ -429,8 +429,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
Binary_Output_Present_Value_Set
(wp_data->object_instance, level, priority);
Binary_Output_Present_Value_Set(wp_data->
object_instance, level, priority);
} else if (priority == 6) {
status = false;
/* Command priority 6 is reserved for use by Minimum On/Off
+8 -8
View File
@@ -833,8 +833,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code);
if (status) {
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))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -868,8 +868,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code);
if (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));
}
break;
@@ -878,8 +878,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Location(characterstring_value(&value.
type.Character_String),
Device_Set_Location(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
@@ -889,8 +889,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code);
if (status) {
Device_Set_Description(characterstring_value(&value.
type.Character_String),
Device_Set_Description(characterstring_value(&value.type.
Character_String),
characterstring_length(&value.type.Character_String));
}
break;
+2 -2
View File
@@ -430,8 +430,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--;
Binary_Output_Present_Value_Set
(wp_data->object_instance, level, priority);
Binary_Output_Present_Value_Set(wp_data->
object_instance, level, priority);
} else if (priority == 6) {
status = false;
/* Command priority 6 is reserved for use by Minimum On/Off
+6 -6
View File
@@ -836,8 +836,8 @@ bool Device_Write_Property_Local(
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))) {
/* we could send an I-Am broadcast to let the world know */
status = true;
} else {
@@ -889,13 +889,13 @@ bool Device_Write_Property_Local(
characterstring_encoding(&value.type.Character_String);
if (encoding < MAX_CHARACTER_STRING_ENCODING) {
/* All the object names in a device must be unique. */
if (Device_Valid_Object_Name(&value.type.
Character_String, NULL, NULL)) {
if (Device_Valid_Object_Name(&value.
type.Character_String, NULL, NULL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_DUPLICATE_NAME;
} else {
Device_Set_Object_Name(&value.type.
Character_String);
Device_Set_Object_Name(&value.
type.Character_String);
status = true;
}
} else {
+2 -4
View File
@@ -378,8 +378,7 @@ static bool MSTP_Transmit_FSM(
case MSTP_TX_STATE_IDLE:
if (!Ringbuf_Empty(&Transmit_Queue)) {
/* get the packet - but don't remove it from queue */
pkt =
(struct mstp_tx_packet *)
pkt = (struct mstp_tx_packet *)
Ringbuf_Get_Front(&Transmit_Queue);
state = MSTP_TX_STATE_SILENCE_WAIT;
}
@@ -1235,8 +1234,7 @@ static bool MSTP_Master_Node_FSM(
Master_State = MSTP_MASTER_STATE_IDLE;
/* clear our flag we were holding for comparison */
MSTP_Flag.ReceivedValidFrame = false;
} else if (rs485_silence_elapsed(Treply_delay) ||
(pkt != NULL)) {
} else if (rs485_silence_elapsed(Treply_delay) || (pkt != NULL)) {
/* DeferredReply */
/* If no reply will be available from the higher layers */
/* within Treply_delay after the reception of the */
+1 -2
View File
@@ -63,8 +63,7 @@ BACNET_ABORT_REASON abort_convert_error_code(
abort_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED;
break;
case ERROR_CODE_ABORT_PROPRIETARY:
abort_code =
(BACNET_ABORT_REASON)FIRST_PROPRIETARY_ABORT_REASON;
abort_code = (BACNET_ABORT_REASON) FIRST_PROPRIETARY_ABORT_REASON;
break;
case ERROR_CODE_ABORT_OTHER:
default:
+7 -7
View File
@@ -149,8 +149,7 @@ static struct Address_Cache_Entry *address_remove_oldest(
pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch->
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
ulTime = pMatch->TimeToLive;
@@ -169,8 +168,7 @@ static struct Address_Cache_Entry *address_remove_oldest(
/* Second pass - try in use and un bound as last resort */
pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch->
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) ==
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
@@ -208,7 +206,8 @@ static void address_file_init(
unsigned max_apdu = 0;
unsigned mac[6] = { 0 };
int count = 0;
char mac_string[80] = {""}, sadr_string[80] = {""};
char mac_string[80] = { "" }, sadr_string[80] = {
""};
BACNET_ADDRESS src = { 0 };
int index = 0;
@@ -230,8 +229,9 @@ static void address_file_init(
src.net = (uint16_t) snet;
if (snet) {
count =
sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x", &mac[0],
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
sscanf(sadr_string, "%2x:%2x:%2x:%2x:%2x:%2x",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4],
&mac[5]);
src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = (uint8_t) mac[index];
+3 -2
View File
@@ -156,8 +156,9 @@ bool apdu_service_supported(
if (Confirmed_Function[i] != NULL) {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
int len = Routed_Device_Service_Approval(
service_supported, 0, NULL, 0);
int len =
Routed_Device_Service_Approval(service_supported, 0,
NULL, 0);
if (len > 0)
break; /* Not supported - return false */
#endif
+74 -66
View File
@@ -264,8 +264,7 @@ int bacapp_decode_data(
}
}
if ((len == 0) &&
(tag_data_type != BACNET_APPLICATION_TAG_NULL) &&
if ((len == 0) && (tag_data_type != BACNET_APPLICATION_TAG_NULL) &&
(tag_data_type != BACNET_APPLICATION_TAG_BOOLEAN) &&
(tag_data_type != BACNET_APPLICATION_TAG_OCTET_STRING)) {
/* indicate that we were not able to decode the value */
@@ -739,8 +738,7 @@ int bacapp_decode_context_data(
} else {
apdu_len = BACNET_STATUS_ERROR;
}
}
else if ( tag_len == 1 ) /* and is a Closing tag */
} else if (tag_len == 1) /* and is a Closing tag */
apdu_len = 0; /* Don't advance over that closing tag. */
}
@@ -961,7 +959,10 @@ int bacapp_data_len(
}
#ifdef BACAPP_SNPRINTF_ENABLED
static bool append_str(char **str, size_t *rem_str_len, const char *add_str)
static bool append_str(
char **str,
size_t * rem_str_len,
const char *add_str)
{
bool retval;
int bytes_written;
@@ -970,9 +971,7 @@ static bool append_str(char **str, size_t *rem_str_len, const char *add_str)
if ((bytes_written < 0) || (bytes_written >= *rem_str_len)) {
/* If there was an error or output was truncated, return error */
retval = false;
}
else
{
} else {
/* Successfully wrote the contents to the string. Let's advance the
* string pointer to the end, and account for the used space */
*str += bytes_written;
@@ -1016,26 +1015,27 @@ int bacapp_snprintf_value(
ret_val = snprintf(str, str_len, "Null");
break;
case BACNET_APPLICATION_TAG_BOOLEAN:
ret_val = (value->type.Boolean) ?
snprintf(str, str_len, "TRUE") :
snprintf(str, str_len, "FALSE");
ret_val =
(value->type.Boolean) ? snprintf(str, str_len,
"TRUE") : snprintf(str, str_len, "FALSE");
break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
ret_val = snprintf(str, str_len, "%lu",
ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Unsigned_Int);
break;
case BACNET_APPLICATION_TAG_SIGNED_INT:
ret_val = snprintf(str, str_len, "%ld",
ret_val =
snprintf(str, str_len, "%ld",
(long) value->type.Signed_Int);
break;
case BACNET_APPLICATION_TAG_REAL:
ret_val = snprintf(str, str_len, "%f",
(double) value->type.Real);
ret_val =
snprintf(str, str_len, "%f", (double) value->type.Real);
break;
#if defined (BACAPP_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
ret_val = snprintf(str, str_len, "%f",
value->type.Double);
ret_val = snprintf(str, str_len, "%f", value->type.Double);
break;
#endif
case BACNET_APPLICATION_TAG_OCTET_STRING:
@@ -1047,15 +1047,15 @@ int bacapp_snprintf_value(
break;
octet_str++;
}
if (i == len)
{
if (i == len) {
// Everything went fine
ret_val = str_len - rem_str_len;
}
break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
len = characterstring_length(&value->type.Character_String);
char_str = characterstring_value(&value->type.Character_String);
char_str =
characterstring_value(&value->type.Character_String);
if (!append_str(&p_str, &rem_str_len, "\""))
break;
for (i = 0; i < len; i++) {
@@ -1068,10 +1068,8 @@ int bacapp_snprintf_value(
break;
char_str++;
}
if ( (i == len) &&
append_str(&p_str, &rem_str_len, "\"")
)
{
if ((i == len) && append_str(&p_str, &rem_str_len, "\"")
) {
// Everything is fine. Indicate how many bytes were
// written
ret_val = str_len - rem_str_len;
@@ -1087,16 +1085,13 @@ int bacapp_snprintf_value(
(uint8_t) i) ? "true" : "false");
if (!append_str(&p_str, &rem_str_len, temp_str))
break;
if (i < len - 1)
{
if (i < len - 1) {
if (!append_str(&p_str, &rem_str_len, ","))
break;
}
}
if ( (i == len) &&
append_str(&p_str, &rem_str_len, "}")
)
{
if ((i == len) && append_str(&p_str, &rem_str_len, "}")
) {
// Everything is fine. Indicate how many bytes were
// written
ret_val = str_len - rem_str_len;
@@ -1106,66 +1101,80 @@ int bacapp_snprintf_value(
switch (property) {
case PROP_OBJECT_TYPE:
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
ret_val = snprintf(str, str_len, "%s",
bactext_object_type_name(value->type.
Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_object_type_name(value->
type.Enumerated));
} else if (value->type.Enumerated < 128) {
ret_val = snprintf(str, str_len, "reserved %lu",
ret_val =
snprintf(str, str_len, "reserved %lu",
(unsigned long) value->type.Enumerated);
} else {
ret_val = snprintf(str, str_len, "proprietary %lu",
ret_val =
snprintf(str, str_len, "proprietary %lu",
(unsigned long) value->type.Enumerated);
}
break;
case PROP_EVENT_STATE:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_event_state_name(value->type.Enumerated));
break;
case PROP_UNITS:
if (value->type.Enumerated < 256) {
ret_val = snprintf(str, str_len, "%s",
bactext_engineering_unit_name(value->
type.Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_engineering_unit_name(value->type.
Enumerated));
} else {
ret_val = snprintf(str, str_len, "proprietary %lu",
ret_val =
snprintf(str, str_len, "proprietary %lu",
(unsigned long) value->type.Enumerated);
}
break;
case PROP_POLARITY:
ret_val = snprintf(str, str_len, "%s",
bactext_binary_polarity_name(value->
type.Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_binary_polarity_name(value->type.
Enumerated));
break;
case PROP_PRESENT_VALUE:
case PROP_RELINQUISH_DEFAULT:
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
ret_val = snprintf(str, str_len, "%s",
bactext_binary_present_value_name(value->type.
Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_binary_present_value_name(value->
type.Enumerated));
} else {
ret_val = snprintf(str, str_len, "%lu",
ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Enumerated);
}
break;
case PROP_RELIABILITY:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_reliability_name(value->type.Enumerated));
break;
case PROP_SYSTEM_STATUS:
ret_val = snprintf(str, str_len, "%s",
bactext_device_status_name(value->
type.Enumerated));
ret_val =
snprintf(str, str_len, "%s",
bactext_device_status_name(value->type.
Enumerated));
break;
case PROP_SEGMENTATION_SUPPORTED:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_segmentation_name(value->type.Enumerated));
break;
case PROP_NODE_TYPE:
ret_val = snprintf(str, str_len, "%s",
ret_val =
snprintf(str, str_len, "%s",
bactext_node_type_name(value->type.Enumerated));
break;
default:
ret_val = snprintf(str, str_len, "%lu",
ret_val =
snprintf(str, str_len, "%lu",
(unsigned long) value->type.Enumerated);
break;
}
@@ -1252,7 +1261,8 @@ int bacapp_snprintf_value(
break;
if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) {
if (!append_str(&p_str, &rem_str_len,
bactext_object_type_name(value->type.Object_Id.type)
bactext_object_type_name(value->type.Object_Id.
type)
)
)
break;
@@ -1313,8 +1323,7 @@ bool bacapp_print_value(
size_t str_len = 32;
int status;
while (true)
{
while (true) {
// Try to allocate memory for the output string. Give up if unable.
str = (char *) calloc(sizeof(char), str_len);
if (!str)
@@ -1323,12 +1332,10 @@ bool bacapp_print_value(
// Try to extract the value into allocated memory. If unable, try again
// another time with a string that is twice as large.
status = bacapp_snprintf_value(str, str_len, object_value);
if ( (status < 0 ) || (status >= str_len) )
{
if ((status < 0) || (status >= str_len)) {
free(str);
str_len *= 2;
}
else if (status == 0) {
} else if (status == 0) {
free(str);
break;
} else {
@@ -1413,7 +1420,8 @@ bool bacapp_parse_application_data(
break;
case BACNET_APPLICATION_TAG_DATE:
count =
sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day, &wday);
sscanf(argv, "%4d/%3d/%3d:%3d", &year, &month, &day,
&wday);
if (count == 3) {
datetime_set_date(&value->type.Date, (uint16_t) year,
(uint8_t) month, (uint8_t) day);
@@ -1637,8 +1645,8 @@ void testBACnetApplicationData_Safe(
break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
characterstring_init_ansi(&input_value[i].type.
Character_String, "Hello There!");
characterstring_init_ansi(&input_value[i].
type.Character_String, "Hello There!");
break;
case BACNET_APPLICATION_TAG_BIT_STRING:
@@ -2113,8 +2121,8 @@ void testBACnetApplicationData(
ct_test(pTest, testBACnetApplicationDataValue(&value));
/* test empty string */
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
"", &value);
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING, "",
&value);
ct_test(pTest, status == true);
ct_test(pTest, testBACnetApplicationDataValue(&value));
+2 -1
View File
@@ -929,7 +929,8 @@ INDTEXT_DATA bacnet_property_names[] = {
,
{PROP_LAST_KEY_SERVER, "last-key-server"}
,
{PROP_NETWORK_ACCESS_SECURITY_ALGORITHMS, "network-access-security-algorithms"}
{PROP_NETWORK_ACCESS_SECURITY_ALGORITHMS,
"network-access-security-algorithms"}
,
{PROP_PACKET_REORDER_TIME, "packet-reorder-time"}
,
+1 -2
View File
@@ -262,8 +262,7 @@ uint16_t bip_receive(
if (pdu[0] != BVLL_TYPE_BACNET_IP)
return 0;
if ( bvlc_for_non_bbmd(&sin, pdu, received_bytes) > 0 )
{
if (bvlc_for_non_bbmd(&sin, pdu, received_bytes) > 0) {
/* Handled, usually with a NACK. */
#if PRINT_ENABLED
fprintf(stderr, "BIP: BVLC discarded!\n");
+6 -4
View File
@@ -665,8 +665,8 @@ static void bvlc_bdt_forward_npdu(
mask in the BDT entry and logically ORing it with the
BBMD address of the same entry. */
bip_dest.sin_addr.s_addr =
((~BBMD_Table[i].broadcast_mask.
s_addr) | BBMD_Table[i].dest_address.s_addr);
((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
dest_address.s_addr);
bip_dest.sin_port = BBMD_Table[i].dest_port;
/* don't send to my broadcast address and same port */
if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr())
@@ -1304,7 +1304,8 @@ int bvlc_for_non_bbmd(
* BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK if registration failed,
* or one of the other codes (if we are a BBMD).
*/
BACNET_BVLC_RESULT bvlc_get_last_result(void)
BACNET_BVLC_RESULT bvlc_get_last_result(
void)
{
return BVLC_Result_Code;
}
@@ -1316,7 +1317,8 @@ BACNET_BVLC_RESULT bvlc_get_last_result(void)
*
* @return A BVLC_ code, such as BVLC_ORIGINAL_UNICAST_NPDU.
*/
BACNET_BVLC_FUNCTION bvlc_get_function_code(void)
BACNET_BVLC_FUNCTION bvlc_get_function_code(
void)
{
return BVLC_Function_Code;
}
+1
View File
@@ -127,6 +127,7 @@ bool dcc_set_status_duration(
return valid;
}
#if BACNET_SVC_DCC_A
/* encode service */
int dcc_encode_apdu(
+138 -143
View File
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len], 0,
&data->notificationParams.
changeOfBitstring.referencedBitString);
&data->notificationParams.changeOfBitstring.
referencedBitString);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.
changeOfBitstring.statusFlags);
&data->notificationParams.changeOfBitstring.
statusFlags);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 0);
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.
changeOfState.statusFlags);
&data->notificationParams.changeOfState.
statusFlags);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 1);
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
case CHANGE_OF_VALUE_REAL:
len =
encode_context_real(&apdu[apdu_len], 1,
data->notificationParams.
changeOfValue.newValue.changeValue);
data->notificationParams.changeOfValue.
newValue.changeValue);
apdu_len += len;
break;
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len],
0,
&data->notificationParams.
changeOfValue.newValue.changedBits);
&data->notificationParams.changeOfValue.
newValue.changedBits);
apdu_len += len;
break;
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.
changeOfValue.statusFlags);
&data->notificationParams.changeOfValue.
statusFlags);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 2);
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
len =
encode_context_real(&apdu[apdu_len], 0,
data->notificationParams.
floatingLimit.referenceValue);
data->notificationParams.floatingLimit.
referenceValue);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.
floatingLimit.statusFlags);
&data->notificationParams.floatingLimit.
statusFlags);
apdu_len += len;
len =
encode_context_real(&apdu[apdu_len], 2,
data->notificationParams.
floatingLimit.setPointValue);
data->notificationParams.floatingLimit.
setPointValue);
apdu_len += len;
len =
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
len =
encode_context_real(&apdu[apdu_len], 0,
data->notificationParams.
outOfRange.exceedingValue);
data->notificationParams.outOfRange.
exceedingValue);
apdu_len += len;
len =
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
len =
encode_context_enumerated(&apdu[apdu_len], 0,
data->notificationParams.
changeOfLifeSafety.newState);
data->notificationParams.changeOfLifeSafety.
newState);
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 1,
data->notificationParams.
changeOfLifeSafety.newMode);
data->notificationParams.changeOfLifeSafety.
newMode);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 2,
&data->notificationParams.
changeOfLifeSafety.statusFlags);
&data->notificationParams.changeOfLifeSafety.
statusFlags);
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 3,
data->notificationParams.
changeOfLifeSafety.operationExpected);
data->notificationParams.changeOfLifeSafety.
operationExpected);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 8);
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
len =
bacapp_encode_context_device_obj_property_ref(&apdu
[apdu_len], 0,
&data->notificationParams.
bufferReady.bufferProperty);
&data->notificationParams.bufferReady.
bufferProperty);
apdu_len += len;
len =
encode_context_unsigned(&apdu[apdu_len], 1,
data->notificationParams.
bufferReady.previousNotification);
data->notificationParams.bufferReady.
previousNotification);
apdu_len += len;
len =
encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams.
bufferReady.currentNotification);
data->notificationParams.bufferReady.
currentNotification);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 10);
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
len =
encode_context_unsigned(&apdu[apdu_len], 0,
data->notificationParams.
unsignedRange.exceedingValue);
data->notificationParams.unsignedRange.
exceedingValue);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.
unsignedRange.statusFlags);
&data->notificationParams.unsignedRange.
statusFlags);
apdu_len += len;
len =
encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams.
unsignedRange.exceededLimit);
data->notificationParams.unsignedRange.
exceededLimit);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 11);
@@ -595,18 +595,16 @@ int event_notify_decode_service_request(
case EVENT_CHANGE_OF_BITSTRING:
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0,
&data->
notificationParams.changeOfBitstring.
referencedBitString))) {
&data->notificationParams.
changeOfBitstring.referencedBitString))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->
notificationParams.changeOfBitstring.
statusFlags))) {
&data->notificationParams.
changeOfBitstring.statusFlags))) {
return -1;
}
len += section_length;
@@ -617,16 +615,16 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
bacapp_decode_context_property_state(&apdu
[len], 0,
&data->notificationParams.
changeOfState.newState))) {
&data->notificationParams.changeOfState.
newState))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.
changeOfState.statusFlags))) {
&data->notificationParams.changeOfState.
statusFlags))) {
return -1;
}
len += section_length;
@@ -644,9 +642,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0,
&data->
notificationParams.changeOfValue.
newValue.changedBits))) {
&data->notificationParams.
changeOfValue.newValue.changedBits))) {
return -1;
}
@@ -657,9 +654,8 @@ int event_notify_decode_service_request(
CHANGE_OF_VALUE_REAL)) {
if (-1 == (section_length =
decode_context_real(&apdu[len], 1,
&data->
notificationParams.changeOfValue.
newValue.changeValue))) {
&data->notificationParams.
changeOfValue.newValue.changeValue))) {
return -1;
}
@@ -677,8 +673,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.
changeOfValue.statusFlags))) {
&data->notificationParams.changeOfValue.
statusFlags))) {
return -1;
}
len += section_length;
@@ -687,31 +683,31 @@ int event_notify_decode_service_request(
case EVENT_FLOATING_LIMIT:
if (-1 == (section_length =
decode_context_real(&apdu[len], 0,
&data->notificationParams.
floatingLimit.referenceValue))) {
&data->notificationParams.floatingLimit.
referenceValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.
floatingLimit.statusFlags))) {
&data->notificationParams.floatingLimit.
statusFlags))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 2,
&data->notificationParams.
floatingLimit.setPointValue))) {
&data->notificationParams.floatingLimit.
setPointValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 3,
&data->notificationParams.
floatingLimit.errorLimit))) {
&data->notificationParams.floatingLimit.
errorLimit))) {
return -1;
}
len += section_length;
@@ -720,31 +716,31 @@ int event_notify_decode_service_request(
case EVENT_OUT_OF_RANGE:
if (-1 == (section_length =
decode_context_real(&apdu[len], 0,
&data->notificationParams.
outOfRange.exceedingValue))) {
&data->notificationParams.outOfRange.
exceedingValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.
outOfRange.statusFlags))) {
&data->notificationParams.outOfRange.
statusFlags))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 2,
&data->notificationParams.
outOfRange.deadband))) {
&data->notificationParams.outOfRange.
deadband))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 3,
&data->notificationParams.
outOfRange.exceededLimit))) {
&data->notificationParams.outOfRange.
exceededLimit))) {
return -1;
}
len += section_length;
@@ -772,9 +768,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 2,
&data->
notificationParams.changeOfLifeSafety.
statusFlags))) {
&data->notificationParams.
changeOfLifeSafety.statusFlags))) {
return -1;
}
len += section_length;
@@ -784,8 +779,8 @@ int event_notify_decode_service_request(
&value))) {
return -1;
}
data->notificationParams.
changeOfLifeSafety.operationExpected =
data->notificationParams.changeOfLifeSafety.
operationExpected =
(BACNET_LIFE_SAFETY_OPERATION) value;
len += section_length;
break;
@@ -794,24 +789,24 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
bacapp_decode_context_device_obj_property_ref
(&apdu[len], 0,
&data->notificationParams.
bufferReady.bufferProperty))) {
&data->notificationParams.bufferReady.
bufferProperty))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 1,
&data->notificationParams.
bufferReady.previousNotification))) {
&data->notificationParams.bufferReady.
previousNotification))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2,
&data->notificationParams.
bufferReady.currentNotification))) {
&data->notificationParams.bufferReady.
currentNotification))) {
return -1;
}
len += section_length;
@@ -820,24 +815,24 @@ int event_notify_decode_service_request(
case EVENT_UNSIGNED_RANGE:
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 0,
&data->notificationParams.
unsignedRange.exceedingValue))) {
&data->notificationParams.unsignedRange.
exceedingValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.
unsignedRange.statusFlags))) {
&data->notificationParams.unsignedRange.
statusFlags))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2,
&data->notificationParams.
unsignedRange.exceededLimit))) {
&data->notificationParams.unsignedRange.
exceededLimit))) {
return -1;
}
len += section_length;
@@ -1083,16 +1078,16 @@ void testEventEventState(
data.eventType = EVENT_CHANGE_OF_BITSTRING;
bitstring_init(&data.notificationParams.
changeOfBitstring.referencedBitString);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 0, true);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 1, false);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 2, true);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 2, false);
bitstring_init(&data.notificationParams.changeOfBitstring.
referencedBitString);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 2, true);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 2, false);
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
@@ -1116,8 +1111,8 @@ void testEventEventState(
testBaseEventState(pTest);
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfBitstring.
referencedBitString,
bitstring_same(&data.notificationParams.
changeOfBitstring.referencedBitString,
&data2.notificationParams.changeOfBitstring.referencedBitString));
ct_test(pTest,
@@ -1180,16 +1175,16 @@ void testEventEventState(
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
bitstring_init(&data.notificationParams.changeOfValue.
newValue.changedBits);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 2, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 3, false);
bitstring_init(&data.notificationParams.changeOfValue.newValue.
changedBits);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 2, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 3, false);
memset(buffer, 0, MAX_APDU);
inLen = event_notify_encode_service_request(&buffer[0], &data);
@@ -1210,8 +1205,8 @@ void testEventEventState(
data2.notificationParams.changeOfValue.tag);
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfValue.newValue.
changedBits,
bitstring_same(&data.notificationParams.changeOfValue.
newValue.changedBits,
&data2.notificationParams.changeOfValue.newValue.changedBits));
/**********************************************************************************/
@@ -1434,12 +1429,12 @@ void testEventEventState(
data.notificationParams.bufferReady.currentNotification = 2345;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
OBJECT_DEVICE;
data.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.instance = 500;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance = 500;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
OBJECT_ANALOG_INPUT;
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance = 100;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance = 100;
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
PROP_PRESENT_VALUE;
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
@@ -1464,34 +1459,34 @@ void testEventEventState(
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.type ==
data2.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.type);
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
type ==
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
type);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance ==
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance ==
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
type ==
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
type);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.instance ==
propertyIdentifier ==
data2.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance ==
data2.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.type ==
data2.notificationParams.bufferReady.bufferProperty.
objectIdentifier.type);
ct_test(pTest,
data.notificationParams.bufferReady.
bufferProperty.propertyIdentifier ==
data2.notificationParams.bufferReady.
bufferProperty.propertyIdentifier);
propertyIdentifier);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
+8 -7
View File
@@ -54,20 +54,21 @@ int get_alarm_sumary_ack_encode_apdu_data(
if (!apdu) {
apdu_len = BACNET_STATUS_ERROR;
}
else if(max_apdu >= 10) {
} else if (max_apdu >= 10) {
/* tag 0 - Object Identifier */
apdu_len += encode_application_object_id(&apdu[apdu_len],
apdu_len +=
encode_application_object_id(&apdu[apdu_len],
(int) get_alarm_data->objectIdentifier.type,
get_alarm_data->objectIdentifier.instance);
/* tag 1 - Alarm State */
apdu_len += encode_application_enumerated(&apdu[apdu_len],
apdu_len +=
encode_application_enumerated(&apdu[apdu_len],
get_alarm_data->alarmState);
/* tag 2 - Acknowledged Transitions */
apdu_len += encode_application_bitstring(&apdu[apdu_len],
apdu_len +=
encode_application_bitstring(&apdu[apdu_len],
&get_alarm_data->acknowledgedTransitions);
}
else {
} else {
apdu_len = BACNET_STATUS_ABORT;
}
+3 -7
View File
@@ -1140,13 +1140,9 @@ void MSTP_Slave_Node_FSM(
break;
case FRAME_TYPE_TEST_REQUEST:
mstp_port->ReceivedValidFrame = false;
MSTP_Create_And_Send_Frame(
mstp_port,
FRAME_TYPE_TEST_RESPONSE,
mstp_port->SourceAddress,
mstp_port->This_Station,
&mstp_port->InputBuffer[0],
mstp_port->DataLength);
MSTP_Create_And_Send_Frame(mstp_port, FRAME_TYPE_TEST_RESPONSE,
mstp_port->SourceAddress, mstp_port->This_Station,
&mstp_port->InputBuffer[0], mstp_port->DataLength);
break;
case FRAME_TYPE_TOKEN:
case FRAME_TYPE_POLL_FOR_MASTER:
+26 -52
View File
@@ -708,71 +708,49 @@ void property_list_special(
pPropertyList->Proprietary.pList = NULL;
switch (object_type) {
case OBJECT_DEVICE:
pPropertyList->Required.pList =
Device_Properties_Required;
pPropertyList->Optional.pList =
Device_Properties_Optional;
pPropertyList->Required.pList = Device_Properties_Required;
pPropertyList->Optional.pList = Device_Properties_Optional;
break;
break;
case OBJECT_ACCUMULATOR:
pPropertyList->Required.pList =
Accumulator_Properties_Required;
pPropertyList->Optional.pList =
Accumulator_Properties_Optional;
pPropertyList->Required.pList = Accumulator_Properties_Required;
pPropertyList->Optional.pList = Accumulator_Properties_Optional;
break;
case OBJECT_ANALOG_INPUT:
pPropertyList->Required.pList =
Analog_Input_Properties_Required;
pPropertyList->Optional.pList =
Analog_Input_Properties_Optional;
pPropertyList->Required.pList = Analog_Input_Properties_Required;
pPropertyList->Optional.pList = Analog_Input_Properties_Optional;
break;
case OBJECT_ANALOG_OUTPUT:
pPropertyList->Required.pList =
Analog_Output_Properties_Required;
pPropertyList->Optional.pList =
Analog_Output_Properties_Optional;
pPropertyList->Required.pList = Analog_Output_Properties_Required;
pPropertyList->Optional.pList = Analog_Output_Properties_Optional;
break;
case OBJECT_ANALOG_VALUE:
pPropertyList->Required.pList =
Analog_Value_Properties_Required;
pPropertyList->Optional.pList =
Analog_Value_Properties_Optional;
pPropertyList->Required.pList = Analog_Value_Properties_Required;
pPropertyList->Optional.pList = Analog_Value_Properties_Optional;
break;
case OBJECT_AVERAGING:
pPropertyList->Required.pList =
Averaging_Properties_Required;
pPropertyList->Optional.pList =
Averaging_Properties_Optional;
pPropertyList->Required.pList = Averaging_Properties_Required;
pPropertyList->Optional.pList = Averaging_Properties_Optional;
break;
case OBJECT_BINARY_INPUT:
pPropertyList->Required.pList =
Binary_Input_Properties_Required;
pPropertyList->Optional.pList =
Binary_Input_Properties_Optional;
pPropertyList->Required.pList = Binary_Input_Properties_Required;
pPropertyList->Optional.pList = Binary_Input_Properties_Optional;
break;
case OBJECT_BINARY_OUTPUT:
pPropertyList->Required.pList =
Binary_Output_Properties_Required;
pPropertyList->Optional.pList =
Binary_Output_Properties_Optional;
pPropertyList->Required.pList = Binary_Output_Properties_Required;
pPropertyList->Optional.pList = Binary_Output_Properties_Optional;
break;
case OBJECT_BINARY_VALUE:
pPropertyList->Required.pList =
Binary_Value_Properties_Required;
pPropertyList->Optional.pList =
Binary_Value_Properties_Optional;
pPropertyList->Required.pList = Binary_Value_Properties_Required;
pPropertyList->Optional.pList = Binary_Value_Properties_Optional;
break;
case OBJECT_CALENDAR:
pPropertyList->Required.pList =
Calendar_Properties_Required;
pPropertyList->Optional.pList =
Calendar_Properties_Optional;
pPropertyList->Required.pList = Calendar_Properties_Required;
pPropertyList->Optional.pList = Calendar_Properties_Optional;
break;
case OBJECT_COMMAND:
pPropertyList->Required.pList =
Command_Properties_Required;
pPropertyList->Optional.pList =
Command_Properties_Optional;
pPropertyList->Required.pList = Command_Properties_Required;
pPropertyList->Optional.pList = Command_Properties_Optional;
break;
case OBJECT_CHARACTERSTRING_VALUE:
pPropertyList->Required.pList =
@@ -781,10 +759,8 @@ void property_list_special(
CharacterString_Value_Properties_Optional;
break;
case OBJECT_LOAD_CONTROL:
pPropertyList->Required.pList =
Load_Control_Properties_Required;
pPropertyList->Optional.pList =
Load_Control_Properties_Optional;
pPropertyList->Required.pList = Load_Control_Properties_Required;
pPropertyList->Optional.pList = Load_Control_Properties_Optional;
break;
case OBJECT_LIFE_SAFETY_POINT:
pPropertyList->Required.pList =
@@ -817,10 +793,8 @@ void property_list_special(
Notification_Class_Properties_Optional;
break;
case OBJECT_TRENDLOG:
pPropertyList->Required.pList =
Trend_Log_Properties_Required;
pPropertyList->Optional.pList =
Trend_Log_Properties_Optional;
pPropertyList->Required.pList = Trend_Log_Properties_Required;
pPropertyList->Optional.pList = Trend_Log_Properties_Optional;
break;
case OBJECT_EVENT_ENROLLMENT:
case OBJECT_FILE:
+8 -5
View File
@@ -490,7 +490,8 @@ void test_Private_Transfer_Ack(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
@@ -543,7 +544,8 @@ void test_Private_Transfer_Error(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
@@ -594,7 +596,8 @@ void test_Private_Transfer_Request(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
@@ -638,8 +641,8 @@ void test_Unconfirmed_Private_Transfer_Request(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
status = bacapp_parse_application_data(
BACNET_APPLICATION_TAG_CHARACTER_STRING,
status =
bacapp_parse_application_data(BACNET_APPLICATION_TAG_CHARACTER_STRING,
&private_data_chunk[0], &data_value);
ct_test(pTest, status == true);
private_data_len =
+1 -2
View File
@@ -158,8 +158,7 @@ int rp_ack_encode_apdu_init(
/* service ack follows */
len =
encode_context_object_id(&apdu[apdu_len], 0,
rpdata->object_type,
encode_context_object_id(&apdu[apdu_len], 0, rpdata->object_type,
rpdata->object_instance);
apdu_len += len;
len =
+15 -10
View File
@@ -67,12 +67,14 @@ int wpm_decode_object_id(
apdu_len -= len;
if (apdu_len >= 4) {
len +=
decode_object_id(&apdu[len], &object_type, &object_instance);
decode_object_id(&apdu[len], &object_type,
&object_instance);
wp_data->object_type = object_type;
wp_data->object_instance = object_instance;
apdu_len -= len;
} else {
wp_data->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
wp_data->error_code =
ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT;
}
} else {
@@ -174,7 +176,9 @@ int wpm_decode_object_property(
}
/* encode functions */
int wpm_encode_apdu_init (uint8_t * apdu, uint8_t invoke_id)
int wpm_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id)
{
int apdu_len = 0; /* total length of the apdu, return value */
@@ -198,8 +202,9 @@ int wpm_encode_apdu_object_begin (
int apdu_len = 0; /* total length of the apdu, return value */
if (apdu) {
apdu_len = encode_context_object_id (
&apdu[0], 0, object_type, object_instance);
apdu_len =
encode_context_object_id(&apdu[0], 0, object_type,
object_instance);
/* Tag 1: sequence of WriteAccessSpecification */
apdu_len += encode_opening_tag(&apdu[apdu_len], 1);
}
@@ -207,7 +212,8 @@ int wpm_encode_apdu_object_begin (
return apdu_len;
}
int wpm_encode_apdu_object_end (uint8_t * apdu)
int wpm_encode_apdu_object_end(
uint8_t * apdu)
{
int apdu_len = 0; /* total length of the apdu, return value */
@@ -226,8 +232,8 @@ int wpm_encode_apdu_object_property (
int len = 0;
if (apdu) {
apdu_len = encode_context_enumerated (&apdu[0], 0,
wpdata->object_property);
apdu_len =
encode_context_enumerated(&apdu[0], 0, wpdata->object_property);
/* optional array index */
if (wpdata->array_index != BACNET_ARRAY_ALL) {
apdu_len +=
@@ -241,8 +247,7 @@ int wpm_encode_apdu_object_property (
}
apdu_len += encode_closing_tag(&apdu[apdu_len], 2);
if (wpdata->priority != BACNET_NO_PRIORITY) {
encode_context_unsigned (&apdu[apdu_len], 3,
wpdata->priority);
encode_context_unsigned(&apdu[apdu_len], 3, wpdata->priority);
}
}