Indented using indent script.

This commit is contained in:
skarg
2010-05-04 21:06:26 +00:00
parent b2368acc27
commit 710cfccfef
134 changed files with 2901 additions and 3035 deletions
+3 -5
View File
@@ -143,15 +143,14 @@ void Analog_Input_Present_Value_Set(
/* return apdu length, or -1 on error */
/* assumption - object has already exists */
int Analog_Input_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
uint8_t *apdu = NULL;
if ((rpdata == NULL) ||
(rpdata->application_data == NULL) ||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
@@ -205,8 +204,7 @@ int Analog_Input_Read_Property(
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
apdu_len = -1;
+10 -9
View File
@@ -181,7 +181,7 @@ char *Analog_Value_Name(
/* return apdu len, or -1 on error */
int Analog_Value_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
@@ -195,8 +195,7 @@ int Analog_Value_Read_Property(
#endif
uint8_t *apdu = NULL;
if ((rpdata == NULL) ||
(rpdata->application_data == NULL) ||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
@@ -236,7 +235,8 @@ int Analog_Value_Read_Property(
break;
case PROP_OUT_OF_SERVICE:
#if 0
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
object_index =
Analog_Value_Instance_To_Index(rpdata->object_instance);
state = Analog_Value_Out_Of_Service[object_index];
#endif
apdu_len = encode_application_boolean(&apdu[0], false);
@@ -253,7 +253,8 @@ int Analog_Value_Read_Property(
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
object_index =
Analog_Value_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 (Present_Value[object_index][i] == ANALOG_LEVEL_NULL)
@@ -282,7 +283,8 @@ int Analog_Value_Read_Property(
apdu_len = encode_application_null(&apdu[0]);
else {
real_value =
Present_Value[object_index][rpdata->array_index - 1];
Present_Value[object_index][rpdata->array_index -
1];
apdu_len =
encode_application_real(&apdu[0], real_value);
}
@@ -353,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
@@ -420,4 +422,3 @@ bool Analog_Value_Write_Property(
return status;
}
+3 -6
View File
@@ -160,7 +160,7 @@ char *Binary_Input_Name(
/* return apdu length, or -1 on error */
/* assumption - object already exists, and has been bounds checked */
int Binary_Input_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
@@ -169,8 +169,7 @@ int Binary_Input_Read_Property(
BACNET_BINARY_PV value = BINARY_INACTIVE;
uint8_t *apdu = NULL;
if ((rpdata == NULL) ||
(rpdata->application_data == NULL) ||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
@@ -224,8 +223,7 @@ int Binary_Input_Read_Property(
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
apdu_len = -1;
@@ -233,4 +231,3 @@ int Binary_Input_Read_Property(
return apdu_len;
}
+7 -9
View File
@@ -154,7 +154,7 @@ char *Binary_Value_Name(
/* return apdu len, or -1 on error */
int Binary_Value_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
@@ -164,8 +164,7 @@ int Binary_Value_Read_Property(
uint8_t *apdu = NULL;
if ((rpdata == NULL) ||
(rpdata->application_data == NULL) ||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
@@ -190,7 +189,8 @@ int Binary_Value_Read_Property(
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
break;
case PROP_PRESENT_VALUE:
present_value = Binary_Value_Present_Value(rpdata->object_instance);
present_value =
Binary_Value_Present_Value(rpdata->object_instance);
apdu_len = encode_application_enumerated(&apdu[0], present_value);
break;
case PROP_STATUS_FLAGS:
@@ -221,8 +221,7 @@ int Binary_Value_Read_Property(
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
apdu_len = -1;
@@ -266,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;
@@ -312,4 +311,3 @@ bool Binary_Value_Write_Property(
return status;
}
+53 -81
View File
@@ -51,12 +51,11 @@
static uint32_t Object_Instance_Number = 12345;
static char My_Object_Name[32] = "ARM7 Device";
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
static BACNET_REINITIALIZED_STATE Reinitialize_State =
BACNET_REINIT_IDLE;
static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
/* forward prototypes */
int Device_Read_Property_Local(
BACNET_READ_PROPERTY_DATA *rpdata);
BACNET_READ_PROPERTY_DATA * rpdata);
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data);
@@ -70,55 +69,30 @@ static struct object_functions {
read_property_function Object_Read_Property;
write_property_function Object_Write_Property;
rpm_property_lists_function Object_RPM_List;
} Object_Table[] =
{
{OBJECT_DEVICE,
NULL,/* don't init - recursive! */
Device_Count,
Device_Index_To_Instance,
Device_Valid_Object_Instance_Number,
Device_Name,
Device_Read_Property_Local,
Device_Write_Property_Local,
Device_Property_Lists},
{OBJECT_ANALOG_INPUT,
Analog_Input_Init,
Analog_Input_Count,
Analog_Input_Index_To_Instance,
Analog_Input_Valid_Instance,
Analog_Input_Name,
Analog_Input_Read_Property,
NULL,
Analog_Input_Property_Lists},
{OBJECT_ANALOG_VALUE,
Analog_Value_Init,
Analog_Value_Count,
Analog_Value_Index_To_Instance,
Analog_Value_Valid_Instance,
Analog_Value_Name,
Analog_Value_Read_Property,
Analog_Value_Write_Property,
Analog_Value_Property_Lists},
{OBJECT_BINARY_INPUT,
Binary_Input_Init,
Binary_Input_Count,
Binary_Input_Index_To_Instance,
Binary_Input_Valid_Instance,
Binary_Input_Name,
Binary_Input_Read_Property,
NULL,
Binary_Input_Property_Lists},
{OBJECT_BINARY_VALUE,
Binary_Value_Init,
Binary_Value_Count,
Binary_Value_Index_To_Instance,
Binary_Value_Valid_Instance,
Binary_Value_Name,
Binary_Value_Read_Property,
Binary_Value_Write_Property,
Binary_Value_Property_Lists},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
} Object_Table[] = {
{
OBJECT_DEVICE, NULL, /* don't init - recursive! */
Device_Count, Device_Index_To_Instance,
Device_Valid_Object_Instance_Number, Device_Name,
Device_Read_Property_Local, Device_Write_Property_Local,
Device_Property_Lists}, {
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
Analog_Input_Name, Analog_Input_Read_Property, NULL,
Analog_Input_Property_Lists}, {
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
Analog_Value_Name, Analog_Value_Read_Property,
Analog_Value_Write_Property, Analog_Value_Property_Lists}, {
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
Binary_Input_Name, Binary_Input_Read_Property, NULL,
Binary_Input_Property_Lists}, {
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
Binary_Value_Name, Binary_Value_Read_Property,
Binary_Value_Write_Property, Binary_Value_Property_Lists}, {
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
};
/* These three arrays are used by the ReadPropertyMultiple handler */
@@ -176,7 +150,7 @@ void Device_Property_Lists(
/* Encodes the property APDU and returns the length,
or sets the error, and returns -1 */
int Device_Read_Property(
BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = -1;
unsigned index = 0;
@@ -294,10 +268,8 @@ void Device_Objects_Property_List(
pObject = &Object_Table[index];
}
if (found && object_property_list) {
object_property_list(
&pPropertyList->Required.pList,
&pPropertyList->Optional.pList,
&pPropertyList->Proprietary.pList);
object_property_list(&pPropertyList->Required.pList,
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
}
/* fill the count */
if (pPropertyList->Required.pList) {
@@ -328,7 +300,7 @@ unsigned Device_Object_List_Count(
void)
{
unsigned count = 0; /* number of objects */
unsigned index = 0; /* loop counter */
unsigned index = 0; /* loop counter */
struct object_functions *pObject = NULL;
/* initialize the default return values */
@@ -363,8 +335,7 @@ bool Device_Object_List_Identifier(
/* initialize the default return values */
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if (pObject->Object_Count &&
pObject->Object_Index_To_Instance) {
if (pObject->Object_Count && pObject->Object_Index_To_Instance) {
object_index -= count;
count = pObject->Object_Count();
if (object_index < count) {
@@ -425,8 +396,7 @@ char *Device_Valid_Object_Id(
pObject = &Object_Table[0];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if ((pObject->Object_Type == object_type) &&
(pObject->Object_Name)) {
if ((pObject->Object_Type == object_type) && (pObject->Object_Name)) {
name = pObject->Object_Name(object_instance);
break;
}
@@ -437,7 +407,8 @@ char *Device_Valid_Object_Id(
return name;
}
unsigned Device_Count(void)
unsigned Device_Count(
void)
{
return 1;
}
@@ -459,7 +430,7 @@ char *Device_Name(
}
bool Device_Reinitialize(
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
BACNET_REINITIALIZE_DEVICE_DATA * rd_data)
{
bool status = false;
@@ -547,7 +518,7 @@ int Device_Set_System_Status(
BACNET_DEVICE_STATUS status,
bool local)
{
int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
if (status < MAX_DEVICE_STATUS) {
System_Status = status;
@@ -588,7 +559,7 @@ uint32_t Device_Database_Revision(
/* return the length of the apdu encoded or -1 for error */
int Device_Read_Property_Local(
BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{
int apdu_len = 0; /* return value */
int len = 0; /* apdu len intermediate value */
@@ -604,8 +575,7 @@ int Device_Read_Property_Local(
struct object_functions *pObject = NULL;
bool found = false;
if ((rpdata == NULL) ||
(rpdata->application_data == NULL) ||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
@@ -702,8 +672,7 @@ int Device_Read_Property_Local(
i = 0;
pObject = &Object_Table[i];
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
if ((pObject->Object_Count) &&
(pObject->Object_Count() > 0)) {
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
}
i++;
@@ -722,8 +691,9 @@ int Device_Read_Property_Local(
/* your maximum APDU size. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
for (i = 1; i <= count; i++) {
found = Device_Object_List_Identifier(i, &object_type,
&instance);
found =
Device_Object_List_Identifier(i, &object_type,
&instance);
if (found) {
len =
encode_application_object_id(&apdu[apdu_len],
@@ -733,7 +703,8 @@ int Device_Read_Property_Local(
/* can we all fit into the APDU? */
if ((apdu_len + len) >= MAX_APDU) {
rpdata->error_class = ERROR_CLASS_SERVICES;
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
rpdata->error_code =
ERROR_CODE_NO_SPACE_FOR_OBJECT;
apdu_len = -1;
break;
}
@@ -746,8 +717,8 @@ int Device_Read_Property_Local(
}
}
} else {
if (Device_Object_List_Identifier(rpdata->array_index, &object_type,
&instance))
if (Device_Object_List_Identifier(rpdata->array_index,
&object_type, &instance))
apdu_len =
encode_application_object_id(&apdu[0], object_type,
instance);
@@ -825,8 +796,7 @@ int Device_Read_Property_Local(
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->object_property != PROP_OBJECT_LIST) &&
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
@@ -858,8 +828,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 {
@@ -918,11 +888,13 @@ bool Device_Write_Property_Local(
the device. */
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
wp_data->error_code =
ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
wp_data->error_code =
ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
+1 -2
View File
@@ -147,8 +147,7 @@ static inline void bacnet_init(
/* set up our confirmed service unrecognized service handler - required! */
apdu_set_unrecognized_service_handler_handler
(handler_unrecognized_service);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
handler_who_has);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
/* we need to handle who-is to support dynamic device binding */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
/* Set the handlers for any confirmed services that we support. */