Fixed Device Address Binding by allowing a zero length APDU to be passed back from the objects, and used -1 as signal for error encoding.

This commit is contained in:
skarg
2006-02-09 17:50:48 +00:00
parent 09dc4d1f04
commit 6d0f6adb90
5 changed files with 19 additions and 12 deletions
+4 -4
View File
@@ -109,7 +109,7 @@ void handler_read_property(
data.array_index,
&error_class,
&error_code);
if (len > 0)
if (len >= 0)
{
// encode the APDU portion of the packet
data.application_data = &Temp_Buf[0];
@@ -138,7 +138,7 @@ void handler_read_property(
data.array_index,
&error_class,
&error_code);
if (len > 0)
if (len >= 0)
{
// encode the APDU portion of the packet
data.application_data = &Temp_Buf[0];
@@ -167,7 +167,7 @@ void handler_read_property(
data.array_index,
&error_class,
&error_code);
if (len > 0)
if (len >= 0)
{
// encode the APDU portion of the packet
data.application_data = &Temp_Buf[0];
@@ -197,7 +197,7 @@ void handler_read_property(
data.array_index,
&error_class,
&error_code);
if (len > 0)
if (len >= 0)
{
// encode the APDU portion of the packet
data.application_data = &Temp_Buf[0];
+3 -1
View File
@@ -61,6 +61,7 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index)
return index;
}
/* return apdu length, or -1 on error */
int Analog_Input_Encode_Property_APDU(
uint8_t *apdu,
uint32_t object_instance,
@@ -115,6 +116,7 @@ int Analog_Input_Encode_Property_APDU(
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
apdu_len = -1;
break;
}
@@ -147,7 +149,7 @@ void testAnalogInput(Test * pTest)
BACNET_ARRAY_ALL,
&error_class,
&error_code);
ct_test(pTest, len != 0);
ct_test(pTest, len >= 0);
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
len = decode_object_id(&apdu[len],
+4 -1
View File
@@ -141,6 +141,7 @@ static float Analog_Output_Present_Value(uint32_t object_instance)
return value;
}
/* return apdu len, or -1 on error */
int Analog_Output_Encode_Property_APDU(
uint8_t *apdu,
uint32_t object_instance,
@@ -223,7 +224,7 @@ int Analog_Output_Encode_Property_APDU(
{
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
apdu_len = 0;
apdu_len = -1;
break;
}
}
@@ -245,6 +246,7 @@ int Analog_Output_Encode_Property_APDU(
{
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
apdu_len = -1;
}
}
@@ -256,6 +258,7 @@ int Analog_Output_Encode_Property_APDU(
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
apdu_len = -1;
break;
}
+2
View File
@@ -144,6 +144,7 @@ static unsigned bacfile_file_size(uint32_t object_instance)
return file_size;
}
/* return the number of bytes used, or -1 on error */
int bacfile_encode_property_apdu(
uint8_t *apdu,
uint32_t object_instance,
@@ -215,6 +216,7 @@ int bacfile_encode_property_apdu(
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
apdu_len = -1;
break;
}
+6 -6
View File
@@ -379,7 +379,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
return status;
}
// return the length of the apdu encoded
// return the length of the apdu encoded or -1 for error
int Device_Encode_Property_APDU(
uint8_t *apdu,
BACNET_PROPERTY_ID property,
@@ -514,7 +514,7 @@ int Device_Encode_Property_APDU(
{
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
apdu_len = 0;
apdu_len = -1;
break;
}
}
@@ -523,7 +523,7 @@ int Device_Encode_Property_APDU(
// error: internal error?
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_OTHER;
apdu_len = 0;
apdu_len = -1;
break;
}
}
@@ -536,6 +536,7 @@ int Device_Encode_Property_APDU(
{
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
apdu_len = -1;
}
}
break;
@@ -554,13 +555,12 @@ int Device_Encode_Property_APDU(
apdu_len = encode_tagged_unsigned(&apdu[0], Number_Of_APDU_Retries);
break;
case PROP_DEVICE_ADDRESS_BINDING:
apdu_len += encode_opening_tag(&apdu[0], 3);
/* put the list here, if it exists */
apdu_len += encode_closing_tag(&apdu[apdu_len], 3);
/* encode the list here, if it exists */
break;
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
apdu_len = -1;
break;
}