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:
@@ -109,7 +109,7 @@ void handler_read_property(
|
|||||||
data.array_index,
|
data.array_index,
|
||||||
&error_class,
|
&error_class,
|
||||||
&error_code);
|
&error_code);
|
||||||
if (len > 0)
|
if (len >= 0)
|
||||||
{
|
{
|
||||||
// encode the APDU portion of the packet
|
// encode the APDU portion of the packet
|
||||||
data.application_data = &Temp_Buf[0];
|
data.application_data = &Temp_Buf[0];
|
||||||
@@ -138,7 +138,7 @@ void handler_read_property(
|
|||||||
data.array_index,
|
data.array_index,
|
||||||
&error_class,
|
&error_class,
|
||||||
&error_code);
|
&error_code);
|
||||||
if (len > 0)
|
if (len >= 0)
|
||||||
{
|
{
|
||||||
// encode the APDU portion of the packet
|
// encode the APDU portion of the packet
|
||||||
data.application_data = &Temp_Buf[0];
|
data.application_data = &Temp_Buf[0];
|
||||||
@@ -167,7 +167,7 @@ void handler_read_property(
|
|||||||
data.array_index,
|
data.array_index,
|
||||||
&error_class,
|
&error_class,
|
||||||
&error_code);
|
&error_code);
|
||||||
if (len > 0)
|
if (len >= 0)
|
||||||
{
|
{
|
||||||
// encode the APDU portion of the packet
|
// encode the APDU portion of the packet
|
||||||
data.application_data = &Temp_Buf[0];
|
data.application_data = &Temp_Buf[0];
|
||||||
@@ -197,7 +197,7 @@ void handler_read_property(
|
|||||||
data.array_index,
|
data.array_index,
|
||||||
&error_class,
|
&error_class,
|
||||||
&error_code);
|
&error_code);
|
||||||
if (len > 0)
|
if (len >= 0)
|
||||||
{
|
{
|
||||||
// encode the APDU portion of the packet
|
// encode the APDU portion of the packet
|
||||||
data.application_data = &Temp_Buf[0];
|
data.application_data = &Temp_Buf[0];
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ uint32_t Analog_Input_Index_To_Instance(unsigned index)
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return apdu length, or -1 on error */
|
||||||
int Analog_Input_Encode_Property_APDU(
|
int Analog_Input_Encode_Property_APDU(
|
||||||
uint8_t *apdu,
|
uint8_t *apdu,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
@@ -115,6 +116,7 @@ int Analog_Input_Encode_Property_APDU(
|
|||||||
default:
|
default:
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +149,7 @@ void testAnalogInput(Test * pTest)
|
|||||||
BACNET_ARRAY_ALL,
|
BACNET_ARRAY_ALL,
|
||||||
&error_class,
|
&error_class,
|
||||||
&error_code);
|
&error_code);
|
||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len >= 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len = decode_object_id(&apdu[len],
|
len = decode_object_id(&apdu[len],
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ static float Analog_Output_Present_Value(uint32_t object_instance)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return apdu len, or -1 on error */
|
||||||
int Analog_Output_Encode_Property_APDU(
|
int Analog_Output_Encode_Property_APDU(
|
||||||
uint8_t *apdu,
|
uint8_t *apdu,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
@@ -223,7 +224,7 @@ int Analog_Output_Encode_Property_APDU(
|
|||||||
{
|
{
|
||||||
*error_class = ERROR_CLASS_SERVICES;
|
*error_class = ERROR_CLASS_SERVICES;
|
||||||
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||||
apdu_len = 0;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,6 +246,7 @@ int Analog_Output_Encode_Property_APDU(
|
|||||||
{
|
{
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||||
|
apdu_len = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +258,7 @@ int Analog_Output_Encode_Property_APDU(
|
|||||||
default:
|
default:
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ static unsigned bacfile_file_size(uint32_t object_instance)
|
|||||||
return file_size;
|
return file_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return the number of bytes used, or -1 on error */
|
||||||
int bacfile_encode_property_apdu(
|
int bacfile_encode_property_apdu(
|
||||||
uint8_t *apdu,
|
uint8_t *apdu,
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
@@ -215,6 +216,7 @@ int bacfile_encode_property_apdu(
|
|||||||
default:
|
default:
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
|||||||
return status;
|
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(
|
int Device_Encode_Property_APDU(
|
||||||
uint8_t *apdu,
|
uint8_t *apdu,
|
||||||
BACNET_PROPERTY_ID property,
|
BACNET_PROPERTY_ID property,
|
||||||
@@ -514,7 +514,7 @@ int Device_Encode_Property_APDU(
|
|||||||
{
|
{
|
||||||
*error_class = ERROR_CLASS_SERVICES;
|
*error_class = ERROR_CLASS_SERVICES;
|
||||||
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||||
apdu_len = 0;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,7 +523,7 @@ int Device_Encode_Property_APDU(
|
|||||||
// error: internal error?
|
// error: internal error?
|
||||||
*error_class = ERROR_CLASS_SERVICES;
|
*error_class = ERROR_CLASS_SERVICES;
|
||||||
*error_code = ERROR_CODE_OTHER;
|
*error_code = ERROR_CODE_OTHER;
|
||||||
apdu_len = 0;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -536,6 +536,7 @@ int Device_Encode_Property_APDU(
|
|||||||
{
|
{
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
|
||||||
|
apdu_len = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -554,13 +555,12 @@ int Device_Encode_Property_APDU(
|
|||||||
apdu_len = encode_tagged_unsigned(&apdu[0], Number_Of_APDU_Retries);
|
apdu_len = encode_tagged_unsigned(&apdu[0], Number_Of_APDU_Retries);
|
||||||
break;
|
break;
|
||||||
case PROP_DEVICE_ADDRESS_BINDING:
|
case PROP_DEVICE_ADDRESS_BINDING:
|
||||||
apdu_len += encode_opening_tag(&apdu[0], 3);
|
/* encode the list here, if it exists */
|
||||||
/* put the list here, if it exists */
|
|
||||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 3);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
*error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user