indented.
This commit is contained in:
@@ -122,11 +122,12 @@ int Analog_Input_Encode_Property_APDU(
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_OBJECT_TYPE:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
OBJECT_ANALOG_INPUT);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], OBJECT_ANALOG_INPUT);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
apdu_len = encode_application_real(&apdu[0],
|
||||
apdu_len =
|
||||
encode_application_real(&apdu[0],
|
||||
Analog_Input_Present_Value(object_instance));
|
||||
break;
|
||||
case PROP_STATUS_FLAGS:
|
||||
@@ -177,14 +178,14 @@ void testAnalogInput(
|
||||
|
||||
|
||||
/* FIXME: we should do a lot more testing here... */
|
||||
len = Analog_Input_Encode_Property_APDU(&apdu[0],
|
||||
instance,
|
||||
len =
|
||||
Analog_Input_Encode_Property_APDU(&apdu[0], instance,
|
||||
PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code);
|
||||
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],
|
||||
(int *) &decoded_type, &decoded_instance);
|
||||
len =
|
||||
decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance);
|
||||
ct_test(pTest, decoded_type == OBJECT_ANALOG_INPUT);
|
||||
ct_test(pTest, decoded_instance == instance);
|
||||
|
||||
|
||||
@@ -296,7 +296,8 @@ bool Analog_Value_Write_Property(
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
len =
|
||||
bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
@@ -400,14 +401,14 @@ void testAnalog_Value(
|
||||
BACNET_ERROR_CODE error_code;
|
||||
|
||||
|
||||
len = Analog_Value_Encode_Property_APDU(&apdu[0],
|
||||
instance,
|
||||
len =
|
||||
Analog_Value_Encode_Property_APDU(&apdu[0], instance,
|
||||
PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code);
|
||||
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],
|
||||
(int *) &decoded_type, &decoded_instance);
|
||||
len =
|
||||
decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance);
|
||||
ct_test(pTest, decoded_type == OBJECT_ANALOG_VALUE);
|
||||
ct_test(pTest, decoded_instance == instance);
|
||||
|
||||
|
||||
@@ -211,14 +211,14 @@ void testBinaryInput(
|
||||
|
||||
|
||||
/* FIXME: we should do a lot more testing here... */
|
||||
len = Binary_Input_Encode_Property_APDU(&apdu[0],
|
||||
instance,
|
||||
len =
|
||||
Binary_Input_Encode_Property_APDU(&apdu[0], instance,
|
||||
PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code);
|
||||
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],
|
||||
(int *) &decoded_type, &decoded_instance);
|
||||
len =
|
||||
decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance);
|
||||
ct_test(pTest, decoded_type == OBJECT_BINARY_INPUT);
|
||||
ct_test(pTest, decoded_instance == instance);
|
||||
|
||||
|
||||
@@ -207,7 +207,8 @@ bool Binary_Value_Write_Property(
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
len =
|
||||
bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
@@ -315,14 +316,14 @@ void testBinary_Value(
|
||||
BACNET_ERROR_CODE error_code;
|
||||
|
||||
|
||||
len = Binary_Value_Encode_Property_APDU(&apdu[0],
|
||||
instance,
|
||||
len =
|
||||
Binary_Value_Encode_Property_APDU(&apdu[0], instance,
|
||||
PROP_OBJECT_IDENTIFIER, BACNET_ARRAY_ALL, &error_class, &error_code);
|
||||
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],
|
||||
(int *) &decoded_type, &decoded_instance);
|
||||
len =
|
||||
decode_object_id(&apdu[len], (int *) &decoded_type, &decoded_instance);
|
||||
ct_test(pTest, decoded_type == OBJECT_BINARY_VALUE);
|
||||
ct_test(pTest, decoded_instance == instance);
|
||||
|
||||
|
||||
@@ -277,7 +277,8 @@ int Device_Encode_Property_APDU(
|
||||
/* FIXME: change the hardcoded names to suit your application */
|
||||
switch (property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
apdu_len = encode_application_object_id(&apdu[0], OBJECT_DEVICE,
|
||||
apdu_len =
|
||||
encode_application_object_id(&apdu[0], OBJECT_DEVICE,
|
||||
Object_Instance_Number);
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
@@ -416,11 +417,13 @@ int Device_Encode_Property_APDU(
|
||||
}
|
||||
break;
|
||||
case PROP_MAX_APDU_LENGTH_ACCEPTED:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Device_Max_APDU_Length_Accepted());
|
||||
break;
|
||||
case PROP_SEGMENTATION_SUPPORTED:
|
||||
apdu_len = encode_application_enumerated(&apdu[0],
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
Device_Segmentation_Supported());
|
||||
break;
|
||||
case PROP_APDU_TIMEOUT:
|
||||
@@ -502,7 +505,8 @@ bool Device_Write_Property(
|
||||
return false;
|
||||
}
|
||||
/* decode the some of the request */
|
||||
len = bacapp_decode_application_data(wp_data->application_data,
|
||||
len =
|
||||
bacapp_decode_application_data(wp_data->application_data,
|
||||
wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
/* FIXME: len == 0: unable to decode? */
|
||||
@@ -510,8 +514,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 {
|
||||
|
||||
@@ -303,8 +303,9 @@ static bool dlmstp_compare_data_expecting_reply(
|
||||
/* decode the request data */
|
||||
request.address.mac[0] = src_address;
|
||||
request.address.mac_len = 1;
|
||||
offset = npdu_decode(&request_pdu[0],
|
||||
NULL, &request.address, &request.npdu_data);
|
||||
offset =
|
||||
npdu_decode(&request_pdu[0], NULL, &request.address,
|
||||
&request.npdu_data);
|
||||
if (request.npdu_data.network_layer_message) {
|
||||
return false;
|
||||
}
|
||||
@@ -321,8 +322,8 @@ static bool dlmstp_compare_data_expecting_reply(
|
||||
/* decode the reply data */
|
||||
reply.address.mac[0] = dest_address;
|
||||
reply.address.mac_len = 1;
|
||||
offset = npdu_decode(&reply_pdu[0],
|
||||
&reply.address, NULL, &reply.npdu_data);
|
||||
offset =
|
||||
npdu_decode(&reply_pdu[0], &reply.address, NULL, &reply.npdu_data);
|
||||
if (reply.npdu_data.network_layer_message) {
|
||||
return false;
|
||||
}
|
||||
@@ -788,9 +789,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
} else {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type,
|
||||
TransmitPacketDest,
|
||||
This_Station,
|
||||
MSTP_Send_Frame(frame_type, TransmitPacketDest, This_Station,
|
||||
(uint8_t *) & TransmitPacket[0], TransmitPacketLen);
|
||||
MSTP_Flag.TransmitPacketPending = false;
|
||||
FrameCount++;
|
||||
@@ -904,8 +903,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* address at which a new master node may be found in that case. */
|
||||
TokenCount++;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN,
|
||||
Next_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station,
|
||||
This_Station, NULL, 0);
|
||||
RetryCount = 0;
|
||||
EventCount = 0;
|
||||
Master_State = MSTP_MASTER_STATE_PASS_TOKEN;
|
||||
@@ -927,8 +926,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* ResetMaintenancePFM */
|
||||
Poll_Station = This_Station;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN,
|
||||
Next_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station,
|
||||
This_Station, NULL, 0);
|
||||
RetryCount = 0;
|
||||
TokenCount = 1; /* changed in Errata SSPC-135-2004 */
|
||||
EventCount = 0;
|
||||
@@ -937,8 +936,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
} else {
|
||||
/* SendMaintenancePFM */
|
||||
Poll_Station = next_poll_station;
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER,
|
||||
Poll_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
|
||||
This_Station, NULL, 0);
|
||||
RetryCount = 0;
|
||||
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
|
||||
}
|
||||
@@ -959,8 +958,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* RetrySendToken */
|
||||
RetryCount++;
|
||||
/* Transmit a Token frame to NS */
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN,
|
||||
Next_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station,
|
||||
This_Station, NULL, 0);
|
||||
EventCount = 0;
|
||||
/* re-enter the current state to listen for NS */
|
||||
/* to begin using the token. */
|
||||
@@ -969,8 +968,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* Assume that NS has failed. */
|
||||
Poll_Station = next_next_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER,
|
||||
Poll_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
|
||||
This_Station, NULL, 0);
|
||||
/* no known successor node */
|
||||
Next_Station = This_Station;
|
||||
RetryCount = 0;
|
||||
@@ -1003,8 +1002,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* on the network and is empowered to create a token. */
|
||||
Poll_Station = next_this_station;
|
||||
/* Transmit a Poll For Master frame to PS. */
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER,
|
||||
Poll_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
|
||||
This_Station, NULL, 0);
|
||||
/* indicate that the next station is unknown */
|
||||
Next_Station = This_Station;
|
||||
RetryCount = 0;
|
||||
@@ -1027,8 +1026,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
Next_Station = SourceAddress;
|
||||
EventCount = 0;
|
||||
/* Transmit a Token frame to NS */
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN,
|
||||
Next_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station,
|
||||
This_Station, NULL, 0);
|
||||
Poll_Station = This_Station;
|
||||
TokenCount = 0;
|
||||
RetryCount = 0;
|
||||
@@ -1060,8 +1059,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* poll for a master at address PS. */
|
||||
EventCount = 0;
|
||||
/* transmit a Token frame to NS */
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN,
|
||||
Next_Station, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_TOKEN, Next_Station,
|
||||
This_Station, NULL, 0);
|
||||
RetryCount = 0;
|
||||
Master_State = MSTP_MASTER_STATE_PASS_TOKEN;
|
||||
} else {
|
||||
@@ -1092,10 +1091,10 @@ static bool MSTP_Master_Node_FSM(
|
||||
case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST:
|
||||
/* Note: we could wait for up to Treply_delay */
|
||||
if (MSTP_Flag.TransmitPacketPending) {
|
||||
matched = dlmstp_compare_data_expecting_reply(&InputBuffer[0],
|
||||
DataLength,
|
||||
SourceAddress,
|
||||
&TransmitPacket[0], TransmitPacketLen, TransmitPacketDest);
|
||||
matched =
|
||||
dlmstp_compare_data_expecting_reply(&InputBuffer[0],
|
||||
DataLength, SourceAddress, &TransmitPacket[0],
|
||||
TransmitPacketLen, TransmitPacketDest);
|
||||
}
|
||||
if (MSTP_Flag.TransmitPacketPending && matched) {
|
||||
/* Reply */
|
||||
@@ -1111,9 +1110,7 @@ static bool MSTP_Master_Node_FSM(
|
||||
} else {
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type,
|
||||
TransmitPacketDest,
|
||||
This_Station,
|
||||
MSTP_Send_Frame(frame_type, TransmitPacketDest, This_Station,
|
||||
(uint8_t *) & TransmitPacket[0], TransmitPacketLen);
|
||||
MSTP_Flag.TransmitPacketPending = false;
|
||||
Master_State = MSTP_MASTER_STATE_IDLE;
|
||||
@@ -1127,8 +1124,8 @@ static bool MSTP_Master_Node_FSM(
|
||||
/* Any reply shall wait until this node receives the token. */
|
||||
/* Call MSTP_Send_Frame to transmit a Reply Postponed frame, */
|
||||
/* and enter the IDLE state. */
|
||||
MSTP_Send_Frame(FRAME_TYPE_REPLY_POSTPONED,
|
||||
SourceAddress, This_Station, NULL, 0);
|
||||
MSTP_Send_Frame(FRAME_TYPE_REPLY_POSTPONED, SourceAddress,
|
||||
This_Station, NULL, 0);
|
||||
Master_State = MSTP_MASTER_STATE_IDLE;
|
||||
}
|
||||
/* clear our flag we were holding for comparison */
|
||||
|
||||
@@ -65,36 +65,41 @@ int Encode_Property_APDU(
|
||||
switch (object_type) {
|
||||
case OBJECT_DEVICE:
|
||||
if (Device_Valid_Object_Instance_Number(object_instance)) {
|
||||
apdu_len = Device_Encode_Property_APDU(&apdu[0],
|
||||
property, array_index, error_class, error_code);
|
||||
apdu_len =
|
||||
Device_Encode_Property_APDU(&apdu[0], property,
|
||||
array_index, error_class, error_code);
|
||||
}
|
||||
break;
|
||||
case OBJECT_ANALOG_INPUT:
|
||||
if (Analog_Input_Valid_Instance(object_instance)) {
|
||||
apdu_len = Analog_Input_Encode_Property_APDU(&apdu[0],
|
||||
object_instance,
|
||||
property, array_index, error_class, error_code);
|
||||
apdu_len =
|
||||
Analog_Input_Encode_Property_APDU(&apdu[0],
|
||||
object_instance, property, array_index, error_class,
|
||||
error_code);
|
||||
}
|
||||
break;
|
||||
case OBJECT_ANALOG_VALUE:
|
||||
if (Analog_Value_Valid_Instance(object_instance)) {
|
||||
apdu_len = Analog_Value_Encode_Property_APDU(&Temp_Buf[0],
|
||||
object_instance,
|
||||
property, array_index, error_class, error_code);
|
||||
apdu_len =
|
||||
Analog_Value_Encode_Property_APDU(&Temp_Buf[0],
|
||||
object_instance, property, array_index, error_class,
|
||||
error_code);
|
||||
}
|
||||
break;
|
||||
case OBJECT_BINARY_INPUT:
|
||||
if (Binary_Input_Valid_Instance(object_instance)) {
|
||||
apdu_len = Binary_Input_Encode_Property_APDU(&apdu[0],
|
||||
object_instance,
|
||||
property, array_index, error_class, error_code);
|
||||
apdu_len =
|
||||
Binary_Input_Encode_Property_APDU(&apdu[0],
|
||||
object_instance, property, array_index, error_class,
|
||||
error_code);
|
||||
}
|
||||
break;
|
||||
case OBJECT_BINARY_VALUE:
|
||||
if (Binary_Value_Valid_Instance(object_instance)) {
|
||||
apdu_len = Binary_Value_Encode_Property_APDU(&Temp_Buf[0],
|
||||
object_instance,
|
||||
property, array_index, error_class, error_code);
|
||||
apdu_len =
|
||||
Binary_Value_Encode_Property_APDU(&Temp_Buf[0],
|
||||
object_instance, property, array_index, error_class,
|
||||
error_code);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -125,28 +130,31 @@ void handler_read_property(
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src,
|
||||
&my_address, &npdu_data);
|
||||
pdu_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 */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
||||
true);
|
||||
goto RP_ABORT;
|
||||
}
|
||||
len = rp_decode_service_request(service_request, service_len, &data);
|
||||
if (len < 0) {
|
||||
/* bad decoding - send an abort */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER, true);
|
||||
goto RP_ABORT;
|
||||
}
|
||||
/* most cases will be error */
|
||||
error = true;
|
||||
len = Encode_Property_APDU(&Temp_Buf[0],
|
||||
data.object_type,
|
||||
data.object_instance,
|
||||
data.object_property, data.array_index, &error_class, &error_code);
|
||||
len =
|
||||
Encode_Property_APDU(&Temp_Buf[0], data.object_type,
|
||||
data.object_instance, data.object_property, data.array_index,
|
||||
&error_class, &error_code);
|
||||
if (len >= 0) {
|
||||
/* encode the APDU portion of the packet */
|
||||
data.application_data = &Temp_Buf[0];
|
||||
@@ -160,19 +168,22 @@ void handler_read_property(
|
||||
if (error) {
|
||||
if (len == -2) {
|
||||
/* BACnet APDU too small to fit data, so proper response is Abort */
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
goto RP_ABORT;
|
||||
}
|
||||
len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code);
|
||||
len =
|
||||
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_READ_PROPERTY,
|
||||
error_class, error_code);
|
||||
}
|
||||
RP_ABORT:
|
||||
pdu_len += len;
|
||||
bytes_sent = datalink_send_pdu(src, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,19 +63,22 @@ void handler_write_property(
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src,
|
||||
&my_address, &npdu_data);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address,
|
||||
&npdu_data);
|
||||
if (service_data->segmented_message) {
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
||||
true);
|
||||
goto WP_ABORT;
|
||||
}
|
||||
/* decode the service request only */
|
||||
len = wp_decode_service_request(service_request, service_len, &wp_data);
|
||||
/* bad decoding or something we didn't understand - send an abort */
|
||||
if (len <= 0) {
|
||||
len = abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER, true);
|
||||
goto WP_ABORT;
|
||||
}
|
||||
@@ -89,8 +92,8 @@ void handler_write_property(
|
||||
} else {
|
||||
len =
|
||||
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
error_class, error_code);
|
||||
}
|
||||
break;
|
||||
case OBJECT_ANALOG_INPUT:
|
||||
@@ -111,8 +114,8 @@ void handler_write_property(
|
||||
} else {
|
||||
len =
|
||||
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
error_class, error_code);
|
||||
}
|
||||
break;
|
||||
case OBJECT_ANALOG_VALUE:
|
||||
@@ -124,8 +127,8 @@ void handler_write_property(
|
||||
} else {
|
||||
len =
|
||||
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class, error_code);
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
error_class, error_code);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -137,8 +140,9 @@ void handler_write_property(
|
||||
}
|
||||
WP_ABORT:
|
||||
pdu_len += len;
|
||||
bytes_sent = datalink_send_pdu(src, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,9 @@ void LowLevelInit(
|
||||
//
|
||||
// OUT = 0 (not used)
|
||||
// result: AT91C_CKGR_PLLR = 0x00000000480A0E (PLL Register)
|
||||
pPMC->PMC_PLLR = ((AT91C_CKGR_DIV & 14) |
|
||||
(AT91C_CKGR_PLLCOUNT & (10 << 8)) | (AT91C_CKGR_MUL & (72 << 16)));
|
||||
pPMC->PMC_PLLR =
|
||||
((AT91C_CKGR_DIV & 14) | (AT91C_CKGR_PLLCOUNT & (10 << 8)) |
|
||||
(AT91C_CKGR_MUL & (72 << 16)));
|
||||
|
||||
// Wait the startup time (until PMC Status register LOCK bit is set)
|
||||
while (!(pPMC->PMC_SR & AT91C_PMC_LOCK));
|
||||
|
||||
@@ -155,8 +155,7 @@ static void bacnet_init(
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||
handler_write_property);
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler
|
||||
(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
handler_device_communication_control);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user