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 */