indented.

This commit is contained in:
skarg
2006-08-13 00:57:17 +00:00
parent 5bb205dc03
commit a30d497669
41 changed files with 574 additions and 573 deletions
+19 -16
View File
@@ -52,31 +52,32 @@ void handler_atomic_read_file(uint8_t * service_request,
int bytes_sent = 0;
BACNET_NPDU_DATA npdu_data;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Received Atomic-Read-File Request!\n");
#endif
#endif
len = arf_decode_service_request(service_request, service_len, &data);
/* prepare a reply */
/* bad decoding - send an abort */
if (len < 0) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, ABORT_REASON_OTHER);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Bad Encoding. Sending Abort!\n");
#endif
#endif
} else if (service_data->segmented_message) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Segmented Message. Sending Abort!\n");
#endif
#endif
} else {
if (data.access == FILE_STREAM_ACCESS) {
if (data.type.stream.requestedOctetCount <
octetstring_capacity(&data.fileData)) {
if (bacfile_read_data(&data)) {
pdu_len = arf_ack_encode_apdu(&Handler_Transmit_Buffer[0],
pdu_len =
arf_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
} else {
error = true;
@@ -86,27 +87,29 @@ void handler_atomic_read_file(uint8_t * service_request,
abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Too Big To Send. Sending Abort!\n");
#endif
#endif
}
} else {
pdu_len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, SERVICE_CONFIRMED_ATOMIC_READ_FILE,
ERROR_CLASS_SERVICES, ERROR_CODE_INVALID_FILE_ACCESS_METHOD);
#if PRINT_ENABLED
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id,
SERVICE_CONFIRMED_ATOMIC_READ_FILE, ERROR_CLASS_SERVICES,
ERROR_CODE_INVALID_FILE_ACCESS_METHOD);
#if PRINT_ENABLED
fprintf(stderr, "Record Access Requested. Sending Error!\n");
#endif
#endif
}
}
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0) {
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
}
#endif
#endif
return;
}
+5 -6
View File
@@ -62,9 +62,9 @@ void handler_atomic_read_file_ack(uint8_t * service_request,
instance = bacfile_instance_from_tsm(service_data->invoke_id);
len = arf_ack_decode_service_request(service_request,
service_len, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Received Read-File Ack!\n");
#endif
#endif
if ((len > 0) && (instance <= BACNET_MAX_INSTANCE)) {
/* write the data received to the file specified */
if (data.access == FILE_STREAM_ACCESS) {
@@ -76,12 +76,11 @@ void handler_atomic_read_file_ack(uint8_t * service_request,
data.type.stream.fileStartPosition, SEEK_SET);
if (fwrite(octetstring_value(&data.fileData),
octetstring_length(&data.fileData), 1,
pFile) != 1)
{
#if PRINT_ENABLED
pFile) != 1) {
#if PRINT_ENABLED
fprintf(stderr, "Failed to write to %s (%u)!\n",
pFilename, instance);
#endif
#endif
}
fclose(pFile);
}
+14 -14
View File
@@ -55,46 +55,46 @@ void handler_device_communication_control(uint8_t * service_request,
/* decode the service request only */
len = dcc_decode_service_request(service_request,
service_len, &timeDuration, &state, &password);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "DeviceCommunicationControl!\n");
if (len > 0)
fprintf(stderr, "DeviceCommunicationControl: "
"timeout=%u state=%u password=%s\n",
(unsigned) timeDuration,
(unsigned) state, characterstring_value(&password));
#endif
#endif
/* bad decoding or something we didn't understand - send an abort */
if (len < 0) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, ABORT_REASON_OTHER);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "DeviceCommunicationControl: "
"Sending Abort - could not decode.\n");
#endif
#endif
} else if (service_data->segmented_message) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "DeviceCommunicationControl: "
"Sending Abort - segmented message.\n");
#endif
#endif
} else if (state >= MAX_BACNET_COMMUNICATION_ENABLE_DISABLE) {
pdu_len = reject_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, REJECT_REASON_UNDEFINED_ENUMERATION);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "DeviceCommunicationControl: "
"Sending Reject - undefined enumeration\n");
#endif
#endif
} else {
if (characterstring_ansi_same(&password, My_Password)) {
pdu_len = encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "DeviceCommunicationControl: "
"Sending Simple Ack!\n");
#endif
#endif
dcc_set_status_duration(state, timeDuration);
} else {
pdu_len =
@@ -102,21 +102,21 @@ void handler_device_communication_control(uint8_t * service_request,
service_data->invoke_id,
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
ERROR_CLASS_SERVICES, ERROR_CODE_PASSWORD_FAILURE);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"DeviceCommunicationControl: "
"Sending Error - password failure.\n");
#endif
#endif
}
}
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "DeviceCommunicationControl: "
"Failed to send PDU (%s)!\n", strerror(errno));
#endif
#endif
return;
}
+6 -6
View File
@@ -44,18 +44,18 @@ void handler_i_am_add(uint8_t * service_request,
(void) service_len;
len = iam_decode_service_request(service_request,
&device_id, &max_apdu, &segmentation, &vendor_id);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Received I-Am Request");
#endif
#endif
if (len != -1) {
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, " from %u!\n", device_id);
#endif
#endif
address_add(device_id, max_apdu, src);
} else {
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "!\n");
#endif
#endif
}
return;
+4 -4
View File
@@ -43,17 +43,17 @@ void handler_i_have(uint8_t * service_request,
len = ihave_decode_service_request(service_request,
service_len, &data);
if (len != -1) {
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "I-Have: %s %d from %s %u!\r\n",
bactext_object_type_name(data.object_id.type),
data.object_id.instance,
bactext_object_type_name(data.device_id.type),
data.device_id.instance);
#endif
#endif
} else {
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "I-Have: received, but unable to decode!\n");
#endif
#endif
}
return;
+14 -14
View File
@@ -55,46 +55,46 @@ void handler_reinitialize_device(uint8_t * service_request,
/* decode the service request only */
len = rd_decode_service_request(service_request,
service_len, &state, &their_password);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "ReinitializeDevice!\n");
if (len > 0)
fprintf(stderr, "ReinitializeDevice: state=%u password=%s\n",
(unsigned) state, characterstring_value(&their_password));
else
fprintf(stderr, "ReinitializeDevice: Unable to decode request!\n");
#endif
#endif
/* bad decoding or something we didn't understand - send an abort */
if (len < 0) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, ABORT_REASON_OTHER);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"ReinitializeDevice: Sending Abort - could not decode.\n");
#endif
#endif
} else if (service_data->segmented_message) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"ReinitializeDevice: Sending Abort - segmented message.\n");
#endif
#endif
} else if (state >= MAX_BACNET_REINITIALIZED_STATE) {
pdu_len = reject_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, REJECT_REASON_UNDEFINED_ENUMERATION);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"ReinitializeDevice: Sending Reject - undefined enumeration\n");
#endif
#endif
} else {
characterstring_init_ansi(&My_Password, Password);
if (characterstring_same(&their_password, &My_Password)) {
pdu_len = encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_REINITIALIZE_DEVICE);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "ReinitializeDevice: Sending Simple Ack!\n");
#endif
#endif
/* FIXME: now you can reboot, restart, quit, or something clever */
/* Note: you can use a mix of state and password to do specific stuff */
/* Note: if you don't do something clever like actually restart,
@@ -105,20 +105,20 @@ void handler_reinitialize_device(uint8_t * service_request,
service_data->invoke_id,
SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
ERROR_CLASS_SERVICES, ERROR_CODE_PASSWORD_FAILURE);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"ReinitializeDevice: Sending Error - password failure.\n");
#endif
#endif
}
}
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n",
strerror(errno));
#endif
#endif
return;
}
+37 -36
View File
@@ -66,25 +66,25 @@ void handler_read_property(uint8_t * service_request,
BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT;
len = rp_decode_service_request(service_request, service_len, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (len <= 0)
fprintf(stderr, "Unable to decode Read-Property Request!\n");
#endif
#endif
/* bad decoding - send an abort */
if (len < 0) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, ABORT_REASON_OTHER);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Abort!\n");
#endif
#endif
send = true;
} else if (service_data->segmented_message) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Abort!\n");
#endif
#endif
send = true;
} else {
switch (data.object_type) {
@@ -99,12 +99,13 @@ void handler_read_property(uint8_t * service_request,
data.application_data = &Temp_Buf[0];
data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */
pdu_len = rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Read Property Ack for Device!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -125,9 +126,9 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for AI!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -148,9 +149,9 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for BI!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -168,11 +169,12 @@ void handler_read_property(uint8_t * service_request,
data.application_data = &Temp_Buf[0];
data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */
pdu_len = rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for BO!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -193,9 +195,9 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for BV!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -216,9 +218,9 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for AO!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -239,9 +241,9 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for AV!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -262,10 +264,10 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Read Property Ack for LSP!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -286,10 +288,10 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Read Property Ack for MSO!\n");
#endif
#endif
send = true;
} else
error = true;
@@ -311,17 +313,17 @@ void handler_read_property(uint8_t * service_request,
pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Read Property Ack for File!\n");
#endif
#endif
send = true;
} else
error = true;
} else
error = true;
break;
#endif /* BACFILE */
#endif /* BACFILE */
default:
error = true;
break;
@@ -331,19 +333,18 @@ void handler_read_property(uint8_t * service_request,
pdu_len = bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_READ_PROPERTY, error_class, error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Error!\n");
#endif
#endif
send = true;
}
if (send) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
#if PRINT_ENABLED
bytes_sent = datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
#endif
#endif
}
return;
+44 -44
View File
@@ -64,7 +64,7 @@ void handler_write_property(uint8_t * service_request,
/* decode the service request only */
len = wp_decode_service_request(service_request,
service_len, &wp_data);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Received Write-Property Request!\n");
if (len > 0)
fprintf(stderr, "type=%u instance=%u property=%u index=%d\n",
@@ -73,21 +73,21 @@ void handler_write_property(uint8_t * service_request,
wp_data.object_property, wp_data.array_index);
else
fprintf(stderr, "Unable to decode Write-Property Request!\n");
#endif
#endif
/* bad decoding or something we didn't understand - send an abort */
if (len <= 0) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, ABORT_REASON_OTHER);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Abort!\n");
#endif
#endif
} else if (service_data->segmented_message) {
pdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Abort!\n");
#endif
#endif
} else {
switch (wp_data.object_type) {
case OBJECT_DEVICE:
@@ -96,20 +96,20 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for Device!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Error for Device!\n");
#endif
#endif
}
break;
case OBJECT_ANALOG_INPUT:
@@ -120,9 +120,9 @@ void handler_write_property(uint8_t * service_request,
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
error_class, error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error!\n");
#endif
#endif
break;
case OBJECT_BINARY_OUTPUT:
if (Binary_Output_Write_Property(&wp_data, &error_class,
@@ -131,19 +131,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for BO!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for BO!\n");
#endif
#endif
}
break;
case OBJECT_BINARY_VALUE:
@@ -153,19 +153,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for BV!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for BV!\n");
#endif
#endif
}
break;
case OBJECT_ANALOG_OUTPUT:
@@ -175,19 +175,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for AO!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for AO!\n");
#endif
#endif
}
break;
case OBJECT_ANALOG_VALUE:
@@ -197,19 +197,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for AV!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for AV!\n");
#endif
#endif
}
break;
case OBJECT_LIFE_SAFETY_POINT:
@@ -219,19 +219,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for LSP!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for LSP!\n");
#endif
#endif
}
break;
case OBJECT_MULTI_STATE_OUTPUT:
@@ -241,19 +241,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for MSO!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for MSO!\n");
#endif
#endif
}
break;
#if BACFILE
@@ -264,19 +264,19 @@ void handler_write_property(uint8_t * service_request,
encode_simple_ack(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Sending Write Property Simple Ack for File!\n");
#endif
#endif
} else {
pdu_len =
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id,
SERVICE_CONFIRMED_WRITE_PROPERTY, error_class,
error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Write Access Error for File!\n");
#endif
#endif
}
break;
#endif
@@ -285,19 +285,19 @@ void handler_write_property(uint8_t * service_request,
bacerror_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, SERVICE_CONFIRMED_WRITE_PROPERTY,
error_class, error_code);
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Sending Unknown Object Error!\n");
#endif
#endif
break;
}
}
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(src, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
#endif
#endif
return;
}
+2 -2
View File
@@ -53,10 +53,10 @@ void handler_unrecognized_service(uint8_t * service_request,
/* send the data */
bytes_sent = datalink_send_pdu(dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent > 0)
fprintf(stderr, "Sent Reject!\n");
else
fprintf(stderr, "Failed to Send Reject (%s)!\n", strerror(errno));
#endif
#endif
}
+10 -8
View File
@@ -74,24 +74,26 @@ uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
npdu_encode_confirmed_apdu(&npdu_data,
MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send AtomicReadFile Request (%s)!\n",
strerror(errno));
#endif
#endif
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send AtomicReadFile Request "
"(payload exceeds destination maximum APDU)!\n");
#endif
#endif
}
}
+12 -11
View File
@@ -75,37 +75,38 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((unsigned) pdu_len <= max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
npdu_encode_confirmed_apdu(&npdu_data,
MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send AtomicWriteFile Request (%s)!\n",
strerror(errno));
#endif
#endif
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send AtomicWriteFile Request "
"(payload [%d] exceeds destination maximum APDU [%u])!\n",
pdu_len, max_apdu);
#endif
#endif
}
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send AtomicWriteFile Request "
"(payload [%d] exceeds octet string capacity)!\n",
pdu_len);
#endif
#endif
}
}
return invoke_id;
}
+10 -8
View File
@@ -73,25 +73,27 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t t
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
npdu_encode_confirmed_apdu(&npdu_data,
MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send DeviceCommunicationControl Request (%s)!\n",
strerror(errno));
#endif
#endif
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr,
"Failed to Send DeviceCommunicationControl Request "
"(exceeds destination maximum APDU)!\n");
#endif
#endif
}
}
+3 -4
View File
@@ -67,11 +67,10 @@ void Send_I_Have(uint32_t device_id,
pdu_len = ihave_encode_apdu(&Handler_Transmit_Buffer[0], &data);
/* send the data */
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
#if PRINT_ENABLED
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send I-Have Reply (%s)!\n",
strerror(errno));
#endif
#endif
}
+10 -8
View File
@@ -73,24 +73,26 @@ uint8_t Send_Reinitialize_Device_Request(uint32_t device_id,
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
npdu_encode_confirmed_apdu(&npdu_data,
MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send ReinitializeDevice Request (%s)!\n",
strerror(errno));
#endif
#endif
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send ReinitializeDevice Request "
"(exceeds destination maximum APDU)!\n");
#endif
#endif
}
}
+10 -8
View File
@@ -79,24 +79,26 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
npdu_encode_confirmed_apdu(&npdu_data,
MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send ReadProperty Request (%s)!\n",
strerror(errno));
#endif
#endif
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send ReadProperty Request "
"(exceeds destination maximum APDU)!\n");
#endif
#endif
}
}
+4 -4
View File
@@ -61,12 +61,12 @@ void Send_TimeSync(BACNET_DATE * bdate, BACNET_TIME * btime)
/* send it out the datalink */
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send Time-Synchronization Request (%s)!\n",
strerror(errno));
#endif
#endif
}
void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime)
@@ -87,10 +87,10 @@ void Send_TimeSyncUTC(BACNET_DATE * bdate, BACNET_TIME * btime)
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send UTC-Time-Synchronization Request (%s)!\n",
strerror(errno));
#endif
#endif
}
+5 -6
View File
@@ -62,17 +62,16 @@ void Send_WhoHas_Name(int32_t low_limit,
data.high_limit = high_limit;
data.object_name = true;
characterstring_init_ansi(&data.object.name, object_name);
pdu_len = whohas_encode_apdu(&Handler_Transmit_Buffer[0],
&data);
pdu_len = whohas_encode_apdu(&Handler_Transmit_Buffer[0], &data);
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
/* send the data */
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Who-Has Request (%s)!\n",
strerror(errno));
#endif
#endif
}
/* find a specific device, or use -1 for limit if you want unlimited */
@@ -101,9 +100,9 @@ void Send_WhoHas_Object(int32_t low_limit,
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Who-Has Request (%s)!\n",
strerror(errno));
#endif
#endif
}
+2 -2
View File
@@ -61,9 +61,9 @@ void Send_WhoIs(int32_t low_limit, int32_t high_limit)
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Who-Is Request (%s)!\n",
strerror(errno));
#endif
#endif
}
+10 -8
View File
@@ -83,24 +83,26 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */
we have a way to check for that and update the
max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent = datalink_send_pdu(&dest, &npdu_data,
npdu_encode_confirmed_apdu(&npdu_data,
MESSAGE_PRIORITY_NORMAL);
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED
#if PRINT_ENABLED
if (bytes_sent <= 0)
fprintf(stderr,
"Failed to Send WriteProperty Request (%s)!\n",
strerror(errno));
#endif
#endif
} else {
tsm_free_invoke_id(invoke_id);
invoke_id = 0;
#if PRINT_ENABLED
#if PRINT_ENABLED
fprintf(stderr, "Failed to Send WriteProperty Request "
"(exceeds destination maximum APDU)!\n");
#endif
#endif
}
}