Fixed indent script, and indented files.

This commit is contained in:
skarg
2010-07-19 23:19:54 +00:00
parent c0d63a1ed0
commit 6c9ef7211d
69 changed files with 681 additions and 627 deletions
+103 -101
View File
@@ -69,15 +69,15 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
static uint32_t Target_Device_Object_Instance = BACNET_MAX_INSTANCE; static uint32_t Target_Device_Object_Instance = BACNET_MAX_INSTANCE;
static BACNET_ADDRESS Target_Address; static BACNET_ADDRESS Target_Address;
/* = { 6, { 127, 0, 0, 1, 0xBA, 0xC0, 0 }, 0 }; loopback address to talk to myself */ /* = { 6, { 127, 0, 0, 1, 0xBA, 0xC0, 0 }, 0 }; loopback address to talk to myself */
static uint16_t My_BIP_Port = 0; /* If set, use this as the source port. */ static uint16_t My_BIP_Port = 0; /* If set, use this as the source port. */
static bool Provided_Targ_MAC = false; static bool Provided_Targ_MAC = false;
/* any errors are picked up in main loop */ /* any errors are picked up in main loop */
static bool Error_Detected = false; static bool Error_Detected = false;
static uint16_t Last_Error_Class = 0; static uint16_t Last_Error_Class = 0;
static uint16_t Last_Error_Code = 0; static uint16_t Last_Error_Code = 0;
static uint16_t Error_Count = 0; /* Counts errors we couldn't get around */ static uint16_t Error_Count = 0; /* Counts errors we couldn't get around */
static bool Has_RPM = true; /* Assume device can do RPM, to start */ static bool Has_RPM = true; /* Assume device can do RPM, to start */
static EPICS_STATES myState = INITIAL_BINDING; static EPICS_STATES myState = INITIAL_BINDING;
/* any valid RP or RPM data returned is put here */ /* any valid RP or RPM data returned is put here */
@@ -113,12 +113,11 @@ static int32_t Property_List[MAX_PROPS + 2];
/* This normally points to Property_List. */ /* This normally points to Property_List. */
static const int *pPropList = NULL; static const int *pPropList = NULL;
#define MINIMAL_PROPLIST_SIZE 4 #define MINIMAL_PROPLIST_SIZE 4
static int32_t MinimalPropList[MINIMAL_PROPLIST_SIZE] = static int32_t MinimalPropList[MINIMAL_PROPLIST_SIZE] = {
{ PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_OBJECT_TYPE, -1
-1
}; };
/* When we have to walk through an array of things, like ObjectIDs or /* When we have to walk through an array of things, like ObjectIDs or
@@ -148,10 +147,10 @@ static void MyErrorHandler(
(void) src; (void) src;
(void) invoke_id; (void) invoke_id;
#if PRINT_ERRORS #if PRINT_ERRORS
if ( ShowValues ) if (ShowValues)
fprintf(stderr, "-- BACnet Error: %s: %s\r\n", fprintf(stderr, "-- BACnet Error: %s: %s\r\n",
bactext_error_class_name(error_class), bactext_error_class_name(error_class),
bactext_error_code_name(error_code)); bactext_error_code_name(error_code));
#endif #endif
Error_Detected = true; Error_Detected = true;
Last_Error_Class = error_class; Last_Error_Class = error_class;
@@ -170,14 +169,15 @@ void MyAbortHandler(
(void) server; (void) server;
#if PRINT_ERRORS #if PRINT_ERRORS
/* It is normal for this to fail, so don't print. */ /* It is normal for this to fail, so don't print. */
if ((myState != GET_ALL_RESPONSE) && !IsLongArray && ShowValues ) if ((myState != GET_ALL_RESPONSE) && !IsLongArray && ShowValues)
fprintf(stderr, "-- BACnet Abort: %s \r\n", fprintf(stderr, "-- BACnet Abort: %s \r\n",
bactext_abort_reason_name(abort_reason)); bactext_abort_reason_name(abort_reason));
#endif #endif
Error_Detected = true; Error_Detected = true;
Last_Error_Class = ERROR_CLASS_SERVICES; Last_Error_Class = ERROR_CLASS_SERVICES;
if ( abort_reason < MAX_BACNET_ABORT_REASON ) if (abort_reason < MAX_BACNET_ABORT_REASON)
Last_Error_Code = (ERROR_CODE_ABORT_BUFFER_OVERFLOW -1) + abort_reason; Last_Error_Code =
(ERROR_CODE_ABORT_BUFFER_OVERFLOW - 1) + abort_reason;
else else
Last_Error_Code = ERROR_CODE_ABORT_OTHER; Last_Error_Code = ERROR_CODE_ABORT_OTHER;
} }
@@ -191,13 +191,15 @@ void MyRejectHandler(
(void) src; (void) src;
(void) invoke_id; (void) invoke_id;
#if PRINT_ERRORS #if PRINT_ERRORS
if ( ShowValues ) if (ShowValues)
fprintf(stderr, "BACnet Reject: %s\r\n", bactext_reject_reason_name(reject_reason)); fprintf(stderr, "BACnet Reject: %s\r\n",
bactext_reject_reason_name(reject_reason));
#endif #endif
Error_Detected = true; Error_Detected = true;
Last_Error_Class = ERROR_CLASS_SERVICES; Last_Error_Class = ERROR_CLASS_SERVICES;
if ( reject_reason < MAX_BACNET_REJECT_REASON ) if (reject_reason < MAX_BACNET_REJECT_REASON)
Last_Error_Code = (ERROR_CODE_REJECT_BUFFER_OVERFLOW -1) + reject_reason; Last_Error_Code =
(ERROR_CODE_REJECT_BUFFER_OVERFLOW - 1) + reject_reason;
else else
Last_Error_Code = ERROR_CODE_REJECT_OTHER; Last_Error_Code = ERROR_CODE_REJECT_OTHER;
} }
@@ -507,7 +509,7 @@ void PrintReadPropertyData(
case PROP_DEVICE_ADDRESS_BINDING: case PROP_DEVICE_ADDRESS_BINDING:
/* Make it VTS3-friendly and don't show "Null" /* Make it VTS3-friendly and don't show "Null"
* as a value. */ * as a value. */
if ( value->tag == BACNET_APPLICATION_TAG_NULL ) { if (value->tag == BACNET_APPLICATION_TAG_NULL) {
fprintf(stdout, "?"); fprintf(stdout, "?");
break; break;
} }
@@ -554,7 +556,8 @@ void PrintReadPropertyData(
* handling the proprietary property numbers. * handling the proprietary property numbers.
* @param propertyIdentifier [in] The property identifier number. * @param propertyIdentifier [in] The property identifier number.
*/ */
void Print_Property_Identifier(unsigned propertyIdentifier) void Print_Property_Identifier(
unsigned propertyIdentifier)
{ {
if (propertyIdentifier < 512) { if (propertyIdentifier < 512) {
fprintf(stdout, "%s", bactext_property_name(propertyIdentifier)); fprintf(stdout, "%s", bactext_property_name(propertyIdentifier));
@@ -581,9 +584,8 @@ static uint8_t Read_Properties(
struct special_property_list_t PropertyListStruct; struct special_property_list_t PropertyListStruct;
int i; int i;
if ( ( !Has_RPM && ( Property_List_Index == 0 ) ) || if ((!Has_RPM && (Property_List_Index == 0)) ||
( Property_List_Length == 0) ) (Property_List_Length == 0)) {
{
/* If we failed to get the Properties with RPM, just settle for what we /* If we failed to get the Properties with RPM, just settle for what we
* know is the fixed list of Required (only) properties. * know is the fixed list of Required (only) properties.
* In practice, this should only happen for simple devices that don't * In practice, this should only happen for simple devices that don't
@@ -594,14 +596,14 @@ static uint8_t Read_Properties(
if (pPropList != NULL) { if (pPropList != NULL) {
Property_List_Length = PropertyListStruct.Required.count; Property_List_Length = PropertyListStruct.Required.count;
} else { } else {
fprintf(stdout, " -- Just Minimal Properties: \r\n" ); fprintf(stdout, " -- Just Minimal Properties: \r\n");
pPropList = MinimalPropList; pPropList = MinimalPropList;
Property_List_Length = MINIMAL_PROPLIST_SIZE -1; Property_List_Length = MINIMAL_PROPLIST_SIZE - 1;
} }
/* Copy this list for later one-by-one processing */ /* Copy this list for later one-by-one processing */
for ( i = 0; i < Property_List_Length; i++ ) for (i = 0; i < Property_List_Length; i++)
Property_List[i] = pPropList[i]; Property_List[i] = pPropList[i];
Property_List[i] = -1; /* Just to be sure we terminate */ Property_List[i] = -1; /* Just to be sure we terminate */
} else } else
pPropList = Property_List; pPropList = Property_List;
@@ -622,7 +624,7 @@ static uint8_t Read_Properties(
array_index = BACNET_ARRAY_ALL; array_index = BACNET_ARRAY_ALL;
switch (prop) { switch (prop) {
/* These are all potentially long arrays, so they may abort */ /* These are all potentially long arrays, so they may abort */
case PROP_OBJECT_LIST: case PROP_OBJECT_LIST:
case PROP_STATE_TEXT: case PROP_STATE_TEXT:
case PROP_STRUCTURED_OBJECT_LIST: case PROP_STRUCTURED_OBJECT_LIST:
@@ -736,10 +738,13 @@ void PrintUsage(
printf("Usage: \r\n"); printf("Usage: \r\n");
printf(" bacepics [-v] [-p sport] [-t target_mac] device-instance \r\n"); printf(" bacepics [-v] [-p sport] [-t target_mac] device-instance \r\n");
printf(" -v: show values instead of '?' \r\n"); printf(" -v: show values instead of '?' \r\n");
printf(" -p: Use sport for \"my\" port, instead of 0xBAC0 (BACnet/IP only) \r\n"); printf
(" -p: Use sport for \"my\" port, instead of 0xBAC0 (BACnet/IP only) \r\n");
printf(" Allows you to communicate with a localhost target. \r\n"); printf(" Allows you to communicate with a localhost target. \r\n");
printf(" -t: declare target's MAC instead of using Who-Is to bind to \r\n"); printf
printf(" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n"); (" -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("\r\n"); printf("\r\n");
printf("Insert the output in your EPICS file as the last section: \r\n"); printf("Insert the output in your EPICS file as the last section: \r\n");
printf("\"List of Objects in test device:\" \r\n"); printf("\"List of Objects in test device:\" \r\n");
@@ -766,40 +771,38 @@ int CheckCommandLineArgs(
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
char *anArg = argv[i]; char *anArg = argv[i];
if (anArg[0] == '-') { if (anArg[0] == '-') {
switch ( anArg[1] ) switch (anArg[1]) {
{ case 'v':
case 'v': ShowValues = true;
ShowValues = true; break;
break; case 'p':
case 'p': if (++i < argc)
if ( ++i < argc ) My_BIP_Port = (uint16_t) strtol(argv[i], NULL, 0);
My_BIP_Port = (uint16_t) strtol(argv[i], NULL, 0); /* Used strtol so sport can be either 0xBAC0 or 47808 */
/* Used strtol so sport can be either 0xBAC0 or 47808 */ break;
break; case 't':
case 't': if (++i < argc) {
if ( ++i < argc ) uint8_t *mac = Target_Address.mac;
{ /* The %hhx specifies unsigned char */
uint8_t *mac = Target_Address.mac; Target_Address.mac_len =
/* The %hhx specifies unsigned char */ sscanf(argv[i], "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
Target_Address.mac_len = sscanf( argv[i], &mac[0], &mac[1], &mac[2], &mac[3], &mac[4],
"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mac[0], &mac[5]);
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); if (Target_Address.mac_len == 6) { /* success */
if ( Target_Address.mac_len == 6 ) /* success */ Target_Address.net = 0;
{ Target_Address.len = 0; /* No src address */
Target_Address.net = 0; Provided_Targ_MAC = true;
Target_Address.len = 0; /* No src address */ break;
Provided_Targ_MAC = true; } else
break; printf("ERROR: invalid Target MAC %s \r\n",
argv[i]);
/* And fall through to PrintUsage */
} }
else /* Either break or fall through, as above */
printf( "ERROR: invalid Target MAC %s \r\n", argv[i] ); /* break; */
/* And fall through to PrintUsage */ default:
} PrintUsage();
/* Either break or fall through, as above */ break;
/* break; */
default:
PrintUsage();
break;
} }
} else { } else {
/* decode the Target Device Instance parameter */ /* decode the Target Device Instance parameter */
@@ -822,7 +825,9 @@ int CheckCommandLineArgs(
} }
/* Initialize fields for a new Object */ /* Initialize fields for a new Object */
void StartNextObject( BACNET_READ_ACCESS_DATA *rpm_object, BACNET_OBJECT_ID *pNewObject ) void StartNextObject(
BACNET_READ_ACCESS_DATA * rpm_object,
BACNET_OBJECT_ID * pNewObject)
{ {
BACNET_PROPERTY_REFERENCE *rpm_property; BACNET_PROPERTY_REFERENCE *rpm_property;
Error_Detected = false; Error_Detected = false;
@@ -879,8 +884,8 @@ int main(
* (eg) we could talk to a BACnet/IP device on our same interface. * (eg) we could talk to a BACnet/IP device on our same interface.
* My_BIP_Port will be non-zero in this case. * My_BIP_Port will be non-zero in this case.
*/ */
if ( My_BIP_Port > 0 ) if (My_BIP_Port > 0)
bip_set_port( My_BIP_Port ); bip_set_port(My_BIP_Port);
address_init(); address_init();
Init_Service_Handlers(); Init_Service_Handlers();
dlenv_init(); dlenv_init();
@@ -889,19 +894,19 @@ int main(
current_seconds = time(NULL); current_seconds = time(NULL);
timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
if ( My_BIP_Port > 0 ) if (My_BIP_Port > 0)
bip_set_port( 0xBAC0 ); /* Set back to std BACnet/IP port */ bip_set_port(0xBAC0); /* Set back to std BACnet/IP port */
/* try to bind with the target device */ /* try to bind with the target device */
found = found =
address_bind_request(Target_Device_Object_Instance, &max_apdu, address_bind_request(Target_Device_Object_Instance, &max_apdu,
&Target_Address); &Target_Address);
if (!found) { if (!found) {
if ( Provided_Targ_MAC ) { if (Provided_Targ_MAC) {
/* Update by adding the MAC address */ /* Update by adding the MAC address */
if ( max_apdu == 0 ) if (max_apdu == 0)
max_apdu = MAX_APDU; /* Whatever set for this datalink. */ max_apdu = MAX_APDU; /* Whatever set for this datalink. */
address_add_binding( Target_Device_Object_Instance, max_apdu, address_add_binding(Target_Device_Object_Instance, max_apdu,
&Target_Address); &Target_Address);
} else { } else {
Send_WhoIs(Target_Device_Object_Instance, Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance); Target_Device_Object_Instance);
@@ -947,8 +952,7 @@ int main(
} }
/* else, loop back and try again */ /* else, loop back and try again */
continue; continue;
} else } else {
{
myState = GET_ALL_REQUEST; myState = GET_ALL_REQUEST;
rpm_object = calloc(1, sizeof(BACNET_READ_ACCESS_DATA)); rpm_object = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
assert(rpm_object); assert(rpm_object);
@@ -959,10 +963,10 @@ int main(
case GET_LIST_OF_ALL_REQUEST: /* differs in ArrayIndex only */ case GET_LIST_OF_ALL_REQUEST: /* differs in ArrayIndex only */
/* Update times; aids single-step debugging */ /* Update times; aids single-step debugging */
last_seconds = current_seconds; last_seconds = current_seconds;
StartNextObject( rpm_object, &myObject ); StartNextObject(rpm_object, &myObject);
invoke_id = invoke_id =
Send_Read_Property_Multiple_Request(buffer, MAX_PDU, Send_Read_Property_Multiple_Request(buffer, MAX_PDU,
Target_Device_Object_Instance, rpm_object); Target_Device_Object_Instance, rpm_object);
if (invoke_id > 0) { if (invoke_id > 0) {
if (myState == GET_LIST_OF_ALL_REQUEST) if (myState == GET_LIST_OF_ALL_REQUEST)
myState = GET_LIST_OF_ALL_RESPONSE; myState = GET_LIST_OF_ALL_RESPONSE;
@@ -999,8 +1003,8 @@ int main(
invoke_id = 0; invoke_id = 0;
if (Error_Detected) { /* The normal case for Device Object */ if (Error_Detected) { /* The normal case for Device Object */
/* Was it because the Device can't do RPM? */ /* Was it because the Device can't do RPM? */
if ( Last_Error_Code == ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE ) if (Last_Error_Code ==
{ ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) {
Has_RPM = false; Has_RPM = false;
myState = GET_PROPERTY_REQUEST; myState = GET_PROPERTY_REQUEST;
} }
@@ -1008,13 +1012,11 @@ int main(
else if (myState == GET_ALL_RESPONSE) else if (myState == GET_ALL_RESPONSE)
myState = GET_LIST_OF_ALL_REQUEST; myState = GET_LIST_OF_ALL_REQUEST;
/* Else drop back to RP. */ /* Else drop back to RP. */
else else {
{
myState = GET_PROPERTY_REQUEST; myState = GET_PROPERTY_REQUEST;
StartNextObject( rpm_object, &myObject ); StartNextObject(rpm_object, &myObject);
} }
} } else if (Has_RPM)
else if ( Has_RPM )
myState = GET_ALL_REQUEST; /* Let's try again */ myState = GET_ALL_REQUEST; /* Let's try again */
else else
myState = GET_PROPERTY_REQUEST; myState = GET_PROPERTY_REQUEST;
@@ -1022,7 +1024,7 @@ int main(
fprintf(stderr, "\rError: TSM Timeout!\r\n"); fprintf(stderr, "\rError: TSM Timeout!\r\n");
tsm_free_invoke_id(invoke_id); tsm_free_invoke_id(invoke_id);
invoke_id = 0; invoke_id = 0;
myState = GET_ALL_REQUEST; /* Let's try again */ myState = GET_ALL_REQUEST; /* Let's try again */
} else if (Error_Detected) { } else if (Error_Detected) {
/* Don't think we'll ever actually reach this point. */ /* Don't think we'll ever actually reach this point. */
invoke_id = 0; invoke_id = 0;
@@ -1060,8 +1062,9 @@ int main(
(invoke_id == (invoke_id ==
Read_Property_Multiple_Data.service_data.invoke_id)) { Read_Property_Multiple_Data.service_data.invoke_id)) {
Read_Property_Multiple_Data.new_data = false; Read_Property_Multiple_Data.new_data = false;
PrintReadPropertyData(Read_Property_Multiple_Data. PrintReadPropertyData
rpm_data->listOfProperties); (Read_Property_Multiple_Data.rpm_data->
listOfProperties);
if (tsm_invoke_id_free(invoke_id)) { if (tsm_invoke_id_free(invoke_id)) {
invoke_id = 0; invoke_id = 0;
} else { } else {
@@ -1088,7 +1091,7 @@ int main(
/* Walked_List_Index = Walked_List_Length = 0; */ /* Walked_List_Index = Walked_List_Length = 0; */
/* } */ /* } */
/* } */ /* } */
myState = GET_PROPERTY_REQUEST; /* Go fetch next Property */ myState = GET_PROPERTY_REQUEST; /* Go fetch next Property */
} else if (tsm_invoke_id_free(invoke_id)) { } else if (tsm_invoke_id_free(invoke_id)) {
invoke_id = 0; invoke_id = 0;
myState = GET_PROPERTY_REQUEST; myState = GET_PROPERTY_REQUEST;
@@ -1100,12 +1103,12 @@ int main(
} else { } else {
/* OK, skip this one and try the next property. */ /* OK, skip this one and try the next property. */
fprintf(stdout, " -- Failed to get "); fprintf(stdout, " -- Failed to get ");
Print_Property_Identifier( Print_Property_Identifier(pPropList
pPropList[Property_List_Index]); [Property_List_Index]);
fprintf(stdout, " \r\n"); fprintf(stdout, " \r\n");
Error_Count++; Error_Count++;
if ( ++Property_List_Index >= Property_List_Length ) if (++Property_List_Index >= Property_List_Length)
myState = NEXT_OBJECT; /* Give up and move on to the next. */ myState = NEXT_OBJECT; /* Give up and move on to the next. */
} }
} }
} else if (tsm_invoke_id_failed(invoke_id)) { } else if (tsm_invoke_id_failed(invoke_id)) {
@@ -1148,12 +1151,11 @@ int main(
/* done with all Objects, signal end of this while loop */ /* done with all Objects, signal end of this while loop */
myObject.type = MAX_BACNET_OBJECT_TYPE; myObject.type = MAX_BACNET_OBJECT_TYPE;
} }
if ( Has_RPM ) if (Has_RPM)
myState = GET_ALL_REQUEST; myState = GET_ALL_REQUEST;
else else {
{
myState = GET_PROPERTY_REQUEST; myState = GET_PROPERTY_REQUEST;
StartNextObject( rpm_object, &myObject ); StartNextObject(rpm_object, &myObject);
} }
} while (myObject.type == OBJECT_DEVICE); } while (myObject.type == OBJECT_DEVICE);
@@ -1177,8 +1179,8 @@ int main(
} while (myObject.type < MAX_BACNET_OBJECT_TYPE); } while (myObject.type < MAX_BACNET_OBJECT_TYPE);
if ( Error_Count > 0 ) if (Error_Count > 0)
fprintf(stderr, "\r-- Found %d Errors \r\n", Error_Count ); fprintf(stderr, "\r-- Found %d Errors \r\n", Error_Count);
/* Closing brace for all Objects */ /* Closing brace for all Objects */
printf("} \r\n"); printf("} \r\n");
@@ -1186,4 +1188,4 @@ int main(
return 0; return 0;
} }
/*@}*//* End group BACEPICS */ /*@} *//* End group BACEPICS */
+16 -14
View File
@@ -48,7 +48,8 @@ static uint16_t BBMD_Timer_Seconds;
* - BACNET_BBMD_TIMETOLIVE - 0..65535 seconds, defaults to 60000 * - BACNET_BBMD_TIMETOLIVE - 0..65535 seconds, defaults to 60000
* - BACNET_BBMD_ADDRESS - dotted IPv4 address * - BACNET_BBMD_ADDRESS - dotted IPv4 address
*/ */
void dlenv_register_as_foreign_device(void) void dlenv_register_as_foreign_device(
void)
{ {
#if defined(BACDL_BIP) && BBMD_ENABLED #if defined(BACDL_BIP) && BBMD_ENABLED
char *pEnv = NULL; char *pEnv = NULL;
@@ -79,8 +80,8 @@ void dlenv_register_as_foreign_device(void)
fprintf(stderr, fprintf(stderr,
"Registering with BBMD at %s:%ld for %ld seconds\n", "Registering with BBMD at %s:%ld for %ld seconds\n",
inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds); inet_ntoa(addr), bbmd_port, bbmd_timetolive_seconds);
bvlc_register_with_bbmd(bbmd_address, (uint16_t)bbmd_port, bvlc_register_with_bbmd(bbmd_address, (uint16_t) bbmd_port,
(uint16_t)bbmd_timetolive_seconds); (uint16_t) bbmd_timetolive_seconds);
BBMD_Timer_Seconds = bbmd_timetolive_seconds; BBMD_Timer_Seconds = bbmd_timetolive_seconds;
} }
} }
@@ -92,7 +93,8 @@ void dlenv_register_as_foreign_device(void)
* *
* Call this function to renew Foreign Device Registration * Call this function to renew Foreign Device Registration
*/ */
void dlenv_maintenance_timer(uint16_t elapsed_seconds) void dlenv_maintenance_timer(
uint16_t elapsed_seconds)
{ {
if (BBMD_Timer_Seconds) { if (BBMD_Timer_Seconds) {
if (BBMD_Timer_Seconds <= elapsed_seconds) { if (BBMD_Timer_Seconds <= elapsed_seconds) {
@@ -153,16 +155,16 @@ void dlenv_init(
#endif #endif
pEnv = getenv("BACNET_IP_PORT"); pEnv = getenv("BACNET_IP_PORT");
if (pEnv) { if (pEnv) {
bip_set_port((uint16_t)strtol(pEnv, NULL, 0)); bip_set_port((uint16_t) strtol(pEnv, NULL, 0));
} else { } else {
/* BIP_Port is statically initialized to 0xBAC0, /* BIP_Port is statically initialized to 0xBAC0,
* so if it is different, then it was programmatically altered, * so if it is different, then it was programmatically altered,
* and we shouldn't just stomp on it here. * and we shouldn't just stomp on it here.
* Unless it is set below 1024, since: * Unless it is set below 1024, since:
* "The range for well-known ports managed by the IANA is 0-1023." * "The range for well-known ports managed by the IANA is 0-1023."
*/ */
if ( bip_get_port() < 1024 ) if (bip_get_port() < 1024)
bip_set_port(0xBAC0); bip_set_port(0xBAC0);
} }
#elif defined(BACDL_MSTP) #elif defined(BACDL_MSTP)
pEnv = getenv("BACNET_MAX_INFO_FRAMES"); pEnv = getenv("BACNET_MAX_INFO_FRAMES");
@@ -192,7 +194,7 @@ void dlenv_init(
#endif #endif
pEnv = getenv("BACNET_APDU_TIMEOUT"); pEnv = getenv("BACNET_APDU_TIMEOUT");
if (pEnv) { if (pEnv) {
apdu_timeout_set((uint16_t)strtol(pEnv, NULL, 0)); apdu_timeout_set((uint16_t) strtol(pEnv, NULL, 0));
fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv); fprintf(stderr, "BACNET_APDU_TIMEOUT=%s\r\n", pEnv);
} else { } else {
#if defined(BACDL_MSTP) #if defined(BACDL_MSTP)
+5 -4
View File
@@ -344,8 +344,9 @@ static bool cov_send_request(
value_list[1].next = NULL; value_list[1].next = NULL;
switch (cov_subscription->monitoredObjectIdentifier.type) { switch (cov_subscription->monitoredObjectIdentifier.type) {
case OBJECT_BINARY_INPUT: case OBJECT_BINARY_INPUT:
Binary_Input_Encode_Value_List(cov_subscription-> Binary_Input_Encode_Value_List
monitoredObjectIdentifier.instance, &value_list[0]); (cov_subscription->monitoredObjectIdentifier.instance,
&value_list[0]);
break; break;
default: default:
goto COV_FAILED; goto COV_FAILED;
@@ -462,8 +463,8 @@ static bool cov_subscribe(
switch (cov_data->monitoredObjectIdentifier.type) { switch (cov_data->monitoredObjectIdentifier.type) {
case OBJECT_BINARY_INPUT: case OBJECT_BINARY_INPUT:
if (Binary_Input_Valid_Instance(cov_data-> if (Binary_Input_Valid_Instance
monitoredObjectIdentifier.instance)) { (cov_data->monitoredObjectIdentifier.instance)) {
status = status =
cov_list_subscribe(src, cov_data, error_class, error_code); cov_list_subscribe(src, cov_data, error_class, error_code);
} else { } else {
+9 -7
View File
@@ -75,7 +75,7 @@ void handler_read_property(
int apdu_len = -1; int apdu_len = -1;
int npdu_len = -1; int npdu_len = -1;
BACNET_NPDU_DATA npdu_data; BACNET_NPDU_DATA npdu_data;
bool error = true; /* assume that there is an error */ bool error = true; /* assume that there is an error */
int bytes_sent = 0; int bytes_sent = 0;
BACNET_ADDRESS my_address; BACNET_ADDRESS my_address;
@@ -85,7 +85,7 @@ void handler_read_property(
npdu_len = npdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address,
&npdu_data); &npdu_data);
if (service_data->segmented_message) { /* we don't support segmentation - send an abort */ if (service_data->segmented_message) { /* we don't support segmentation - send an abort */
rpdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
len = BACNET_STATUS_ABORT; len = BACNET_STATUS_ABORT;
#if PRINT_ENABLED #if PRINT_ENABLED
@@ -136,7 +136,7 @@ void handler_read_property(
} }
} }
RP_FAILURE: RP_FAILURE:
if (error) { if (error) {
if (len == BACNET_STATUS_ABORT) { if (len == BACNET_STATUS_ABORT) {
/* Kludge alert! At the moment we assume any abort is due to /* Kludge alert! At the moment we assume any abort is due to
@@ -153,7 +153,7 @@ void handler_read_property(
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RP: Sending Abort!\n"); fprintf(stderr, "RP: Sending Abort!\n");
#endif #endif
} else if (len == BACNET_STATUS_ERROR){ } else if (len == BACNET_STATUS_ERROR) {
apdu_len = apdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[npdu_len], bacerror_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY, service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY,
@@ -161,9 +161,11 @@ void handler_read_property(
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RP: Sending Error!\n"); fprintf(stderr, "RP: Sending Error!\n");
#endif #endif
} else if (len == BACNET_STATUS_REJECT){ } else if (len == BACNET_STATUS_REJECT) {
apdu_len = reject_encode_apdu(&Handler_Transmit_Buffer[npdu_len], apdu_len =
service_data->invoke_id, reject_convert_error_code(rpdata.error_code)); reject_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
reject_convert_error_code(rpdata.error_code));
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RP: Sending Reject!\n"); fprintf(stderr, "RP: Sending Reject!\n");
#endif #endif
+43 -35
View File
@@ -106,7 +106,7 @@ static int RPM_Encode_Property(
uint8_t * apdu, uint8_t * apdu,
uint16_t offset, uint16_t offset,
uint16_t max_apdu, uint16_t max_apdu,
BACNET_RPM_DATA *rpmdata) BACNET_RPM_DATA * rpmdata)
{ {
int len = 0; int len = 0;
size_t copy_len = 0; size_t copy_len = 0;
@@ -114,8 +114,8 @@ static int RPM_Encode_Property(
BACNET_READ_PROPERTY_DATA rpdata; BACNET_READ_PROPERTY_DATA rpdata;
len = len =
rpm_ack_encode_apdu_object_property(&Temp_Buf[0], rpmdata->object_property, rpm_ack_encode_apdu_object_property(&Temp_Buf[0],
rpmdata->array_index); rpmdata->object_property, rpmdata->array_index);
copy_len = memcopy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu); copy_len = memcopy(&apdu[0], &Temp_Buf[0], offset, len, max_apdu);
if (copy_len == 0) { if (copy_len == 0) {
rpmdata->error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata->error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
@@ -133,9 +133,9 @@ static int RPM_Encode_Property(
rpdata.application_data_len = sizeof(Temp_Buf); rpdata.application_data_len = sizeof(Temp_Buf);
len = Device_Read_Property(&rpdata); len = Device_Read_Property(&rpdata);
if (len < 0) { if (len < 0) {
if ((len == BACNET_STATUS_ABORT) || (len == BACNET_STATUS_REJECT)){ if ((len == BACNET_STATUS_ABORT) || (len == BACNET_STATUS_REJECT)) {
/* pass on aborts and rejects for now */ /* pass on aborts and rejects for now */
return len; /* Ie, Abort */ return len; /* Ie, Abort */
} }
/* error was returned - encode that for the response */ /* error was returned - encode that for the response */
len = len =
@@ -221,14 +221,14 @@ void handler_read_property_multiple(
apdu_len = apdu_len =
rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len], rpm_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id); service_data->invoke_id);
for(;;) { for (;;) {
/* Start by looking for an object ID */ /* Start by looking for an object ID */
len = len =
rpm_decode_object_id(&service_request[decode_len], rpm_decode_object_id(&service_request[decode_len],
service_len - decode_len, &rpmdata); service_len - decode_len, &rpmdata);
if (len >= 0) { /* Got one so skip to next stage */ if (len >= 0) { /* Got one so skip to next stage */
decode_len += len; decode_len += len;
} else { /* bad encoding - skip to error/reject/abort handling */ } else { /* bad encoding - skip to error/reject/abort handling */
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Bad Encoding.\n"); fprintf(stderr, "RPM: Bad Encoding.\n");
#endif #endif
@@ -243,7 +243,7 @@ void handler_read_property_multiple(
len, sizeof(Handler_Transmit_Buffer)); len, sizeof(Handler_Transmit_Buffer));
if (!copy_len) { if (!copy_len) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Response too big!\r\n"); fprintf(stderr, "RPM: Response too big!\r\n");
#endif #endif
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
@@ -252,12 +252,12 @@ void handler_read_property_multiple(
apdu_len += copy_len; apdu_len += copy_len;
/* do each property of this object of the RPM request */ /* do each property of this object of the RPM request */
for(;;) { for (;;) {
/* Fetch a property */ /* Fetch a property */
len = len =
rpm_decode_object_property(&service_request[decode_len], rpm_decode_object_property(&service_request[decode_len],
service_len - decode_len, &rpmdata); service_len - decode_len, &rpmdata);
if (len < 0) { /* bad encoding - skip to error/reject/abort handling */ if (len < 0) { /* bad encoding - skip to error/reject/abort handling */
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Bad Encoding.\n"); fprintf(stderr, "RPM: Bad Encoding.\n");
#endif #endif
@@ -276,16 +276,17 @@ void handler_read_property_multiple(
if (rpmdata.array_index != BACNET_ARRAY_ALL) { if (rpmdata.array_index != BACNET_ARRAY_ALL) {
/* No array index options for this special property. /* No array index options for this special property.
Encode error for this object property response */ Encode error for this object property response */
len = len =
rpm_ack_encode_apdu_object_property(&Temp_Buf[0], rpm_ack_encode_apdu_object_property(&Temp_Buf[0],
rpmdata.object_property, rpmdata.array_index); rpmdata.object_property, rpmdata.array_index);
copy_len = copy_len =
memcopy(&Handler_Transmit_Buffer[0], memcopy(&Handler_Transmit_Buffer[0], &Temp_Buf[0],
&Temp_Buf[0], npdu_len + apdu_len, npdu_len + apdu_len, len,
len, sizeof(Handler_Transmit_Buffer)); sizeof(Handler_Transmit_Buffer));
if (copy_len == 0) { if (copy_len == 0) {
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
goto RPM_FAILURE; goto RPM_FAILURE;
} }
@@ -295,18 +296,20 @@ void handler_read_property_multiple(
ERROR_CLASS_PROPERTY, ERROR_CLASS_PROPERTY,
ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY); ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY);
copy_len = copy_len =
memcopy(&Handler_Transmit_Buffer[0], memcopy(&Handler_Transmit_Buffer[0], &Temp_Buf[0],
&Temp_Buf[0], npdu_len + apdu_len, npdu_len + apdu_len, len,
len, sizeof(Handler_Transmit_Buffer)); sizeof(Handler_Transmit_Buffer));
if (copy_len == 0) { if (copy_len == 0) {
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
goto RPM_FAILURE; goto RPM_FAILURE;
} }
apdu_len += len; apdu_len += len;
} else { } else {
special_object_property = rpmdata.object_property; special_object_property = rpmdata.object_property;
Device_Objects_Property_List(rpmdata.object_type, &property_list); Device_Objects_Property_List(rpmdata.object_type,
&property_list);
property_count = property_count =
RPM_Object_Property_Count(&property_list, RPM_Object_Property_Count(&property_list,
special_object_property); special_object_property);
@@ -314,7 +317,8 @@ void handler_read_property_multiple(
/* handle the error code - but use the special property */ /* handle the error code - but use the special property */
len = len =
RPM_Encode_Property(&Handler_Transmit_Buffer[0], RPM_Encode_Property(&Handler_Transmit_Buffer[0],
(uint16_t)(npdu_len + apdu_len), MAX_APDU, &rpmdata); (uint16_t) (npdu_len + apdu_len), MAX_APDU,
&rpmdata);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
} else { } else {
@@ -327,8 +331,9 @@ void handler_read_property_multiple(
RPM_Object_Property(&property_list, RPM_Object_Property(&property_list,
special_object_property, index); special_object_property, index);
len = len =
RPM_Encode_Property(&Handler_Transmit_Buffer[0], RPM_Encode_Property(&Handler_Transmit_Buffer
(uint16_t)(npdu_len + apdu_len), MAX_APDU, &rpmdata); [0], (uint16_t) (npdu_len + apdu_len),
MAX_APDU, &rpmdata);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
} else { } else {
@@ -342,7 +347,8 @@ void handler_read_property_multiple(
/* handle an individual property */ /* handle an individual property */
len = len =
RPM_Encode_Property(&Handler_Transmit_Buffer[0], RPM_Encode_Property(&Handler_Transmit_Buffer[0],
(uint16_t)(npdu_len + apdu_len), sizeof(Handler_Transmit_Buffer), &rpmdata); (uint16_t) (npdu_len + apdu_len),
sizeof(Handler_Transmit_Buffer), &rpmdata);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
} else { } else {
@@ -356,20 +362,20 @@ void handler_read_property_multiple(
decode_len++; decode_len++;
len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]); len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]);
copy_len = copy_len =
memcopy(&Handler_Transmit_Buffer[npdu_len], memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
&Temp_Buf[0], apdu_len, len, apdu_len, len, sizeof(Handler_Transmit_Buffer));
sizeof(Handler_Transmit_Buffer));
if (!copy_len) { if (!copy_len) {
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
goto RPM_FAILURE; goto RPM_FAILURE;
} else { } else {
apdu_len += copy_len; apdu_len += copy_len;
} }
break; /* finished with this property list */ break; /* finished with this property list */
} }
} }
if(service_len == decode_len) /* Reached the end so finish up */ if (service_len == decode_len) /* Reached the end so finish up */
break; break;
} }
@@ -385,7 +391,7 @@ void handler_read_property_multiple(
goto RPM_FAILURE; goto RPM_FAILURE;
} }
RPM_FAILURE: RPM_FAILURE:
if (error) { if (error) {
if (error == BACNET_STATUS_ABORT) { if (error == BACNET_STATUS_ABORT) {
/* Kludge alert! At the moment we assume any abort is due to /* Kludge alert! At the moment we assume any abort is due to
@@ -402,7 +408,7 @@ void handler_read_property_multiple(
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RP: Sending Abort!\n"); fprintf(stderr, "RP: Sending Abort!\n");
#endif #endif
} else if (error == BACNET_STATUS_ERROR){ } else if (error == BACNET_STATUS_ERROR) {
apdu_len = apdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[npdu_len], bacerror_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_READ_PROP_MULTIPLE, service_data->invoke_id, SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
@@ -410,9 +416,11 @@ void handler_read_property_multiple(
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RP: Sending Error!\n"); fprintf(stderr, "RP: Sending Error!\n");
#endif #endif
} else if (error == BACNET_STATUS_REJECT){ } else if (error == BACNET_STATUS_REJECT) {
apdu_len = reject_encode_apdu(&Handler_Transmit_Buffer[npdu_len], apdu_len =
service_data->invoke_id, reject_convert_error_code(rpmdata.error_code)); reject_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id,
reject_convert_error_code(rpmdata.error_code));
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RP: Sending Reject!\n"); fprintf(stderr, "RP: Sending Reject!\n");
#endif #endif
+6 -6
View File
@@ -219,8 +219,8 @@ void rpm_ack_print_data(
#if PRINT_ENABLED #if PRINT_ENABLED
if (listOfProperties->propertyIdentifier < 512) { if (listOfProperties->propertyIdentifier < 512) {
fprintf(stdout, " %s: ", fprintf(stdout, " %s: ",
bactext_property_name bactext_property_name(listOfProperties->
(listOfProperties->propertyIdentifier)); propertyIdentifier));
} else { } else {
fprintf(stdout, " proprietary %u: ", fprintf(stdout, " proprietary %u: ",
(unsigned) listOfProperties->propertyIdentifier); (unsigned) listOfProperties->propertyIdentifier);
@@ -261,10 +261,10 @@ void rpm_ack_print_data(
#if PRINT_ENABLED #if PRINT_ENABLED
/* AccessError */ /* AccessError */
fprintf(stdout, "BACnet Error: %s: %s\r\n", fprintf(stdout, "BACnet Error: %s: %s\r\n",
bactext_error_class_name((int) listOfProperties->error. bactext_error_class_name((int) listOfProperties->
error_class), error.error_class),
bactext_error_code_name((int) listOfProperties->error. bactext_error_code_name((int) listOfProperties->
error_code)); error.error_code));
#endif #endif
} }
listOfProperties = listOfProperties->next; listOfProperties = listOfProperties->next;
+2 -2
View File
@@ -103,8 +103,8 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: "); fprintf(stderr, "UCOV: ");
if (pProperty_value->propertyIdentifier < 512) { if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ", fprintf(stderr, "%s ",
bactext_property_name(pProperty_value-> bactext_property_name
propertyIdentifier)); (pProperty_value->propertyIdentifier));
} else { } else {
fprintf(stderr, "proprietary %u ", fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier); pProperty_value->propertyIdentifier);
+2 -2
View File
@@ -173,8 +173,8 @@ bool WPValidateString(
(characterstring_length(&pValue->type.Character_String) == (characterstring_length(&pValue->type.Character_String) ==
0)) { 0)) {
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE; *pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (characterstring_length(&pValue->type. } else if (characterstring_length(&pValue->
Character_String) >= iMaxLen) { type.Character_String) >= iMaxLen) {
*pErrorClass = ERROR_CLASS_RESOURCES; *pErrorClass = ERROR_CLASS_RESOURCES;
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY; *pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
} else } else
+1 -1
View File
@@ -95,7 +95,7 @@ uint8_t Send_Atomic_Read_File_Stream(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+2 -1
View File
@@ -97,7 +97,8 @@ uint8_t Send_Atomic_Write_File_Stream(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len <= max_apdu) { if ((unsigned) pdu_len <= max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); &npdu_data, &Handler_Transmit_Buffer[0],
(uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -101,7 +101,7 @@ uint8_t Send_Device_Communication_Control_Request(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -118,7 +118,7 @@ uint8_t Send_Private_Transfer_Request(
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+1 -1
View File
@@ -98,7 +98,7 @@ uint8_t Send_Reinitialize_Device_Request(
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t)pdu_len); &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
+4 -2
View File
@@ -78,7 +78,9 @@ void Send_Who_Is_Router_To_Network(
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
/* encode the optional DNET portion of the packet */ /* encode the optional DNET portion of the packet */
if (dnet >= 0) { if (dnet >= 0) {
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], (uint16_t)dnet); len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) dnet);
pdu_len += len; pdu_len += len;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Send Who-Is-Router-To-Network message to %u\n", dnet); fprintf(stderr, "Send Who-Is-Router-To-Network message to %u\n", dnet);
@@ -122,7 +124,7 @@ void Send_I_Am_Router_To_Network(
fprintf(stderr, "Send I-Am-Router-To-Network message to:\n"); fprintf(stderr, "Send I-Am-Router-To-Network message to:\n");
#endif #endif
while (DNET_list[index] != -1) { while (DNET_list[index] != -1) {
dnet = (uint16_t)DNET_list[index]; dnet = (uint16_t) DNET_list[index];
len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], dnet); len = encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], dnet);
pdu_len += len; pdu_len += len;
index++; index++;
+3 -2
View File
@@ -155,8 +155,9 @@ uint8_t Send_Write_Property_Request(
#if PRINT_ENABLED_DEBUG #if PRINT_ENABLED_DEBUG
fprintf(stderr, "WriteProperty service: " "%s tag=%d\n", fprintf(stderr, "WriteProperty service: " "%s tag=%d\n",
(object_value->context_specific ? "context" : "application"), (object_value->context_specific ? "context" : "application"),
(int) (object_value->context_specific ? object_value-> (int) (object_value->
context_tag : object_value->tag)); context_specific ? object_value->context_tag : object_value->
tag));
#endif #endif
len = bacapp_encode_data(&application_data[apdu_len], object_value); len = bacapp_encode_data(&application_data[apdu_len], object_value);
if ((len + apdu_len) < MAX_APDU) { if ((len + apdu_len) < MAX_APDU) {
+1 -1
View File
@@ -232,7 +232,7 @@ static void packet_statistics_save(
} }
fprintf(stdout, "Node Count: %u\r\n", node_count); fprintf(stdout, "Node Count: %u\r\n", node_count);
fprintf(stdout, "Invalid Frame Count: %lu\r\n", fprintf(stdout, "Invalid Frame Count: %lu\r\n",
(long unsigned int)Invalid_Frame_Count); (long unsigned int) Invalid_Frame_Count);
} }
static void packet_statistics_clear( static void packet_statistics_clear(
+6 -6
View File
@@ -367,8 +367,8 @@ int Analog_Output_Read_Property(
apdu_len = encode_application_null(&apdu[0]); apdu_len = encode_application_null(&apdu[0]);
else { else {
real_value = real_value =
Analog_Output_Level[object_index][rpdata-> Analog_Output_Level[object_index]
array_index - 1]; [rpdata->array_index - 1];
apdu_len = apdu_len =
encode_application_real(&apdu[0], real_value); encode_application_real(&apdu[0], real_value);
} }
@@ -442,11 +442,11 @@ bool Analog_Output_Write_Property(
if (status) { if (status) {
level = AO_LEVEL_NULL; level = AO_LEVEL_NULL;
object_index = object_index =
Analog_Output_Instance_To_Index(wp_data-> Analog_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
status = status =
Analog_Output_Present_Value_Relinquish(wp_data-> Analog_Output_Present_Value_Relinquish
object_instance, wp_data->priority); (wp_data->object_instance, wp_data->priority);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
+4 -4
View File
@@ -316,8 +316,8 @@ int Analog_Value_Read_Property(
apdu_len = encode_application_null(&apdu[0]); apdu_len = encode_application_null(&apdu[0]);
else { else {
real_value = real_value =
Analog_Value_Level[object_index][rpdata-> Analog_Value_Level[object_index]
array_index - 1]; [rpdata->array_index - 1];
apdu_len = apdu_len =
encode_application_real(&apdu[0], real_value); encode_application_real(&apdu[0], real_value);
} }
@@ -392,8 +392,8 @@ bool Analog_Value_Write_Property(
if (status) { if (status) {
level = ANALOG_LEVEL_NULL; level = ANALOG_LEVEL_NULL;
object_index = object_index =
Analog_Value_Instance_To_Index(wp_data-> Analog_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
+1 -1
View File
@@ -369,7 +369,7 @@ uint32_t bacfile_instance_from_tsm(
BACNET_ADDRESS dest; /* where the original packet was destined */ BACNET_ADDRESS dest; /* where the original packet was destined */
uint8_t apdu[MAX_PDU] = { 0 }; /* original APDU packet */ uint8_t apdu[MAX_PDU] = { 0 }; /* original APDU packet */
uint16_t apdu_len = 0; /* original APDU packet length */ uint16_t apdu_len = 0; /* original APDU packet length */
int len = 0; /* apdu header length */ int len = 0; /* apdu header length */
BACNET_ATOMIC_READ_FILE_DATA data = { 0 }; BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */ uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */
bool found = false; bool found = false;
+6 -6
View File
@@ -297,8 +297,8 @@ int Binary_Output_Read_Property(
apdu_len = encode_application_null(&apdu[apdu_len]); apdu_len = encode_application_null(&apdu[apdu_len]);
else { else {
present_value = present_value =
Binary_Output_Level[object_index][rpdata-> Binary_Output_Level[object_index]
array_index - 1]; [rpdata->array_index - 1];
apdu_len = apdu_len =
encode_application_enumerated(&apdu[apdu_len], encode_application_enumerated(&apdu[apdu_len],
present_value); present_value);
@@ -371,8 +371,8 @@ bool Binary_Output_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated; level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index = object_index =
Binary_Output_Instance_To_Index(wp_data-> Binary_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
Binary_Output_Level[object_index][priority] = level; Binary_Output_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
@@ -398,8 +398,8 @@ bool Binary_Output_Write_Property(
if (status) { if (status) {
level = BINARY_NULL; level = BINARY_NULL;
object_index = object_index =
Binary_Output_Instance_To_Index(wp_data-> Binary_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
+8 -8
View File
@@ -285,13 +285,13 @@ int Binary_Value_Read_Property(
object_index = object_index =
Binary_Value_Instance_To_Index(rpdata->object_instance); Binary_Value_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Binary_Value_Level[object_index][rpdata-> if (Binary_Value_Level[object_index][rpdata->array_index]
array_index] == BINARY_NULL) == BINARY_NULL)
apdu_len = encode_application_null(&apdu[apdu_len]); apdu_len = encode_application_null(&apdu[apdu_len]);
else { else {
present_value = present_value =
Binary_Value_Level[object_index][rpdata-> Binary_Value_Level[object_index]
array_index]; [rpdata->array_index];
apdu_len = apdu_len =
encode_application_enumerated(&apdu[apdu_len], encode_application_enumerated(&apdu[apdu_len],
present_value); present_value);
@@ -354,8 +354,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated; level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index(wp_data-> Binary_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
Binary_Value_Level[object_index][priority] = level; Binary_Value_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
@@ -381,8 +381,8 @@ bool Binary_Value_Write_Property(
if (status) { if (status) {
level = BINARY_NULL; level = BINARY_NULL;
object_index = object_index =
Binary_Value_Instance_To_Index(wp_data-> Binary_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
+17 -16
View File
@@ -808,7 +808,7 @@ bool Device_Object_List_Identifier(
* look for the index to instance to get the ID */ * look for the index to instance to get the ID */
if (pObject->Object_Iterator) { if (pObject->Object_Iterator) {
/* First find the first object */ /* First find the first object */
temp_index = pObject->Object_Iterator(~(unsigned)0); temp_index = pObject->Object_Iterator(~(unsigned) 0);
/* Then step through the objects to find the nth */ /* Then step through the objects to find the nth */
while (object_index != 0) { while (object_index != 0) {
temp_index = pObject->Object_Iterator(temp_index); temp_index = pObject->Object_Iterator(temp_index);
@@ -1101,7 +1101,8 @@ static int Device_Read_Property_Local(
/* can we all fit into the APDU? */ /* can we all fit into the APDU? */
if ((apdu_len + len) >= MAX_APDU) { if ((apdu_len + len) >= MAX_APDU) {
/* Abort response */ /* Abort response */
rpdata->error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpdata->error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
apdu_len = BACNET_STATUS_ABORT; apdu_len = BACNET_STATUS_ABORT;
break; break;
} }
@@ -1240,8 +1241,8 @@ static bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id. (Device_Set_Object_Instance_Number(value.type.
instance))) { Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */ /* FIXME: we could send an I-Am broadcast to let the world know */
} else { } else {
status = false; status = false;
@@ -1274,8 +1275,8 @@ static bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t) value.type. Device_Set_Vendor_Identifier((uint16_t) value.
Unsigned_Int); type.Unsigned_Int);
} }
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
@@ -1302,8 +1303,8 @@ static bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false, WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Object_Name(characterstring_value(&value.type. Device_Set_Object_Name(characterstring_value(&value.
Character_String), type.Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1312,8 +1313,8 @@ static bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true, WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Location(characterstring_value(&value.type. Device_Set_Location(characterstring_value(&value.
Character_String), type.Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1323,8 +1324,8 @@ static bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true, WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Description(characterstring_value(&value.type. Device_Set_Description(characterstring_value(&value.
Character_String), type.Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1333,8 +1334,8 @@ static bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_MOD_LEN, true, WPValidateString(&value, MAX_DEV_MOD_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Model_Name(characterstring_value(&value.type. Device_Set_Model_Name(characterstring_value(&value.
Character_String), type.Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1346,8 +1347,8 @@ static bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if (value.type.Unsigned_Int <= 255) { if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames((uint8_t) value.type. dlmstp_set_max_info_frames((uint8_t) value.
Unsigned_Int); type.Unsigned_Int);
} else { } else {
status = false; status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
+10 -10
View File
@@ -469,13 +469,13 @@ int Lighting_Output_Read_Property(
object_index = object_index =
Lighting_Output_Instance_To_Index(rpdata->object_instance); Lighting_Output_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Lighting_Output_Level[object_index][rpdata-> if (Lighting_Output_Level[object_index][rpdata->array_index
array_index - 1] == LIGHTING_LEVEL_NULL) - 1] == LIGHTING_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]); apdu_len = encode_application_null(&apdu[0]);
else { else {
real_value = real_value =
Lighting_Output_Level[object_index][rpdata-> Lighting_Output_Level[object_index]
array_index - 1]; [rpdata->array_index - 1];
apdu_len = apdu_len =
encode_application_real(&apdu[0], real_value); encode_application_real(&apdu[0], real_value);
} }
@@ -550,11 +550,11 @@ bool Lighting_Output_Write_Property(
if (status) { if (status) {
level = LIGHTING_LEVEL_NULL; level = LIGHTING_LEVEL_NULL;
object_index = object_index =
Lighting_Output_Instance_To_Index(wp_data-> Lighting_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
status = status =
Lighting_Output_Present_Value_Relinquish(wp_data-> Lighting_Output_Present_Value_Relinquish
object_instance, wp_data->priority); (wp_data->object_instance, wp_data->priority);
if (wp_data->priority == 6) { if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any algorithm and may not be used for other purposes in any
@@ -581,8 +581,8 @@ bool Lighting_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Lighting_Output_Instance_To_Index(wp_data-> Lighting_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
Lighting_Output_Out_Of_Service[object_index] = Lighting_Output_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+4 -4
View File
@@ -318,8 +318,8 @@ bool Life_Safety_Point_Write_Property(
if (status) { if (status) {
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) { if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
object_index = object_index =
Life_Safety_Point_Instance_To_Index(wp_data-> Life_Safety_Point_Instance_To_Index
object_instance); (wp_data->object_instance);
Life_Safety_Point_Mode[object_index] = Life_Safety_Point_Mode[object_index] =
value.type.Enumerated; value.type.Enumerated;
} else { } else {
@@ -335,8 +335,8 @@ bool Life_Safety_Point_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Life_Safety_Point_Instance_To_Index(wp_data-> Life_Safety_Point_Instance_To_Index
object_instance); (wp_data->object_instance);
Life_Safety_Point_Out_Of_Service[object_index] = Life_Safety_Point_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+9 -9
View File
@@ -174,7 +174,7 @@ bool Multistate_Input_Present_Value_Set(
index = Multistate_Input_Instance_To_Index(object_instance); index = Multistate_Input_Instance_To_Index(object_instance);
if (index < MAX_MULTISTATE_INPUTS) { if (index < MAX_MULTISTATE_INPUTS) {
if (value < MULTISTATE_NUMBER_OF_STATES) { if (value < MULTISTATE_NUMBER_OF_STATES) {
Present_Value[index] = (uint8_t)value; Present_Value[index] = (uint8_t) value;
status = true; status = true;
} }
} }
@@ -400,8 +400,8 @@ int Multistate_Input_Read_Property(
/* if no index was specified, then try to encode the entire list */ /* if no index was specified, then try to encode the entire list */
/* into one packet. */ /* into one packet. */
object_index = object_index =
Multistate_Input_Instance_To_Index(rpdata-> Multistate_Input_Instance_To_Index
object_instance); (rpdata->object_instance);
for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) { for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance, Multistate_Input_State_Text(rpdata->object_instance,
@@ -422,8 +422,8 @@ int Multistate_Input_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Input_Instance_To_Index(rpdata-> Multistate_Input_Instance_To_Index
object_instance); (rpdata->object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) { if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance, Multistate_Input_State_Text(rpdata->object_instance,
@@ -478,8 +478,8 @@ bool Multistate_Input_Write_Property(
if (status) { if (status) {
if (Out_Of_Service[object_index]) { if (Out_Of_Service[object_index]) {
status = status =
Multistate_Input_Present_Value_Set(wp_data-> Multistate_Input_Present_Value_Set
object_instance, value.type.Unsigned_Int); (wp_data->object_instance, value.type.Unsigned_Int);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -497,8 +497,8 @@ bool Multistate_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Multistate_Input_Instance_To_Index(wp_data-> Multistate_Input_Instance_To_Index
object_instance); (wp_data->object_instance);
Out_Of_Service[object_index] = value.type.Boolean; Out_Of_Service[object_index] = value.type.Boolean;
} }
break; break;
+14 -14
View File
@@ -266,8 +266,8 @@ int Multistate_Output_Read_Property(
/* into one packet. */ /* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) { else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index = object_index =
Multistate_Output_Instance_To_Index(rpdata-> Multistate_Output_Instance_To_Index
object_instance); (rpdata->object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */ /* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] == if (Multistate_Output_Level[object_index][i] ==
@@ -292,16 +292,16 @@ int Multistate_Output_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Output_Instance_To_Index(rpdata-> Multistate_Output_Instance_To_Index
object_instance); (rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Multistate_Output_Level[object_index][rpdata-> if (Multistate_Output_Level[object_index]
array_index - 1] == MULTISTATE_NULL) [rpdata->array_index - 1] == MULTISTATE_NULL)
apdu_len = encode_application_null(&apdu[0]); apdu_len = encode_application_null(&apdu[0]);
else { else {
present_value = present_value =
Multistate_Output_Level[object_index][rpdata-> Multistate_Output_Level[object_index]
array_index - 1]; [rpdata->array_index - 1];
apdu_len = apdu_len =
encode_application_unsigned(&apdu[0], encode_application_unsigned(&apdu[0],
present_value); present_value);
@@ -370,8 +370,8 @@ bool Multistate_Output_Write_Property(
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) { (value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
level = value.type.Unsigned_Int; level = value.type.Unsigned_Int;
object_index = object_index =
Multistate_Output_Instance_To_Index(wp_data-> Multistate_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
Multistate_Output_Level[object_index][priority] = Multistate_Output_Level[object_index][priority] =
(uint8_t) level; (uint8_t) level;
@@ -398,8 +398,8 @@ bool Multistate_Output_Write_Property(
if (status) { if (status) {
level = MULTISTATE_NULL; level = MULTISTATE_NULL;
object_index = object_index =
Multistate_Output_Instance_To_Index(wp_data-> Multistate_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
@@ -425,8 +425,8 @@ bool Multistate_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Multistate_Output_Instance_To_Index(wp_data-> Multistate_Output_Instance_To_Index
object_instance); (wp_data->object_instance);
Multistate_Output_Out_Of_Service[object_index] = Multistate_Output_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+32 -23
View File
@@ -731,9 +731,9 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) { if (wp_data->application_data_len != 0) {
iOffset += len; iOffset += len;
len = len =
bacapp_decode_context_data(&wp_data-> bacapp_decode_context_data(&wp_data->application_data
application_data[iOffset], wp_data->application_data_len, [iOffset], wp_data->application_data_len, &value,
&value, PROP_LOG_DEVICE_OBJECT_PROPERTY); PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || ((value.context_tag != 2) && if ((len == 0) || ((value.context_tag != 2) &&
(value.context_tag != 3))) { (value.context_tag != 3))) {
/* Bad decode or wrong tag */ /* Bad decode or wrong tag */
@@ -750,8 +750,8 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) { if (wp_data->application_data_len != 0) {
iOffset += len; iOffset += len;
len = len =
bacapp_decode_context_data(&wp_data-> bacapp_decode_context_data
application_data[iOffset], (&wp_data->application_data[iOffset],
wp_data->application_data_len, &value, wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY); PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || (value.context_tag != 3)) { if ((len == 0) || (value.context_tag != 3)) {
@@ -1044,19 +1044,19 @@ void TL_Local_Time_To_BAC(
TempTime = localtime(&SourceTime); TempTime = localtime(&SourceTime);
DestTime->date.year = (uint16_t)(TempTime->tm_year + 1900); DestTime->date.year = (uint16_t) (TempTime->tm_year + 1900);
DestTime->date.month = (uint8_t)(TempTime->tm_mon + 1); DestTime->date.month = (uint8_t) (TempTime->tm_mon + 1);
DestTime->date.day = (uint8_t)TempTime->tm_mday; DestTime->date.day = (uint8_t) TempTime->tm_mday;
/* BACnet is 1 to 7 = Monday to Sunday /* BACnet is 1 to 7 = Monday to Sunday
* Windows is days from Sunday 0 - 6 so we * Windows is days from Sunday 0 - 6 so we
* have to adjust */ * have to adjust */
if (TempTime->tm_wday == 0) if (TempTime->tm_wday == 0)
DestTime->date.wday = 7; DestTime->date.wday = 7;
else else
DestTime->date.wday = (uint8_t)TempTime->tm_wday; DestTime->date.wday = (uint8_t) TempTime->tm_wday;
DestTime->time.hour = (uint8_t)TempTime->tm_hour; DestTime->time.hour = (uint8_t) TempTime->tm_hour;
DestTime->time.min = (uint8_t)TempTime->tm_min; DestTime->time.min = (uint8_t) TempTime->tm_min;
DestTime->time.sec = (uint8_t)TempTime->tm_sec; DestTime->time.sec = (uint8_t) TempTime->tm_sec;
DestTime->time.hundredths = 0; DestTime->time.hundredths = 0;
} }
@@ -1093,8 +1093,8 @@ int rr_trend_log_encode(
pRequest->ItemCount = 0; /* Start out with nothing */ pRequest->ItemCount = 0; /* Start out with nothing */
/* Bail out now if nowt - should never happen for a Trend Log but ... */ /* Bail out now if nowt - should never happen for a Trend Log but ... */
if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)]. if (LogInfo[Trend_Log_Instance_To_Index(pRequest->
ulRecordCount == 0) object_instance)].ulRecordCount == 0)
return (0); return (0);
if ((pRequest->RequestType == RR_BY_POSITION) || if ((pRequest->RequestType == RR_BY_POSITION) ||
@@ -1555,11 +1555,17 @@ int TL_encode_entry(
* have limited to 32 bits maximum as allowed by the standard * have limited to 32 bits maximum as allowed by the standard
*/ */
bitstring_init(&TempBits); bitstring_init(&TempBits);
bitstring_set_bits_used(&TempBits, (pSource->Datum.Bits.ucLen >> 4) & 0x0F, pSource->Datum.Bits.ucLen & 0x0F); bitstring_set_bits_used(&TempBits,
for(ucCount = pSource->Datum.Bits.ucLen >> 4; ucCount > 0; ucCount--) (pSource->Datum.Bits.ucLen >> 4) & 0x0F,
bitstring_set_octet(&TempBits, ucCount - 1, pSource->Datum.Bits.ucStore[ucCount-1]); pSource->Datum.Bits.ucLen & 0x0F);
for (ucCount = pSource->Datum.Bits.ucLen >> 4; ucCount > 0;
ucCount--)
bitstring_set_octet(&TempBits, ucCount - 1,
pSource->Datum.Bits.ucStore[ucCount - 1]);
iLen += encode_context_bitstring(&apdu[iLen], pSource->ucRecType, &TempBits); iLen +=
encode_context_bitstring(&apdu[iLen], pSource->ucRecType,
&TempBits);
break; break;
case TL_TYPE_NULL: case TL_TYPE_NULL:
@@ -1627,7 +1633,7 @@ static int local_read_property(
} }
} }
if((len >= 0) && (status != NULL)){ if ((len >= 0) && (status != NULL)) {
/* Fetch the status flags if required */ /* Fetch the status flags if required */
rpdata.application_data = status; rpdata.application_data = status;
rpdata.application_data_len = MAX_APDU; rpdata.application_data_len = MAX_APDU;
@@ -1722,13 +1728,16 @@ void TL_fetch_property(
TempRec.Datum.Bits.ucLen |= TempRec.Datum.Bits.ucLen |=
(8 - (bitstring_bits_used(&TempBits) % 8)) & 7; (8 - (bitstring_bits_used(&TempBits) % 8)) & 7;
/* Fetch the octets with the bits directly */ /* Fetch the octets with the bits directly */
for(ucCount = 0; ucCount < bitstring_bytes_used(&TempBits); ucCount++) for (ucCount = 0;
TempRec.Datum.Bits.ucStore[ucCount] = bitstring_octet(&TempBits, ucCount); ucCount < bitstring_bytes_used(&TempBits); ucCount++)
TempRec.Datum.Bits.ucStore[ucCount] =
bitstring_octet(&TempBits, ucCount);
} else { } else {
/* We will only use the first 4 octets to save space */ /* We will only use the first 4 octets to save space */
TempRec.Datum.Bits.ucLen = 4 << 4; TempRec.Datum.Bits.ucLen = 4 << 4;
for(ucCount = 0; ucCount < 4; ucCount++) for (ucCount = 0; ucCount < 4; ucCount++)
TempRec.Datum.Bits.ucStore[ucCount] = bitstring_octet(&TempBits, ucCount); TempRec.Datum.Bits.ucStore[ucCount] =
bitstring_octet(&TempBits, ucCount);
} }
break; break;
+2 -2
View File
@@ -132,8 +132,8 @@ void My_Read_Property_Ack_Handler(
if (address_match(&Target_Address, src) && if (address_match(&Target_Address, src) &&
(service_data->invoke_id == Request_Invoke_ID)) { (service_data->invoke_id == Request_Invoke_ID)) {
len = rp_ack_decode_service_request( len =
service_request, service_len, &data); rp_ack_decode_service_request(service_request, service_len, &data);
if (len > 0) { if (len > 0) {
rp_ack_print_data(&data); rp_ack_print_data(&data);
} }
+1 -1
View File
@@ -185,4 +185,4 @@ int main(
} }
} }
/* @} *//* End group ServerDemo */ /* @} *//* End group ServerDemo */
+23 -24
View File
@@ -376,15 +376,14 @@ typedef enum {
PROP_BINARY_ACTIVE_VALUE = 324, PROP_BINARY_ACTIVE_VALUE = 324,
PROP_BINARY_INACTIVE_VALUE = 325, PROP_BINARY_INACTIVE_VALUE = 325,
/* enumerations 342-344 are defined in Addendum 2008-w */ /* enumerations 342-344 are defined in Addendum 2008-w */
PROP_BIT_MASK = 342, PROP_BIT_MASK = 342,
PROP_BIT_TEXT = 343, PROP_BIT_TEXT = 343,
PROP_IS_UTC = 344 PROP_IS_UTC = 344
/* The special property identifiers all, optional, and required */
/* The special property identifiers all, optional, and required */ /* are reserved for use in the ReadPropertyConditional and */
/* are reserved for use in the ReadPropertyConditional and */ /* ReadPropertyMultiple services or services not defined in this standard. */
/* ReadPropertyMultiple services or services not defined in this standard. */ /* Enumerated values 0-511 are reserved for definition by ASHRAE. */
/* Enumerated values 0-511 are reserved for definition by ASHRAE. */ /* Enumerated values 512-4194303 may be used by others subject to the */
/* Enumerated values 512-4194303 may be used by others subject to the */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
} BACNET_PROPERTY_ID; } BACNET_PROPERTY_ID;
@@ -899,25 +898,25 @@ typedef enum {
OBJECT_STRUCTURED_VIEW = 29, OBJECT_STRUCTURED_VIEW = 29,
OBJECT_ACCESS_DOOR = 30, OBJECT_ACCESS_DOOR = 30,
OBJECT_LIGHTING_OUTPUT = 31, OBJECT_LIGHTING_OUTPUT = 31,
OBJECT_ACCESS_CREDENTIAL = 32, /* Addendum 2008-j */ OBJECT_ACCESS_CREDENTIAL = 32, /* Addendum 2008-j */
OBJECT_ACCESS_POINT = 33, OBJECT_ACCESS_POINT = 33,
OBJECT_ACCESS_RIGHTS = 34, OBJECT_ACCESS_RIGHTS = 34,
OBJECT_ACCESS_USER = 35, OBJECT_ACCESS_USER = 35,
OBJECT_ACCESS_ZONE = 36, OBJECT_ACCESS_ZONE = 36,
OBJECT_CREDENTIAL_DATA_INPUT = 37, /* authentication-factor-input */ OBJECT_CREDENTIAL_DATA_INPUT = 37, /* authentication-factor-input */
OBJECT_NETWORK_SECURITY = 38, /* Addendum 2008-g */ OBJECT_NETWORK_SECURITY = 38, /* Addendum 2008-g */
OBJECT_BITSTRING_VALUE = 39, /* Addendum 2008-w */ OBJECT_BITSTRING_VALUE = 39, /* Addendum 2008-w */
OBJECT_CHARACTERSTRING_VALUE = 40, OBJECT_CHARACTERSTRING_VALUE = 40,
OBJECT_DATE_PATTERN_VALUE = 41, OBJECT_DATE_PATTERN_VALUE = 41,
OBJECT_DATE_VALUE = 42, OBJECT_DATE_VALUE = 42,
OBJECT_DATETIME_PATTERN_VALUE = 43, OBJECT_DATETIME_PATTERN_VALUE = 43,
OBJECT_DATETIME_VALUE = 44, OBJECT_DATETIME_VALUE = 44,
OBJECT_INTEGER_VALUE = 45, OBJECT_INTEGER_VALUE = 45,
OBJECT_LARGE_ANALOG_VALUE = 46, OBJECT_LARGE_ANALOG_VALUE = 46,
OBJECT_OCTETSTRING_VALUE = 47, OBJECT_OCTETSTRING_VALUE = 47,
OBJECT_POSITIVE_INTEGER_VALUE = 48, OBJECT_POSITIVE_INTEGER_VALUE = 48,
OBJECT_TIME_PATTERN_VALUE = 49, OBJECT_TIME_PATTERN_VALUE = 49,
OBJECT_TIME_VALUE = 50, OBJECT_TIME_VALUE = 50,
MAX_ASHRAE_OBJECT_TYPE = 51, MAX_ASHRAE_OBJECT_TYPE = 51,
/* used for bit string loop */ /* used for bit string loop */
+1 -1
View File
@@ -139,7 +139,7 @@ extern "C" {
* chosen at runtime from among these choices. * chosen at runtime from among these choices.
* - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN * - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN
* are not currently supported by this project. * are not currently supported by this project.
*//** @defgroup DLTemplates DataLink Template Functions *//** @defgroup DLTemplates DataLink Template Functions
* @ingroup DataLink * @ingroup DataLink
* Most of the functions in this group are function templates which are assigned * Most of the functions in this group are function templates which are assigned
* to a specific DataLink network layer implementation either at compile time or * to a specific DataLink network layer implementation either at compile time or
+1 -1
View File
@@ -101,7 +101,7 @@ extern "C" {
* These device management BIBBs prescribe the BACnet capabilities required * These device management BIBBs prescribe the BACnet capabilities required
* to interoperably perform the device management functions enumerated in * to interoperably perform the device management functions enumerated in
* 22.2.1.5 for the BACnet devices defined therein. * 22.2.1.5 for the BACnet devices defined therein.
*//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC) *//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC)
* @ingroup RDMS * @ingroup RDMS
* 16.1 DeviceCommunicationControl Service <br> * 16.1 DeviceCommunicationControl Service <br>
* The DeviceCommunicationControl service is used by a client BACnet-user to * The DeviceCommunicationControl service is used by a client BACnet-user to
+3 -3
View File
@@ -157,7 +157,7 @@ extern "C" {
uint16_t Device_Vendor_Identifier( uint16_t Device_Vendor_Identifier(
void); void);
void Device_Set_Vendor_Identifier( void Device_Set_Vendor_Identifier(
uint16_t vendor_id); uint16_t vendor_id);
const char *Device_Model_Name( const char *Device_Model_Name(
void); void);
@@ -237,11 +237,11 @@ extern "C" {
* - The interface between the implemented Objects and the BAC-stack services, * - The interface between the implemented Objects and the BAC-stack services,
* specifically the handlers, which are mediated through function calls to * specifically the handlers, which are mediated through function calls to
* the Device object. * the Device object.
*//** @defgroup ObjHelpers Object Helper Functions *//** @defgroup ObjHelpers Object Helper Functions
* @ingroup ObjFrmwk * @ingroup ObjFrmwk
* This section describes the function templates for the helper functions that * This section describes the function templates for the helper functions that
* provide common object support. * provide common object support.
*//** @defgroup ObjIntf Handler-to-Object Interface Functions *//** @defgroup ObjIntf Handler-to-Object Interface Functions
* @ingroup ObjFrmwk * @ingroup ObjFrmwk
* This section describes the fairly limited set of functions that link the * 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 * BAC-stack handlers to the BACnet Object instances. All of these calls are
+4 -2
View File
@@ -31,8 +31,10 @@ extern "C" {
void dlenv_init( void dlenv_init(
void); void);
void dlenv_register_as_foreign_device(void); void dlenv_register_as_foreign_device(
void dlenv_maintenance_timer(uint16_t elapsed_seconds); void);
void dlenv_maintenance_timer(
uint16_t elapsed_seconds);
#ifdef __cplusplus #ifdef __cplusplus
} }
+2 -2
View File
@@ -213,7 +213,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably * These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the alarm and event management functions enumerated in 22.2.1.2 * perform the alarm and event management functions enumerated in 22.2.1.2
* for the BACnet devices defined therein. * for the BACnet devices defined therein.
*//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N) *//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N)
* @ingroup ALMEVNT * @ingroup ALMEVNT
* 13.6 ConfirmedCOVNotification Service <br> * 13.6 ConfirmedCOVNotification Service <br>
* The ConfirmedCOVNotification service is used to notify subscribers about * The ConfirmedCOVNotification service is used to notify subscribers about
@@ -230,7 +230,7 @@ extern "C" {
* For unsubscribed notifications, the algorithm for determining when to issue * For unsubscribed notifications, the algorithm for determining when to issue
* this service is a local matter and may be based on a change of value, * this service is a local matter and may be based on a change of value,
* periodic updating, or some other criteria. * periodic updating, or some other criteria.
*//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK) *//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK)
* @ingroup ALMEVNT * @ingroup ALMEVNT
* 13.5 AcknowledgeAlarm Service <br> * 13.5 AcknowledgeAlarm Service <br>
* In some systems a device may need to know that an operator has seen the alarm * In some systems a device may need to know that an operator has seen the alarm
+1 -1
View File
@@ -135,7 +135,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably * These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the data sharing functions enumerated in 22.2.1.1 for the BACnet * perform the data sharing functions enumerated in 22.2.1.1 for the BACnet
* devices defined therein. * devices defined therein.
*//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP) *//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
* @ingroup DataShare * @ingroup DataShare
* 15.5 ReadProperty Service <br> * 15.5 ReadProperty Service <br>
* The ReadProperty service is used by a client BACnet-user to request the * The ReadProperty service is used by a client BACnet-user to request the
+3 -3
View File
@@ -133,7 +133,7 @@ extern "C" {
int rpm_decode_object_id( int rpm_decode_object_id(
uint8_t * apdu, uint8_t * apdu,
unsigned apdu_len, unsigned apdu_len,
BACNET_RPM_DATA *rpmdata); BACNET_RPM_DATA * rpmdata);
/* is this the end of this object property list? */ /* is this the end of this object property list? */
int rpm_decode_object_end( int rpm_decode_object_end(
@@ -144,7 +144,7 @@ extern "C" {
int rpm_decode_object_property( int rpm_decode_object_property(
uint8_t * apdu, uint8_t * apdu,
unsigned apdu_len, unsigned apdu_len,
BACNET_RPM_DATA *rpmdata); BACNET_RPM_DATA * rpmdata);
/* RPM Ack - reply from server */ /* RPM Ack - reply from server */
int rpm_ack_encode_apdu_init( int rpm_ack_encode_apdu_init(
@@ -153,7 +153,7 @@ extern "C" {
int rpm_ack_encode_apdu_object_begin( int rpm_ack_encode_apdu_object_begin(
uint8_t * apdu, uint8_t * apdu,
BACNET_RPM_DATA *rpmdata); BACNET_RPM_DATA * rpmdata);
int rpm_ack_encode_apdu_object_property( int rpm_ack_encode_apdu_object_property(
uint8_t * apdu, uint8_t * apdu,
+13 -7
View File
@@ -1,9 +1,15 @@
#!/bin/sh #!/bin/sh
# indent uses a local indent.pro file if it exists # indent uses a local indent.pro file if it exists
# File must be in consistent unix format before indenting # File must be in consistent unix format before indenting
#DOS2UNIX=/usr/bin/dos2unix
DOS2UNIX=/usr/bin/fromdos
INDENT=/usr/bin/indent
REMOVE=/bin/rm
# exit silently if utility is not installed # exit silently if utility is not installed
[ -x /usr/bin/indent ] || exit 0 [ -x ${INDENT} ] || exit 0
[ -x /usr/bin/dos2unix ] || exit 0 [ -x ${DOS2UNIX} ] || exit 0
INDENTRC=".indent.pro" INDENTRC=".indent.pro"
if [ ! -e ${INDENTRC} ] if [ ! -e ${INDENTRC} ]
@@ -16,22 +22,22 @@ directory=${1-`pwd`}
for filename in $( find $directory -name '*.c' ) for filename in $( find $directory -name '*.c' )
do do
echo Fixing DOS/Unix $filename echo Fixing DOS/Unix $filename
/usr/bin/dos2unix $filename ${DOS2UNIX} $filename
echo Indenting $filename echo Indenting $filename
/usr/bin/indent $filename ${INDENT} $filename
done done
for filename in $( find $directory -name '*.h' ) for filename in $( find $directory -name '*.h' )
do do
echo Fixing DOS/Unix $filename echo Fixing DOS/Unix $filename
/usr/bin/dos2unix $filename ${DOS2UNIX} $filename
echo Indenting $filename echo Indenting $filename
/usr/bin/indent $filename ${INDENT} $filename
done done
for filename in $( find $directory -name '*~' ) for filename in $( find $directory -name '*~' )
do do
echo Removing backup $filename echo Removing backup $filename
rm $filename ${REMOVE} $filename
done done
+2 -2
View File
@@ -355,8 +355,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real; level = (uint8_t) value.type.Real;
object_index = object_index =
Analog_Value_Instance_To_Index(wp_data-> Analog_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
Present_Value[object_index] = level; Present_Value[object_index] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
+2 -2
View File
@@ -265,8 +265,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated; level = value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index(wp_data-> Binary_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level; Present_Value[object_index] = level;
+2 -2
View File
@@ -824,8 +824,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id. (Device_Set_Object_Instance_Number(value.type.
instance))) { Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+2 -2
View File
@@ -206,8 +206,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) || if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) { (value.type.Enumerated == BINARY_INACTIVE)) {
object_index = object_index =
Binary_Value_Instance_To_Index(wp_data-> Binary_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated; (BACNET_BINARY_PV) value.type.Enumerated;
+6 -5
View File
@@ -224,11 +224,12 @@ int Device_Encode_Property_APDU(
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
break; break;
case PROP_PROTOCOL_VERSION: case PROP_PROTOCOL_VERSION:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len =
BACNET_PROTOCOL_VERSION); encode_application_unsigned(&apdu[0], BACNET_PROTOCOL_VERSION);
break; break;
case PROP_PROTOCOL_REVISION: case PROP_PROTOCOL_REVISION:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len =
encode_application_unsigned(&apdu[0],
BACNET_PROTOCOL_REVISION); BACNET_PROTOCOL_REVISION);
break; break;
case PROP_PROTOCOL_SERVICES_SUPPORTED: case PROP_PROTOCOL_SERVICES_SUPPORTED:
@@ -373,8 +374,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id. (Device_Set_Object_Instance_Number(value.type.
instance))) { Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+2 -2
View File
@@ -206,8 +206,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) || if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) { (value.type.Enumerated == BINARY_INACTIVE)) {
object_index = object_index =
Binary_Value_Instance_To_Index(wp_data-> Binary_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated; (BACNET_BINARY_PV) value.type.Enumerated;
+4 -3
View File
@@ -230,11 +230,12 @@ int Device_Encode_Property_APDU(
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
break; break;
case PROP_PROTOCOL_VERSION: case PROP_PROTOCOL_VERSION:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len =
BACNET_PROTOCOL_VERSION); encode_application_unsigned(&apdu[0], BACNET_PROTOCOL_VERSION);
break; break;
case PROP_PROTOCOL_REVISION: case PROP_PROTOCOL_REVISION:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len =
encode_application_unsigned(&apdu[0],
BACNET_PROTOCOL_REVISION); BACNET_PROTOCOL_REVISION);
break; break;
case PROP_PROTOCOL_SERVICES_SUPPORTED: case PROP_PROTOCOL_SERVICES_SUPPORTED:
+2 -2
View File
@@ -445,8 +445,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
Binary_Output_Present_Value_Set(wp_data-> Binary_Output_Present_Value_Set
object_instance, level, priority); (wp_data->object_instance, level, priority);
} else if (priority == 6) { } else if (priority == 6) {
status = false; status = false;
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
+8 -7
View File
@@ -642,11 +642,12 @@ int Device_Read_Property_Local(
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
break; break;
case PROP_PROTOCOL_VERSION: case PROP_PROTOCOL_VERSION:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len =
BACNET_PROTOCOL_VERSION); encode_application_unsigned(&apdu[0], BACNET_PROTOCOL_VERSION);
break; break;
case PROP_PROTOCOL_REVISION: case PROP_PROTOCOL_REVISION:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len =
encode_application_unsigned(&apdu[0],
BACNET_PROTOCOL_REVISION); BACNET_PROTOCOL_REVISION);
break; break;
case PROP_PROTOCOL_SERVICES_SUPPORTED: case PROP_PROTOCOL_SERVICES_SUPPORTED:
@@ -801,8 +802,8 @@ bool Device_Write_Property_Local(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id. (Device_Set_Object_Instance_Number(value.type.
instance))) { Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
@@ -862,8 +863,8 @@ bool Device_Write_Property_Local(
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
&small_length, 1); &small_length, 1);
pCharString = pCharString =
characterstring_value(&value.type. characterstring_value(&value.
Character_String); type.Character_String);
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0, eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
(uint8_t *) pCharString, length); (uint8_t *) pCharString, length);
status = true; status = true;
+2 -2
View File
@@ -218,8 +218,8 @@ typedef struct {
#if ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3)) || \ #if ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3)) || \
((__GNUC__ == 4) && (__GNUC_MINOR__ == 3) && (__GNUC_PATCHLEVEL__ < 3))) ((__GNUC__ == 4) && (__GNUC_MINOR__ == 3) && (__GNUC_PATCHLEVEL__ < 3)))
/* bug in WinAVR - not quite IAR compatible */ /* bug in WinAVR - not quite IAR compatible */
#define __EEPUT _EEPUT #define __EEPUT _EEPUT
#define __EEGET _EEGET #define __EEGET _EEGET
#endif #endif
#endif #endif
+3 -3
View File
@@ -127,7 +127,7 @@ bool timer_elapsed_minutes(
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
bool timer_elapsed_milliseconds_short( bool timer_elapsed_milliseconds_short(
struct etimer *t, struct etimer * t,
uint16_t value) uint16_t value)
{ {
uint32_t milliseconds; uint32_t milliseconds;
@@ -143,7 +143,7 @@ bool timer_elapsed_milliseconds_short(
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
bool timer_elapsed_seconds_short( bool timer_elapsed_seconds_short(
struct etimer *t, struct etimer * t,
uint16_t value) uint16_t value)
{ {
return timer_elapsed_seconds(t, value); return timer_elapsed_seconds(t, value);
@@ -155,7 +155,7 @@ bool timer_elapsed_seconds_short(
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
bool timer_elapsed_minutes_short( bool timer_elapsed_minutes_short(
struct etimer *t, struct etimer * t,
uint16_t value) uint16_t value)
{ {
return timer_elapsed_minutes(t, value); return timer_elapsed_minutes(t, value);
+2 -2
View File
@@ -320,8 +320,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real; level = (uint8_t) value.type.Real;
object_index = object_index =
Analog_Value_Instance_To_Index(wp_data-> Analog_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
Present_Value[object_index] = level; Present_Value[object_index] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
+2 -2
View File
@@ -232,8 +232,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated; level = value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index(wp_data-> Binary_Value_Instance_To_Index
object_instance); (wp_data->object_instance);
priority--; priority--;
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level; Present_Value[object_index] = level;
+2 -2
View File
@@ -505,8 +505,8 @@ bool Device_Write_Property(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type.Object_Id. (Device_Set_Object_Instance_Number(value.type.
instance))) { Object_Id.instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+6 -5
View File
@@ -126,7 +126,7 @@ int dlmstp_send_pdu(
Transmit_Packet.frame_type = Transmit_Packet.frame_type =
FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY; FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
} }
Transmit_Packet.pdu_len = (uint16_t)pdu_len; Transmit_Packet.pdu_len = (uint16_t) pdu_len;
for (i = 0; i < pdu_len; i++) { for (i = 0; i < pdu_len; i++) {
Transmit_Packet.pdu[i] = pdu[i]; Transmit_Packet.pdu[i] = pdu[i];
} }
@@ -180,7 +180,7 @@ static void dlmstp_receive_fsm_task(
(void) pArg; (void) pArg;
(void) SetThreadPriority(GetCurrentThread(), (void) SetThreadPriority(GetCurrentThread(),
THREAD_PRIORITY_TIME_CRITICAL); THREAD_PRIORITY_TIME_CRITICAL);
for(;;) { for (;;) {
/* only do receive state machine while we don't have a frame */ /* only do receive state machine while we don't have a frame */
if ((MSTP_Port.ReceivedValidFrame == false) && if ((MSTP_Port.ReceivedValidFrame == false) &&
(MSTP_Port.ReceivedInvalidFrame == false)) { (MSTP_Port.ReceivedInvalidFrame == false)) {
@@ -206,7 +206,7 @@ static void dlmstp_master_fsm_task(
(void) pArg; (void) pArg;
(void) SetThreadPriority(GetCurrentThread(), (void) SetThreadPriority(GetCurrentThread(),
THREAD_PRIORITY_TIME_CRITICAL); THREAD_PRIORITY_TIME_CRITICAL);
for(;;) { for (;;) {
switch (MSTP_Port.master_state) { switch (MSTP_Port.master_state) {
case MSTP_MASTER_STATE_IDLE: case MSTP_MASTER_STATE_IDLE:
dwMilliseconds = Tno_token; dwMilliseconds = Tno_token;
@@ -349,7 +349,7 @@ bool dlmstp_compare_data_expecting_reply(
request.address.mac[0] = src_address; request.address.mac[0] = src_address;
request.address.mac_len = 1; request.address.mac_len = 1;
offset = offset =
(uint16_t)npdu_decode(&request_pdu[0], NULL, &request.address, (uint16_t) npdu_decode(&request_pdu[0], NULL, &request.address,
&request.npdu_data); &request.npdu_data);
if (request.npdu_data.network_layer_message) { if (request.npdu_data.network_layer_message) {
return false; return false;
@@ -367,7 +367,8 @@ bool dlmstp_compare_data_expecting_reply(
/* decode the reply data */ /* decode the reply data */
bacnet_address_copy(&reply.address, dest_address); bacnet_address_copy(&reply.address, dest_address);
offset = offset =
(uint16_t)npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data); (uint16_t) npdu_decode(&reply_pdu[0], &reply.address, NULL,
&reply.npdu_data);
if (reply.npdu_data.network_layer_message) { if (reply.npdu_data.network_layer_message) {
return false; return false;
} }
+2 -1
View File
@@ -94,9 +94,10 @@ void strupper(
{ {
char *p; char *p;
for (p = str; *p != '\0'; ++p) { for (p = str; *p != '\0'; ++p) {
*p = (char)toupper(*p); *p = (char) toupper(*p);
} }
} }
#pragma #pragma
/**************************************************************************** /****************************************************************************
+1 -1
View File
@@ -70,7 +70,7 @@ BACNET_ABORT_REASON abort_convert_error_code(
break; break;
} }
return(abort_code); return (abort_code);
} }
/* encode service */ /* encode service */
+6 -4
View File
@@ -149,7 +149,8 @@ struct Address_Cache_Entry *address_remove_oldest(
pMatch = Address_Cache; pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { 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) { BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
ulTime = pMatch->TimeToLive; ulTime = pMatch->TimeToLive;
@@ -168,7 +169,8 @@ struct Address_Cache_Entry *address_remove_oldest(
/* Second pass - try in use and un bound as last resort */ /* Second pass - try in use and un bound as last resort */
pMatch = Address_Cache; pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { 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_STATIC)) ==
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) { ((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
@@ -222,7 +224,7 @@ void address_file_init(
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.mac_len = (uint8_t) count; src.mac_len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) { for (index = 0; index < MAX_MAC_LEN; index++) {
src.mac[index] = (uint8_t)mac[index]; src.mac[index] = (uint8_t) mac[index];
} }
src.net = (uint16_t) snet; src.net = (uint16_t) snet;
if (snet) { if (snet) {
@@ -231,7 +233,7 @@ void address_file_init(
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.len = (uint8_t) count; src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) { for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = (uint8_t)mac[index]; src.adr[index] = (uint8_t) mac[index];
} }
} else { } else {
src.len = 0; src.len = 0;
+6 -4
View File
@@ -211,7 +211,8 @@ bool apdu_service_supported_to_index(
} }
/* Confirmed ACK Function Handlers */ /* Confirmed ACK Function Handlers */
static confirmed_ack_function Confirmed_ACK_Function[MAX_BACNET_CONFIRMED_SERVICE]; static confirmed_ack_function
Confirmed_ACK_Function[MAX_BACNET_CONFIRMED_SERVICE];
void apdu_set_confirmed_simple_ack_handler( void apdu_set_confirmed_simple_ack_handler(
BACNET_CONFIRMED_SERVICE service_choice, BACNET_CONFIRMED_SERVICE service_choice,
@@ -238,7 +239,8 @@ void apdu_set_confirmed_simple_ack_handler(
case SERVICE_CONFIRMED_VT_CLOSE: case SERVICE_CONFIRMED_VT_CLOSE:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_REQUEST_KEY: case SERVICE_CONFIRMED_REQUEST_KEY:
Confirmed_ACK_Function[service_choice] = (confirmed_ack_function)pFunction; Confirmed_ACK_Function[service_choice] =
(confirmed_ack_function) pFunction;
break; break;
default: default:
break; break;
@@ -366,7 +368,7 @@ void apdu_handler(
uint8_t service_choice = 0; uint8_t service_choice = 0;
uint8_t *service_request = NULL; uint8_t *service_request = NULL;
uint16_t service_request_len = 0; uint16_t service_request_len = 0;
int len = 0; /* counts where we are in PDU */ int len = 0; /* counts where we are in PDU */
uint8_t tag_number = 0; uint8_t tag_number = 0;
uint32_t len_value = 0; uint32_t len_value = 0;
uint32_t error_code = 0; uint32_t error_code = 0;
@@ -458,7 +460,7 @@ void apdu_handler(
} }
service_choice = apdu[len++]; service_choice = apdu[len++];
service_request = &apdu[len]; service_request = &apdu[len];
service_request_len = apdu_len - (uint16_t)len; service_request_len = apdu_len - (uint16_t) len;
switch (service_choice) { switch (service_choice) {
case SERVICE_CONFIRMED_GET_ALARM_SUMMARY: case SERVICE_CONFIRMED_GET_ALARM_SUMMARY:
case SERVICE_CONFIRMED_GET_ENROLLMENT_SUMMARY: case SERVICE_CONFIRMED_GET_ENROLLMENT_SUMMARY:
+26 -26
View File
@@ -891,8 +891,8 @@ bool bacapp_print_value(
case PROP_OBJECT_TYPE: case PROP_OBJECT_TYPE:
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) { if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_object_type_name(value-> bactext_object_type_name(value->type.
type.Enumerated)); Enumerated));
} else if (value->type.Enumerated < 128) { } else if (value->type.Enumerated < 128) {
fprintf(stream, "reserved %lu", fprintf(stream, "reserved %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
@@ -908,8 +908,8 @@ bool bacapp_print_value(
case PROP_UNITS: case PROP_UNITS:
if (value->type.Enumerated < 256) { if (value->type.Enumerated < 256) {
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_engineering_unit_name(value->type. bactext_engineering_unit_name(value->
Enumerated)); type.Enumerated));
} else { } else {
fprintf(stream, "proprietary %lu", fprintf(stream, "proprietary %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
@@ -917,13 +917,13 @@ bool bacapp_print_value(
break; break;
case PROP_POLARITY: case PROP_POLARITY:
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_binary_polarity_name(value->type. bactext_binary_polarity_name(value->
Enumerated)); type.Enumerated));
break; break;
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_binary_present_value_name(value->type. bactext_binary_present_value_name(value->
Enumerated)); type.Enumerated));
break; break;
case PROP_RELIABILITY: case PROP_RELIABILITY:
fprintf(stream, "%s", fprintf(stream, "%s",
@@ -931,8 +931,8 @@ bool bacapp_print_value(
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_device_status_name(value->type. bactext_device_status_name(value->
Enumerated)); type.Enumerated));
break; break;
case PROP_SEGMENTATION_SUPPORTED: case PROP_SEGMENTATION_SUPPORTED:
fprintf(stream, "%s", fprintf(stream, "%s",
@@ -1084,10 +1084,10 @@ bool bacapp_parse_application_data(
datetime_set_date(&value->type.Date, (uint16_t) year, datetime_set_date(&value->type.Date, (uint16_t) year,
(uint8_t) month, (uint8_t) day); (uint8_t) month, (uint8_t) day);
} else if (count == 4) { } else if (count == 4) {
value->type.Date.year = (uint16_t)year; value->type.Date.year = (uint16_t) year;
value->type.Date.month = (uint8_t)month; value->type.Date.month = (uint8_t) month;
value->type.Date.day = (uint8_t)day; value->type.Date.day = (uint8_t) day;
value->type.Date.wday = (uint8_t)wday; value->type.Date.wday = (uint8_t) wday;
} else { } else {
status = false; status = false;
} }
@@ -1097,18 +1097,18 @@ bool bacapp_parse_application_data(
sscanf(argv, "%d:%d:%d.%d", &hour, &min, &sec, sscanf(argv, "%d:%d:%d.%d", &hour, &min, &sec,
&hundredths); &hundredths);
if (count == 4) { if (count == 4) {
value->type.Time.hour = (uint8_t)hour; value->type.Time.hour = (uint8_t) hour;
value->type.Time.min = (uint8_t)min; value->type.Time.min = (uint8_t) min;
value->type.Time.sec = (uint8_t)sec; value->type.Time.sec = (uint8_t) sec;
value->type.Time.hundredths = (uint8_t)hundredths; value->type.Time.hundredths = (uint8_t) hundredths;
} else if (count == 3) { } else if (count == 3) {
value->type.Time.hour = (uint8_t)hour; value->type.Time.hour = (uint8_t) hour;
value->type.Time.min = (uint8_t)min; value->type.Time.min = (uint8_t) min;
value->type.Time.sec = (uint8_t)sec; value->type.Time.sec = (uint8_t) sec;
value->type.Time.hundredths = 0; value->type.Time.hundredths = 0;
} else if (count == 2) { } else if (count == 2) {
value->type.Time.hour = (uint8_t)hour; value->type.Time.hour = (uint8_t) hour;
value->type.Time.min = (uint8_t)min; value->type.Time.min = (uint8_t) min;
value->type.Time.sec = 0; value->type.Time.sec = 0;
value->type.Time.hundredths = 0; value->type.Time.hundredths = 0;
} else { } else {
@@ -1118,7 +1118,7 @@ bool bacapp_parse_application_data(
case BACNET_APPLICATION_TAG_OBJECT_ID: case BACNET_APPLICATION_TAG_OBJECT_ID:
count = sscanf(argv, "%d:%d", &object_type, &instance); count = sscanf(argv, "%d:%d", &object_type, &instance);
if (count == 2) { if (count == 2) {
value->type.Object_Id.type = (uint16_t)object_type; value->type.Object_Id.type = (uint16_t) object_type;
value->type.Object_Id.instance = instance; value->type.Object_Id.instance = instance;
} else { } else {
status = false; status = false;
@@ -1303,8 +1303,8 @@ void testBACnetApplicationData_Safe(
break; break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING: case BACNET_APPLICATION_TAG_CHARACTER_STRING:
characterstring_init_ansi(&input_value[i]. characterstring_init_ansi(&input_value[i].type.
type.Character_String, "Hello There!"); Character_String, "Hello There!");
break; break;
case BACNET_APPLICATION_TAG_BIT_STRING: case BACNET_APPLICATION_TAG_BIT_STRING:
+32 -32
View File
@@ -237,32 +237,32 @@ INDTEXT_DATA bacnet_object_type_names[] = {
{OBJECT_CREDENTIAL_DATA_INPUT, "Credential Data Input"} {OBJECT_CREDENTIAL_DATA_INPUT, "Credential Data Input"}
, ,
{OBJECT_NETWORK_SECURITY, "Network Security"} {OBJECT_NETWORK_SECURITY, "Network Security"}
, ,
{OBJECT_BITSTRING_VALUE, "Bitstring Value"} {OBJECT_BITSTRING_VALUE, "Bitstring Value"}
, ,
{OBJECT_CHARACTERSTRING_VALUE, "Characterstring Value"} {OBJECT_CHARACTERSTRING_VALUE, "Characterstring Value"}
, ,
{OBJECT_DATE_PATTERN_VALUE, "Date Pattern Value"} {OBJECT_DATE_PATTERN_VALUE, "Date Pattern Value"}
, ,
{OBJECT_DATE_VALUE, "Date Value"} {OBJECT_DATE_VALUE, "Date Value"}
, ,
{OBJECT_DATETIME_PATTERN_VALUE, "Datetime Pattern Value"} {OBJECT_DATETIME_PATTERN_VALUE, "Datetime Pattern Value"}
, ,
{OBJECT_DATETIME_VALUE, "Datetime Value"} {OBJECT_DATETIME_VALUE, "Datetime Value"}
, ,
{OBJECT_INTEGER_VALUE, "Integer Value"} {OBJECT_INTEGER_VALUE, "Integer Value"}
, ,
{OBJECT_LARGE_ANALOG_VALUE, "Large Analog Value"} {OBJECT_LARGE_ANALOG_VALUE, "Large Analog Value"}
, ,
{OBJECT_OCTETSTRING_VALUE, "Octetstring Value"} {OBJECT_OCTETSTRING_VALUE, "Octetstring Value"}
, ,
{OBJECT_POSITIVE_INTEGER_VALUE, "Positive Integer Value"} {OBJECT_POSITIVE_INTEGER_VALUE, "Positive Integer Value"}
, ,
{OBJECT_TIME_PATTERN_VALUE, "Time Pattern Value"} {OBJECT_TIME_PATTERN_VALUE, "Time Pattern Value"}
, ,
{OBJECT_TIME_VALUE, "Time Value"} {OBJECT_TIME_VALUE, "Time Value"}
, ,
{0, NULL} {0, NULL}
/* Enumerated values 0-127 are reserved for definition by ASHRAE. /* Enumerated values 0-127 are reserved for definition by ASHRAE.
Enumerated values 128-1023 may be used by others subject to Enumerated values 128-1023 may be used by others subject to
the procedures and constraints described in Clause 23. */ the procedures and constraints described in Clause 23. */
@@ -940,12 +940,12 @@ INDTEXT_DATA bacnet_property_names[] = {
, ,
{PROP_BINARY_INACTIVE_VALUE, "binary-inactive-value"} {PROP_BINARY_INACTIVE_VALUE, "binary-inactive-value"}
, ,
{PROP_BIT_MASK, "bit-mask"} {PROP_BIT_MASK, "bit-mask"}
, ,
{PROP_BIT_TEXT, "bit-text"} {PROP_BIT_TEXT, "bit-text"}
, ,
{PROP_IS_UTC, "is-utc"} {PROP_IS_UTC, "is-utc"}
, ,
{0, NULL} {0, NULL}
/* Enumerated values 0-511 are reserved for definition by ASHRAE. /* Enumerated values 0-511 are reserved for definition by ASHRAE.
+23 -19
View File
@@ -206,7 +206,7 @@ int bvlc_encode_write_bdt_init(
/* The 2-octet BVLC Length field is the length, in octets, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ length field itself, most significant octet first. */
BVLC_length = 4 + (uint16_t)(entries * 10); BVLC_length = 4 + (uint16_t) (entries * 10);
encode_unsigned16(&pdu[2], BVLC_length); encode_unsigned16(&pdu[2], BVLC_length);
len = 4; len = 4;
} }
@@ -245,7 +245,7 @@ static int bvlc_encode_read_bdt_ack_init(
/* The 2-octet BVLC Length field is the length, in octets, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ length field itself, most significant octet first. */
BVLC_length = 4 + (uint16_t)(entries * 10); BVLC_length = 4 + (uint16_t) (entries * 10);
encode_unsigned16(&pdu[2], BVLC_length); encode_unsigned16(&pdu[2], BVLC_length);
len = 4; len = 4;
} }
@@ -370,7 +370,7 @@ static int bvlc_encode_read_fdt_ack_init(
/* The 2-octet BVLC Length field is the length, in octets, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ length field itself, most significant octet first. */
BVLC_length = 4 + (uint16_t)(entries * 10); BVLC_length = 4 + (uint16_t) (entries * 10);
encode_unsigned16(&pdu[2], BVLC_length); encode_unsigned16(&pdu[2], BVLC_length);
len = 4; len = 4;
} }
@@ -408,7 +408,7 @@ static int bvlc_encode_read_fdt_ack(
pdu_len += len; pdu_len += len;
len = encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live); len = encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live);
pdu_len += len; pdu_len += len;
seconds_remaining = (uint16_t)FD_Table[i].seconds_remaining; seconds_remaining = (uint16_t) FD_Table[i].seconds_remaining;
len = encode_unsigned16(&pdu[pdu_len], seconds_remaining); len = encode_unsigned16(&pdu[pdu_len], seconds_remaining);
pdu_len += len; pdu_len += len;
} }
@@ -455,7 +455,7 @@ int bvlc_encode_original_unicast_npdu(
/* The 2-octet BVLC Length field is the length, in octets, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ length field itself, most significant octet first. */
BVLC_length = 4 + (uint16_t)npdu_length; BVLC_length = 4 + (uint16_t) npdu_length;
len = encode_unsigned16(&pdu[2], BVLC_length) + 2; len = encode_unsigned16(&pdu[2], BVLC_length) + 2;
for (i = 0; i < npdu_length; i++) { for (i = 0; i < npdu_length; i++) {
pdu[len] = npdu[i]; pdu[len] = npdu[i];
@@ -481,7 +481,7 @@ int bvlc_encode_original_broadcast_npdu(
/* The 2-octet BVLC Length field is the length, in octets, /* The 2-octet BVLC Length field is the length, in octets,
of the entire BVLL message, including the two octets of the of the entire BVLL message, including the two octets of the
length field itself, most significant octet first. */ length field itself, most significant octet first. */
BVLC_length = 4 + (uint16_t)npdu_length; BVLC_length = 4 + (uint16_t) npdu_length;
len = encode_unsigned16(&pdu[2], BVLC_length) + 2; len = encode_unsigned16(&pdu[2], BVLC_length) + 2;
for (i = 0; i < npdu_length; i++) { for (i = 0; i < npdu_length; i++) {
pdu[len] = npdu[i]; pdu[len] = npdu[i];
@@ -507,7 +507,7 @@ static void bvlc_internet_to_bacnet_address(
len = encode_unsigned32(&src->mac[0], address); len = encode_unsigned32(&src->mac[0], address);
port = ntohs(sin->sin_port); port = ntohs(sin->sin_port);
len += encode_unsigned16(&src->mac[4], port); len += encode_unsigned16(&src->mac[4], port);
src->mac_len = (uint8_t)len; src->mac_len = (uint8_t) len;
src->net = 0; src->net = 0;
src->len = 0; src->len = 0;
} }
@@ -668,7 +668,8 @@ static void bvlc_bdt_forward_npdu(
unsigned i = 0; /* loop counter */ unsigned i = 0; /* loop counter */
struct sockaddr_in bip_dest = { 0 }; struct sockaddr_in bip_dest = { 0 };
mtu_len = (uint16_t)bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length); mtu_len =
(uint16_t) bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length);
/* loop through the BDT and send one to each entry, except us */ /* loop through the BDT and send one to each entry, except us */
for (i = 0; i < MAX_BBMD_ENTRIES; i++) { for (i = 0; i < MAX_BBMD_ENTRIES; i++) {
if (BBMD_Table[i].valid) { if (BBMD_Table[i].valid) {
@@ -677,8 +678,8 @@ static void bvlc_bdt_forward_npdu(
mask in the BDT entry and logically ORing it with the mask in the BDT entry and logically ORing it with the
BBMD address of the same entry. */ BBMD address of the same entry. */
bip_dest.sin_addr.s_addr = bip_dest.sin_addr.s_addr =
htonl(((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i]. htonl(((~BBMD_Table[i].broadcast_mask.
dest_address.s_addr)); s_addr) | BBMD_Table[i].dest_address.s_addr));
bip_dest.sin_port = htons(BBMD_Table[i].dest_port); bip_dest.sin_port = htons(BBMD_Table[i].dest_port);
/* don't send to my broadcast address and same port */ /* don't send to my broadcast address and same port */
if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr())) if ((bip_dest.sin_addr.s_addr == htonl(bip_get_broadcast_addr()))
@@ -710,7 +711,8 @@ static void bvlc_forward_npdu(
uint16_t mtu_len = 0; uint16_t mtu_len = 0;
struct sockaddr_in bip_dest = { 0 }; struct sockaddr_in bip_dest = { 0 };
mtu_len = (uint16_t)bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length); mtu_len =
(uint16_t) bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, npdu_length);
bip_dest.sin_addr.s_addr = htonl(bip_get_broadcast_addr()); bip_dest.sin_addr.s_addr = htonl(bip_get_broadcast_addr());
bip_dest.sin_port = htons(bip_get_port()); bip_dest.sin_port = htons(bip_get_port());
bvlc_send_mpdu(&bip_dest, mtu, mtu_len); bvlc_send_mpdu(&bip_dest, mtu, mtu_len);
@@ -727,7 +729,8 @@ static void bvlc_fdt_forward_npdu(
unsigned i = 0; /* loop counter */ unsigned i = 0; /* loop counter */
struct sockaddr_in bip_dest = { 0 }; struct sockaddr_in bip_dest = { 0 };
mtu_len = (uint16_t)bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, max_npdu); mtu_len =
(uint16_t) bvlc_encode_forwarded_npdu(&mtu[0], sin, npdu, max_npdu);
/* loop through the FDT and send one to each entry */ /* loop through the FDT and send one to each entry */
for (i = 0; i < MAX_FD_ENTRIES; i++) { for (i = 0; i < MAX_FD_ENTRIES; i++) {
if (FD_Table[i].valid && FD_Table[i].seconds_remaining) { if (FD_Table[i].valid && FD_Table[i].seconds_remaining) {
@@ -769,7 +772,8 @@ void bvlc_register_with_bbmd(
Write Broadcast Distribution Table, or Write Broadcast Distribution Table, or
register with the BBMD as a Foreign Device */ register with the BBMD as a Foreign Device */
mtu_len = mtu_len =
(uint16_t)bvlc_encode_register_foreign_device(&mtu[0], time_to_live_seconds); (uint16_t) bvlc_encode_register_foreign_device(&mtu[0],
time_to_live_seconds);
bvlc_send_mpdu(&Remote_BBMD, &mtu[0], mtu_len); bvlc_send_mpdu(&Remote_BBMD, &mtu[0], mtu_len);
} }
@@ -780,7 +784,7 @@ static void bvlc_send_result(
uint8_t mtu[MAX_MPDU] = { 0 }; uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 0; uint16_t mtu_len = 0;
mtu_len = (uint16_t)bvlc_encode_bvlc_result(&mtu[0], result_code); mtu_len = (uint16_t) bvlc_encode_bvlc_result(&mtu[0], result_code);
bvlc_send_mpdu(dest, mtu, mtu_len); bvlc_send_mpdu(dest, mtu, mtu_len);
return; return;
@@ -792,7 +796,7 @@ static int bvlc_send_bdt(
uint8_t mtu[MAX_MPDU] = { 0 }; uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 0; uint16_t mtu_len = 0;
mtu_len = (uint16_t)bvlc_encode_read_bdt_ack(&mtu[0], sizeof(mtu)); mtu_len = (uint16_t) bvlc_encode_read_bdt_ack(&mtu[0], sizeof(mtu));
if (mtu_len) { if (mtu_len) {
bvlc_send_mpdu(dest, &mtu[0], mtu_len); bvlc_send_mpdu(dest, &mtu[0], mtu_len);
} }
@@ -806,7 +810,7 @@ static int bvlc_send_fdt(
uint8_t mtu[MAX_MPDU] = { 0 }; uint8_t mtu[MAX_MPDU] = { 0 };
uint16_t mtu_len = 0; uint16_t mtu_len = 0;
mtu_len = (uint16_t)bvlc_encode_read_fdt_ack(&mtu[0], sizeof(mtu)); mtu_len = (uint16_t) bvlc_encode_read_fdt_ack(&mtu[0], sizeof(mtu));
if (mtu_len) { if (mtu_len) {
bvlc_send_mpdu(dest, &mtu[0], mtu_len); bvlc_send_mpdu(dest, &mtu[0], mtu_len);
} }
@@ -1194,11 +1198,11 @@ int bvlc_send_pdu(
} }
bvlc_dest.sin_addr.s_addr = htonl(address.s_addr); bvlc_dest.sin_addr.s_addr = htonl(address.s_addr);
bvlc_dest.sin_port = htons(port); bvlc_dest.sin_port = htons(port);
BVLC_length = (uint16_t)pdu_len + 4 /*inclusive */ ; BVLC_length = (uint16_t) pdu_len + 4 /*inclusive */ ;
mtu_len = 2; mtu_len = 2;
mtu_len += (uint16_t)encode_unsigned16(&mtu[mtu_len], BVLC_length); mtu_len += (uint16_t) encode_unsigned16(&mtu[mtu_len], BVLC_length);
memcpy(&mtu[mtu_len], pdu, pdu_len); memcpy(&mtu[mtu_len], pdu, pdu_len);
mtu_len += (uint16_t)pdu_len; mtu_len += (uint16_t) pdu_len;
return bvlc_send_mpdu(&bvlc_dest, mtu, mtu_len); return bvlc_send_mpdu(&bvlc_dest, mtu, mtu_len);
} }
+1 -1
View File
@@ -274,7 +274,7 @@ int cov_notify_decode_service_request(
decode_tag_number_and_value(&apdu[len], &tag_number, decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value); &len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value); len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->priority = (uint8_t)decoded_value; value->priority = (uint8_t) decoded_value;
} else { } else {
value->priority = BACNET_NO_PRIORITY; value->priority = BACNET_NO_PRIORITY;
} }
+1 -1
View File
@@ -485,7 +485,7 @@ int bacapp_encode_context_datetime(
len = encode_opening_tag(&apdu[apdu_len], tag_number); len = encode_opening_tag(&apdu[apdu_len], tag_number);
apdu_len += len; apdu_len += len;
len = bacapp_encode_datetime(&apdu[apdu_len], value ); len = bacapp_encode_datetime(&apdu[apdu_len], value);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], tag_number); len = encode_closing_tag(&apdu[apdu_len], tag_number);
+139 -134
View File
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], 0, encode_context_bitstring(&apdu[apdu_len], 0,
&data->notificationParams.changeOfBitstring. &data->notificationParams.
referencedBitString); changeOfBitstring.referencedBitString);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.changeOfBitstring. &data->notificationParams.
statusFlags); changeOfBitstring.statusFlags);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 0); len = encode_closing_tag(&apdu[apdu_len], 0);
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.changeOfState. &data->notificationParams.
statusFlags); changeOfState.statusFlags);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 1); len = encode_closing_tag(&apdu[apdu_len], 1);
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
case CHANGE_OF_VALUE_REAL: case CHANGE_OF_VALUE_REAL:
len = len =
encode_context_real(&apdu[apdu_len], 1, encode_context_real(&apdu[apdu_len], 1,
data->notificationParams.changeOfValue. data->notificationParams.
newValue.changeValue); changeOfValue.newValue.changeValue);
apdu_len += len; apdu_len += len;
break; break;
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], encode_context_bitstring(&apdu[apdu_len],
0, 0,
&data->notificationParams.changeOfValue. &data->notificationParams.
newValue.changedBits); changeOfValue.newValue.changedBits);
apdu_len += len; apdu_len += len;
break; break;
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.changeOfValue. &data->notificationParams.
statusFlags); changeOfValue.statusFlags);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 2); len = encode_closing_tag(&apdu[apdu_len], 2);
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
len = len =
encode_context_real(&apdu[apdu_len], 0, encode_context_real(&apdu[apdu_len], 0,
data->notificationParams.floatingLimit. data->notificationParams.
referenceValue); floatingLimit.referenceValue);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.floatingLimit. &data->notificationParams.
statusFlags); floatingLimit.statusFlags);
apdu_len += len; apdu_len += len;
len = len =
encode_context_real(&apdu[apdu_len], 2, encode_context_real(&apdu[apdu_len], 2,
data->notificationParams.floatingLimit. data->notificationParams.
setPointValue); floatingLimit.setPointValue);
apdu_len += len; apdu_len += len;
len = len =
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
len = len =
encode_context_real(&apdu[apdu_len], 0, encode_context_real(&apdu[apdu_len], 0,
data->notificationParams.outOfRange. data->notificationParams.
exceedingValue); outOfRange.exceedingValue);
apdu_len += len; apdu_len += len;
len = len =
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
len = len =
encode_context_enumerated(&apdu[apdu_len], 0, encode_context_enumerated(&apdu[apdu_len], 0,
data->notificationParams.changeOfLifeSafety. data->notificationParams.
newState); changeOfLifeSafety.newState);
apdu_len += len; apdu_len += len;
len = len =
encode_context_enumerated(&apdu[apdu_len], 1, encode_context_enumerated(&apdu[apdu_len], 1,
data->notificationParams.changeOfLifeSafety. data->notificationParams.
newMode); changeOfLifeSafety.newMode);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 2, encode_context_bitstring(&apdu[apdu_len], 2,
&data->notificationParams.changeOfLifeSafety. &data->notificationParams.
statusFlags); changeOfLifeSafety.statusFlags);
apdu_len += len; apdu_len += len;
len = len =
encode_context_enumerated(&apdu[apdu_len], 3, encode_context_enumerated(&apdu[apdu_len], 3,
data->notificationParams.changeOfLifeSafety. data->notificationParams.
operationExpected); changeOfLifeSafety.operationExpected);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 8); len = encode_closing_tag(&apdu[apdu_len], 8);
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
len = len =
bacapp_encode_context_device_obj_property_ref(&apdu bacapp_encode_context_device_obj_property_ref(&apdu
[apdu_len], 0, [apdu_len], 0,
&data->notificationParams.bufferReady. &data->notificationParams.
bufferProperty); bufferReady.bufferProperty);
apdu_len += len; apdu_len += len;
len = len =
encode_context_unsigned(&apdu[apdu_len], 1, encode_context_unsigned(&apdu[apdu_len], 1,
data->notificationParams.bufferReady. data->notificationParams.
previousNotification); bufferReady.previousNotification);
apdu_len += len; apdu_len += len;
len = len =
encode_context_unsigned(&apdu[apdu_len], 2, encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams.bufferReady. data->notificationParams.
currentNotification); bufferReady.currentNotification);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 10); len = encode_closing_tag(&apdu[apdu_len], 10);
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
len = len =
encode_context_unsigned(&apdu[apdu_len], 0, encode_context_unsigned(&apdu[apdu_len], 0,
data->notificationParams.unsignedRange. data->notificationParams.
exceedingValue); unsignedRange.exceedingValue);
apdu_len += len; apdu_len += len;
len = len =
encode_context_bitstring(&apdu[apdu_len], 1, encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.unsignedRange. &data->notificationParams.
statusFlags); unsignedRange.statusFlags);
apdu_len += len; apdu_len += len;
len = len =
encode_context_unsigned(&apdu[apdu_len], 2, encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams.unsignedRange. data->notificationParams.
exceededLimit); unsignedRange.exceededLimit);
apdu_len += len; apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 11); len = encode_closing_tag(&apdu[apdu_len], 11);
@@ -595,16 +595,18 @@ int event_notify_decode_service_request(
case EVENT_CHANGE_OF_BITSTRING: case EVENT_CHANGE_OF_BITSTRING:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0, decode_context_bitstring(&apdu[len], 0,
&data->notificationParams. &data->
changeOfBitstring.referencedBitString))) { notificationParams.changeOfBitstring.
referencedBitString))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams. &data->
changeOfBitstring.statusFlags))) { notificationParams.changeOfBitstring.
statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -615,16 +617,16 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
bacapp_decode_context_property_state(&apdu bacapp_decode_context_property_state(&apdu
[len], 0, [len], 0,
&data->notificationParams.changeOfState. &data->notificationParams.
newState))) { changeOfState.newState))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.changeOfState. &data->notificationParams.
statusFlags))) { changeOfState.statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -642,8 +644,9 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0, decode_context_bitstring(&apdu[len], 0,
&data->notificationParams. &data->
changeOfValue.newValue.changedBits))) { notificationParams.changeOfValue.
newValue.changedBits))) {
return -1; return -1;
} }
@@ -654,8 +657,9 @@ int event_notify_decode_service_request(
CHANGE_OF_VALUE_REAL)) { CHANGE_OF_VALUE_REAL)) {
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 1, decode_context_real(&apdu[len], 1,
&data->notificationParams. &data->
changeOfValue.newValue.changeValue))) { notificationParams.changeOfValue.
newValue.changeValue))) {
return -1; return -1;
} }
@@ -673,8 +677,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.changeOfValue. &data->notificationParams.
statusFlags))) { changeOfValue.statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -683,31 +687,31 @@ int event_notify_decode_service_request(
case EVENT_FLOATING_LIMIT: case EVENT_FLOATING_LIMIT:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 0, decode_context_real(&apdu[len], 0,
&data->notificationParams.floatingLimit. &data->notificationParams.
referenceValue))) { floatingLimit.referenceValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.floatingLimit. &data->notificationParams.
statusFlags))) { floatingLimit.statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 2, decode_context_real(&apdu[len], 2,
&data->notificationParams.floatingLimit. &data->notificationParams.
setPointValue))) { floatingLimit.setPointValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 3, decode_context_real(&apdu[len], 3,
&data->notificationParams.floatingLimit. &data->notificationParams.
errorLimit))) { floatingLimit.errorLimit))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -716,31 +720,31 @@ int event_notify_decode_service_request(
case EVENT_OUT_OF_RANGE: case EVENT_OUT_OF_RANGE:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 0, decode_context_real(&apdu[len], 0,
&data->notificationParams.outOfRange. &data->notificationParams.
exceedingValue))) { outOfRange.exceedingValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.outOfRange. &data->notificationParams.
statusFlags))) { outOfRange.statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 2, decode_context_real(&apdu[len], 2,
&data->notificationParams.outOfRange. &data->notificationParams.
deadband))) { outOfRange.deadband))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_real(&apdu[len], 3, decode_context_real(&apdu[len], 3,
&data->notificationParams.outOfRange. &data->notificationParams.
exceededLimit))) { outOfRange.exceededLimit))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -768,8 +772,9 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 2, decode_context_bitstring(&apdu[len], 2,
&data->notificationParams. &data->
changeOfLifeSafety.statusFlags))) { notificationParams.changeOfLifeSafety.
statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -779,8 +784,8 @@ int event_notify_decode_service_request(
&value))) { &value))) {
return -1; return -1;
} }
data->notificationParams.changeOfLifeSafety. data->notificationParams.
operationExpected = changeOfLifeSafety.operationExpected =
(BACNET_LIFE_SAFETY_OPERATION) value; (BACNET_LIFE_SAFETY_OPERATION) value;
len += section_length; len += section_length;
break; break;
@@ -789,24 +794,24 @@ int event_notify_decode_service_request(
if (-1 == (section_length = if (-1 == (section_length =
bacapp_decode_context_device_obj_property_ref bacapp_decode_context_device_obj_property_ref
(&apdu[len], 0, (&apdu[len], 0,
&data->notificationParams.bufferReady. &data->notificationParams.
bufferProperty))) { bufferReady.bufferProperty))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 1, decode_context_unsigned(&apdu[len], 1,
&data->notificationParams.bufferReady. &data->notificationParams.
previousNotification))) { bufferReady.previousNotification))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2, decode_context_unsigned(&apdu[len], 2,
&data->notificationParams.bufferReady. &data->notificationParams.
currentNotification))) { bufferReady.currentNotification))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -815,24 +820,24 @@ int event_notify_decode_service_request(
case EVENT_UNSIGNED_RANGE: case EVENT_UNSIGNED_RANGE:
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 0, decode_context_unsigned(&apdu[len], 0,
&data->notificationParams.unsignedRange. &data->notificationParams.
exceedingValue))) { unsignedRange.exceedingValue))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1, decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.unsignedRange. &data->notificationParams.
statusFlags))) { unsignedRange.statusFlags))) {
return -1; return -1;
} }
len += section_length; len += section_length;
if (-1 == (section_length = if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2, decode_context_unsigned(&apdu[len], 2,
&data->notificationParams.unsignedRange. &data->notificationParams.
exceededLimit))) { unsignedRange.exceededLimit))) {
return -1; return -1;
} }
len += section_length; len += section_length;
@@ -1091,16 +1096,16 @@ void testEventEventState(
data.eventType = EVENT_CHANGE_OF_BITSTRING; data.eventType = EVENT_CHANGE_OF_BITSTRING;
bitstring_init(&data.notificationParams.changeOfBitstring. bitstring_init(&data.notificationParams.
referencedBitString); changeOfBitstring.referencedBitString);
bitstring_set_bit(&data.notificationParams.changeOfBitstring. bitstring_set_bit(&data.notificationParams.
referencedBitString, 0, true); changeOfBitstring.referencedBitString, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfBitstring. bitstring_set_bit(&data.notificationParams.
referencedBitString, 1, false); changeOfBitstring.referencedBitString, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfBitstring. bitstring_set_bit(&data.notificationParams.
referencedBitString, 2, true); changeOfBitstring.referencedBitString, 2, true);
bitstring_set_bit(&data.notificationParams.changeOfBitstring. bitstring_set_bit(&data.notificationParams.
referencedBitString, 2, false); changeOfBitstring.referencedBitString, 2, false);
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags); bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
@@ -1186,16 +1191,16 @@ void testEventEventState(
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS; data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
bitstring_init(&data.notificationParams.changeOfValue.newValue. bitstring_init(&data.notificationParams.changeOfValue.
changedBits); newValue.changedBits);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. bitstring_set_bit(&data.notificationParams.changeOfValue.
changedBits, 0, true); newValue.changedBits, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. bitstring_set_bit(&data.notificationParams.changeOfValue.
changedBits, 1, false); newValue.changedBits, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. bitstring_set_bit(&data.notificationParams.changeOfValue.
changedBits, 2, false); newValue.changedBits, 2, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue. bitstring_set_bit(&data.notificationParams.changeOfValue.
changedBits, 3, false); newValue.changedBits, 3, false);
memset(buffer, 0, MAX_APDU); memset(buffer, 0, MAX_APDU);
inLen = event_notify_encode_service_request(&buffer[0], &data); inLen = event_notify_encode_service_request(&buffer[0], &data);
@@ -1435,12 +1440,12 @@ void testEventEventState(
data.notificationParams.bufferReady.currentNotification = 2345; data.notificationParams.bufferReady.currentNotification = 2345;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type = data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
OBJECT_DEVICE; OBJECT_DEVICE;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier. data.notificationParams.bufferReady.bufferProperty.
instance = 500; deviceIndentifier.instance = 500;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type = data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
OBJECT_ANALOG_INPUT; OBJECT_ANALOG_INPUT;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier. data.notificationParams.bufferReady.bufferProperty.
instance = 100; objectIdentifier.instance = 100;
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier = data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
PROP_PRESENT_VALUE; PROP_PRESENT_VALUE;
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0; data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
@@ -1465,34 +1470,34 @@ void testEventEventState(
ct_test(pTest, ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier. data.notificationParams.bufferReady.bufferProperty.
type == deviceIndentifier.type ==
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier. data2.notificationParams.bufferReady.bufferProperty.
type); 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, ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty. data.notificationParams.bufferReady.bufferProperty.
propertyIdentifier == deviceIndentifier.instance ==
data2.notificationParams.bufferReady.bufferProperty. data2.notificationParams.bufferReady.bufferProperty.
propertyIdentifier); 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);
ct_test(pTest, ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.arrayIndex == data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
+6 -4
View File
@@ -449,8 +449,8 @@ void MSTP_Receive_Frame_FSM(
/* NoData */ /* NoData */
else if (mstp_port->DataLength == 0) { else if (mstp_port->DataLength == 0) {
printf_receive_data("%s", printf_receive_data("%s",
mstptext_frame_type((unsigned) mstp_port-> mstptext_frame_type((unsigned)
FrameType)); mstp_port->FrameType));
if ((mstp_port->DestinationAddress == if ((mstp_port->DestinationAddress ==
mstp_port->This_Station) mstp_port->This_Station)
|| (mstp_port->DestinationAddress == || (mstp_port->DestinationAddress ==
@@ -714,7 +714,8 @@ bool MSTP_Master_Node_FSM(
uint8_t frame_type = mstp_port->OutputBuffer[2]; uint8_t frame_type = mstp_port->OutputBuffer[2];
uint8_t destination = mstp_port->OutputBuffer[3]; uint8_t destination = mstp_port->OutputBuffer[3];
RS485_Send_Frame(mstp_port, RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->OutputBuffer[0], (uint16_t)length); (uint8_t *) & mstp_port->OutputBuffer[0],
(uint16_t) length);
mstp_port->FrameCount++; mstp_port->FrameCount++;
switch (frame_type) { switch (frame_type) {
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
@@ -1049,7 +1050,8 @@ bool MSTP_Master_Node_FSM(
/* then call MSTP_Create_And_Send_Frame to transmit the reply frame */ /* then call MSTP_Create_And_Send_Frame to transmit the reply frame */
/* and enter the IDLE state to wait for the next frame. */ /* and enter the IDLE state to wait for the next frame. */
RS485_Send_Frame(mstp_port, RS485_Send_Frame(mstp_port,
(uint8_t *) & mstp_port->OutputBuffer[0], (uint16_t)length); (uint8_t *) & mstp_port->OutputBuffer[0],
(uint16_t) length);
mstp_port->master_state = MSTP_MASTER_STATE_IDLE; mstp_port->master_state = MSTP_MASTER_STATE_IDLE;
} else { } else {
/* DeferredReply */ /* DeferredReply */
+2 -2
View File
@@ -139,7 +139,7 @@ int ptransfer_decode_service_request(
return -1; return -1;
} }
len = decode_len; len = decode_len;
private_data->vendorID = (uint16_t)unsigned_value; private_data->vendorID = (uint16_t) unsigned_value;
/* Tag 1: serviceNumber */ /* Tag 1: serviceNumber */
decode_len = decode_context_unsigned(&apdu[len], 1, &unsigned_value); decode_len = decode_context_unsigned(&apdu[len], 1, &unsigned_value);
if (decode_len < 0) { if (decode_len < 0) {
@@ -279,7 +279,7 @@ int ptransfer_error_decode_service_request(
return -1; return -1;
} }
len += decode_len; len += decode_len;
private_data->vendorID = (uint16_t)unsigned_value; private_data->vendorID = (uint16_t) unsigned_value;
/* Tag 2: serviceNumber */ /* Tag 2: serviceNumber */
decode_len = decode_context_unsigned(&apdu[len], 2, &unsigned_value); decode_len = decode_context_unsigned(&apdu[len], 2, &unsigned_value);
if (decode_len < 0) { if (decode_len < 0) {
+1 -1
View File
@@ -87,7 +87,7 @@ BACNET_REJECT_REASON reject_convert_error_code(
break; break;
} }
return(reject_code); return (reject_code);
} }
/* encode service */ /* encode service */
+2 -2
View File
@@ -91,7 +91,7 @@ int rp_decode_service_request(
if (rpdata != NULL) { if (rpdata != NULL) {
/* Must have at least 2 tags, an object id and a property identifier /* Must have at least 2 tags, an object id and a property identifier
* of at least 1 byte in length to have any chance of parsing */ * of at least 1 byte in length to have any chance of parsing */
if(apdu_len < 7) { if (apdu_len < 7) {
rpdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER; rpdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
@@ -130,7 +130,7 @@ int rp_decode_service_request(
rpdata->array_index = BACNET_ARRAY_ALL; rpdata->array_index = BACNET_ARRAY_ALL;
} }
if(len < apdu_len) { if (len < apdu_len) {
/* If something left over now, we have an invalid request */ /* If something left over now, we have an invalid request */
rpdata->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS; rpdata->error_code = ERROR_CODE_REJECT_TOO_MANY_ARGUMENTS;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
+10 -12
View File
@@ -197,14 +197,14 @@ int rpm_encode_apdu(
int rpm_decode_object_id( int rpm_decode_object_id(
uint8_t * apdu, uint8_t * apdu,
unsigned apdu_len, unsigned apdu_len,
BACNET_RPM_DATA *rpmdata) BACNET_RPM_DATA * rpmdata)
{ {
unsigned len = 0; unsigned len = 0;
uint16_t type = 0; /* for decoding */ uint16_t type = 0; /* for decoding */
/* check for value pointers */ /* check for value pointers */
if (apdu && apdu_len && rpmdata) { if (apdu && apdu_len && rpmdata) {
if(apdu_len < 5) { /* Must be at least 2 tags and an object id */ if (apdu_len < 5) { /* Must be at least 2 tags and an object id */
rpmdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER; rpmdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
@@ -251,7 +251,7 @@ int rpm_decode_object_end(
int rpm_decode_object_property( int rpm_decode_object_property(
uint8_t * apdu, uint8_t * apdu,
unsigned apdu_len, unsigned apdu_len,
BACNET_RPM_DATA *rpmdata) BACNET_RPM_DATA * rpmdata)
{ {
unsigned len = 0; unsigned len = 0;
unsigned option_len = 0; unsigned option_len = 0;
@@ -284,7 +284,7 @@ int rpm_decode_object_property(
rpmdata->object_property = (BACNET_PROPERTY_ID) property; rpmdata->object_property = (BACNET_PROPERTY_ID) property;
/* Tag 1: Optional propertyArrayIndex */ /* Tag 1: Optional propertyArrayIndex */
rpmdata->array_index = BACNET_ARRAY_ALL; /* Assume most probable outcome */ rpmdata->array_index = BACNET_ARRAY_ALL; /* Assume most probable outcome */
if (IS_CONTEXT_SPECIFIC(apdu[len]) && !IS_CLOSING_TAG(apdu[len])) { if (IS_CONTEXT_SPECIFIC(apdu[len]) && !IS_CLOSING_TAG(apdu[len])) {
option_len = option_len =
(unsigned) decode_tag_number_and_value(&apdu[len], &tag_number, (unsigned) decode_tag_number_and_value(&apdu[len], &tag_number,
@@ -293,7 +293,8 @@ int rpm_decode_object_property(
len += option_len; len += option_len;
/* Should be at least the unsigned array index + 1 tag left */ /* Should be at least the unsigned array index + 1 tag left */
if ((len + len_value_type) >= apdu_len) { if ((len + len_value_type) >= apdu_len) {
rpmdata->error_code = ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER; rpmdata->error_code =
ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
len += len +=
@@ -324,7 +325,7 @@ int rpm_ack_encode_apdu_init(
int rpm_ack_encode_apdu_object_begin( int rpm_ack_encode_apdu_object_begin(
uint8_t * apdu, uint8_t * apdu,
BACNET_RPM_DATA *rpmdata) BACNET_RPM_DATA * rpmdata)
{ {
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
@@ -620,8 +621,7 @@ void testReadPropertyMultiple(
ct_test(pTest, service_request_len > 0); ct_test(pTest, service_request_len > 0);
test_len = test_len =
rpm_decode_object_id(service_request, service_request_len, rpm_decode_object_id(service_request, service_request_len, &rpmdata);
&rpmdata);
ct_test(pTest, test_len > 0); ct_test(pTest, test_len > 0);
ct_test(pTest, rpmdata.object_type == OBJECT_DEVICE); ct_test(pTest, rpmdata.object_type == OBJECT_DEVICE);
ct_test(pTest, rpmdata.object_instance == 123); ct_test(pTest, rpmdata.object_instance == 123);
@@ -725,8 +725,7 @@ void testReadPropertyMultipleAck(
/* object beginning */ /* object beginning */
rpmdata.object_type = OBJECT_DEVICE; rpmdata.object_type = OBJECT_DEVICE;
rpmdata.object_instance = 123; rpmdata.object_instance = 123;
apdu_len += apdu_len += rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], &rpmdata);
rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], &rpmdata);
/* reply property */ /* reply property */
apdu_len += apdu_len +=
rpm_ack_encode_apdu_object_property(&apdu[apdu_len], rpm_ack_encode_apdu_object_property(&apdu[apdu_len],
@@ -760,8 +759,7 @@ void testReadPropertyMultipleAck(
/* object beginning */ /* object beginning */
rpmdata.object_type = OBJECT_ANALOG_INPUT; rpmdata.object_type = OBJECT_ANALOG_INPUT;
rpmdata.object_instance = 33; rpmdata.object_instance = 33;
apdu_len += apdu_len += rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], &rpmdata);
rpm_ack_encode_apdu_object_begin(&apdu[apdu_len], &rpmdata);
/* reply property */ /* reply property */
apdu_len += apdu_len +=
rpm_ack_encode_apdu_object_property(&apdu[apdu_len], rpm_ack_encode_apdu_object_property(&apdu[apdu_len],
+3 -3
View File
@@ -73,7 +73,7 @@ static uint8_t tsm_find_invokeID_index(
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) { for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
if (TSM_List[i].InvokeID == invokeID) { if (TSM_List[i].InvokeID == invokeID) {
index = (uint8_t)i; index = (uint8_t) i;
break; break;
} }
} }
@@ -89,7 +89,7 @@ static uint8_t tsm_find_first_free_index(
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) { for (i = 0; i < MAX_TSM_TRANSACTIONS; i++) {
if (TSM_List[i].InvokeID == 0) { if (TSM_List[i].InvokeID == 0) {
index = (uint8_t)i; index = (uint8_t) i;
break; break;
} }
} }
@@ -238,7 +238,7 @@ bool tsm_get_transaction_pdu(
/* FIXME: we may want to free the transaction so it doesn't timeout */ /* FIXME: we may want to free the transaction so it doesn't timeout */
/* retrieve the transaction */ /* retrieve the transaction */
/* FIXME: bounds check the pdu_len? */ /* FIXME: bounds check the pdu_len? */
*apdu_len = (uint16_t)TSM_List[index].apdu_len; *apdu_len = (uint16_t) TSM_List[index].apdu_len;
for (j = 0; j < *apdu_len; j++) { for (j = 0; j < *apdu_len; j++) {
apdu[j] = TSM_List[index].apdu[j]; apdu[j] = TSM_List[index].apdu[j];
} }