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