Changed all the C++ comments to C comments using comment.sh script.
This commit is contained in:
@@ -58,7 +58,7 @@ extern "C" {
|
||||
BACNET_PROPERTY_ID object_property, int32_t array_index);
|
||||
|
||||
/* returns the invoke ID for confirmed request, or 0 if failed */
|
||||
uint8_t Send_Write_Property_Request(uint32_t device_id, // destination device
|
||||
uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
|
||||
@@ -59,12 +59,12 @@ void handler_atomic_read_file(uint8_t * service_request,
|
||||
len = arf_decode_service_request(service_request, service_len, &data);
|
||||
if (len < 0)
|
||||
fprintf(stderr, "Unable to decode Atomic-Read-File Request!\n");
|
||||
// prepare a reply
|
||||
/* prepare a reply */
|
||||
datalink_get_my_address(&my_address);
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
// bad decoding - send an abort
|
||||
/* bad decoding - send an abort */
|
||||
if (len < 0) {
|
||||
pdu_len += abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER);
|
||||
@@ -112,8 +112,8 @@ void handler_atomic_read_file(uint8_t * service_request,
|
||||
send = true;
|
||||
}
|
||||
if (send) {
|
||||
bytes_sent = datalink_send_pdu(src, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(src, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
#include "handlers.h"
|
||||
#include "txbuf.h"
|
||||
|
||||
// We performed an AtomicReadFile Request,
|
||||
// and here is the data from the server
|
||||
// Note: it does not have to be the same file=instance
|
||||
// that someone can read from us. It is common to
|
||||
// use the description as the file name.
|
||||
/* We performed an AtomicReadFile Request, */
|
||||
/* and here is the data from the server */
|
||||
/* Note: it does not have to be the same file=instance */
|
||||
/* that someone can read from us. It is common to */
|
||||
/* use the description as the file name. */
|
||||
#if BACFILE
|
||||
void handler_atomic_read_file_ack(uint8_t * service_request,
|
||||
uint16_t service_len,
|
||||
@@ -58,13 +58,13 @@ void handler_atomic_read_file_ack(uint8_t * service_request,
|
||||
uint32_t instance = 0;
|
||||
|
||||
(void) src;
|
||||
// get the file instance from the tsm data before freeing it
|
||||
/* get the file instance from the tsm data before freeing it */
|
||||
instance = bacfile_instance_from_tsm(service_data->invoke_id);
|
||||
len = arf_ack_decode_service_request(service_request,
|
||||
service_len, &data);
|
||||
fprintf(stderr, "Received Read-File Ack!\n");
|
||||
if ((len > 0) && (instance <= BACNET_MAX_INSTANCE)) {
|
||||
// write the data received to the file specified
|
||||
/* write the data received to the file specified */
|
||||
if (data.access == FILE_STREAM_ACCESS) {
|
||||
pFilename = bacfile_name(instance);
|
||||
if (pFilename) {
|
||||
@@ -81,7 +81,7 @@ void handler_atomic_read_file_ack(uint8_t * service_request,
|
||||
}
|
||||
}
|
||||
} else if (data.access == FILE_RECORD_ACCESS) {
|
||||
// FIXME: add handling for Record Access
|
||||
/* FIXME: add handling for Record Access */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ void handler_device_communication_control(uint8_t * service_request,
|
||||
BACNET_ADDRESS my_address;
|
||||
int bytes_sent = 0;
|
||||
|
||||
// decode the service request only
|
||||
/* decode the service request only */
|
||||
len = dcc_decode_service_request(service_request,
|
||||
service_len, &timeDuration, &state, &password);
|
||||
fprintf(stderr, "DeviceCommunicationControl!\n");
|
||||
@@ -64,12 +64,12 @@ void handler_device_communication_control(uint8_t * service_request,
|
||||
else
|
||||
fprintf(stderr, "DeviceCommunicationControl: "
|
||||
"Unable to decode request!\n");
|
||||
// prepare a reply
|
||||
/* prepare a reply */
|
||||
datalink_get_my_address(&my_address);
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
// bad decoding or something we didn't understand - send an abort
|
||||
/* bad decoding or something we didn't understand - send an abort */
|
||||
if (len == -1) {
|
||||
pdu_len += abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER);
|
||||
@@ -105,8 +105,8 @@ void handler_device_communication_control(uint8_t * service_request,
|
||||
"Sending Error - password failure.\n");
|
||||
}
|
||||
}
|
||||
bytes_sent = datalink_send_pdu(src, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(src, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "DeviceCommunicationControl: "
|
||||
"Failed to send PDU (%s)!\n", strerror(errno));
|
||||
|
||||
@@ -66,7 +66,7 @@ void handler_i_am_bind(uint8_t * service_request,
|
||||
(void) service_len;
|
||||
len = iam_decode_service_request(service_request,
|
||||
&device_id, &max_apdu, &segmentation, &vendor_id);
|
||||
// only add address if requested to bind
|
||||
/* only add address if requested to bind */
|
||||
address_add_binding(device_id, max_apdu, src);
|
||||
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ void handler_reinitialize_device(uint8_t * service_request,
|
||||
BACNET_ADDRESS my_address;
|
||||
int bytes_sent = 0;
|
||||
|
||||
// decode the service request only
|
||||
/* decode the service request only */
|
||||
len = rd_decode_service_request(service_request,
|
||||
service_len, &state, &password);
|
||||
fprintf(stderr, "ReinitializeDevice!\n");
|
||||
@@ -60,12 +60,12 @@ void handler_reinitialize_device(uint8_t * service_request,
|
||||
(unsigned) state, characterstring_value(&password));
|
||||
else
|
||||
fprintf(stderr, "ReinitializeDevice: Unable to decode request!\n");
|
||||
// prepare a reply
|
||||
/* prepare a reply */
|
||||
datalink_get_my_address(&my_address);
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
// bad decoding or something we didn't understand - send an abort
|
||||
/* bad decoding or something we didn't understand - send an abort */
|
||||
if (len == -1) {
|
||||
pdu_len += abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER);
|
||||
@@ -103,8 +103,8 @@ void handler_reinitialize_device(uint8_t * service_request,
|
||||
"ReinitializeDevice: Sending Error - password failure.\n");
|
||||
}
|
||||
}
|
||||
bytes_sent = datalink_send_pdu(src, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(src, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n",
|
||||
strerror(errno));
|
||||
|
||||
@@ -62,12 +62,12 @@ void handler_read_property(uint8_t * service_request,
|
||||
len = rp_decode_service_request(service_request, service_len, &data);
|
||||
if (len <= 0)
|
||||
fprintf(stderr, "Unable to decode Read-Property Request!\n");
|
||||
// prepare a reply
|
||||
/* prepare a reply */
|
||||
datalink_get_my_address(&my_address);
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
// bad decoding - send an abort
|
||||
/* bad decoding - send an abort */
|
||||
if (len == -1) {
|
||||
pdu_len += abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER);
|
||||
@@ -82,16 +82,16 @@ void handler_read_property(uint8_t * service_request,
|
||||
} else {
|
||||
switch (data.object_type) {
|
||||
case OBJECT_DEVICE:
|
||||
// FIXME: probably need a length limitation sent with encode
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
if (data.object_instance == Device_Object_Instance_Number()) {
|
||||
len = Device_Encode_Property_APDU(&Temp_Buf[0],
|
||||
data.object_property,
|
||||
data.array_index, &error_class, &error_code);
|
||||
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_len = len;
|
||||
// FIXME: probably need a length limitation sent with encode
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
pdu_len +=
|
||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
||||
[pdu_len], service_data->invoke_id, &data);
|
||||
@@ -109,10 +109,10 @@ void handler_read_property(uint8_t * service_request,
|
||||
data.object_property,
|
||||
data.array_index, &error_class, &error_code);
|
||||
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_len = len;
|
||||
// FIXME: probably need a length limitation sent with encode
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
pdu_len +=
|
||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
||||
[pdu_len], service_data->invoke_id, &data);
|
||||
@@ -130,10 +130,10 @@ void handler_read_property(uint8_t * service_request,
|
||||
data.object_property,
|
||||
data.array_index, &error_class, &error_code);
|
||||
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_len = len;
|
||||
// FIXME: probably need a length limitation sent with encode
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
pdu_len +=
|
||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
||||
[pdu_len], service_data->invoke_id, &data);
|
||||
@@ -152,10 +152,10 @@ void handler_read_property(uint8_t * service_request,
|
||||
data.object_property,
|
||||
data.array_index, &error_class, &error_code);
|
||||
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_len = len;
|
||||
// FIXME: probably need a length limitation sent with encode
|
||||
/* FIXME: probably need a length limitation sent with encode */
|
||||
pdu_len +=
|
||||
rp_ack_encode_apdu(&Handler_Transmit_Buffer
|
||||
[pdu_len], service_data->invoke_id, &data);
|
||||
@@ -180,8 +180,8 @@ void handler_read_property(uint8_t * service_request,
|
||||
send = true;
|
||||
}
|
||||
if (send) {
|
||||
bytes_sent = datalink_send_pdu(src, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(src, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ void handler_write_property(uint8_t * service_request,
|
||||
BACNET_ERROR_CODE error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
int bytes_sent = 0;
|
||||
|
||||
// decode the service request only
|
||||
/* decode the service request only */
|
||||
len = wp_decode_service_request(service_request,
|
||||
service_len, &wp_data);
|
||||
fprintf(stderr, "Received Write-Property Request!\n");
|
||||
@@ -66,12 +66,12 @@ 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");
|
||||
// prepare a reply
|
||||
/* prepare a reply */
|
||||
datalink_get_my_address(&my_address);
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], src, &my_address, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
// bad decoding or something we didn't understand - send an abort
|
||||
/* bad decoding or something we didn't understand - send an abort */
|
||||
if (len == -1) {
|
||||
pdu_len += abort_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, ABORT_REASON_OTHER);
|
||||
@@ -134,8 +134,8 @@ void handler_write_property(uint8_t * service_request,
|
||||
break;
|
||||
}
|
||||
}
|
||||
bytes_sent = datalink_send_pdu(src, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(src, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
|
||||
|
||||
|
||||
@@ -46,16 +46,16 @@ void handler_unrecognized_service(uint8_t * service_request,
|
||||
(void) service_len;
|
||||
datalink_get_my_address(&src);
|
||||
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], dest, &src, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], dest, &src, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
// encode the APDU portion of the packet
|
||||
/* encode the APDU portion of the packet */
|
||||
pdu_len += reject_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
|
||||
|
||||
bytes_sent = datalink_send_pdu(dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent > 0)
|
||||
fprintf(stderr, "Sent Reject!\n");
|
||||
else
|
||||
|
||||
@@ -63,11 +63,11 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t t
|
||||
status = tsm_transaction_available();
|
||||
if (status) {
|
||||
datalink_get_my_address(&my_address);
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, // true for confirmed messages
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
// load the data for the encoding
|
||||
/* load the data for the encoding */
|
||||
characterstring_init_ansi(&password_string, password);
|
||||
pdu_len += dcc_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
invoke_id,
|
||||
@@ -80,8 +80,8 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t t
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
||||
&dest, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send DeviceCommunicationControl Request (%s)!\n",
|
||||
|
||||
@@ -68,8 +68,8 @@ void Send_I_Have(uint32_t device_id,
|
||||
characterstring_init_ansi(&data.object_name, object_name);
|
||||
pdu_len += ihave_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data);
|
||||
/* send the data */
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send I-Have Reply (%s)!\n",
|
||||
strerror(errno));
|
||||
|
||||
@@ -64,11 +64,11 @@ uint8_t Send_Reinitialize_Device_Request(uint32_t device_id,
|
||||
status = tsm_transaction_available();
|
||||
if (status) {
|
||||
datalink_get_my_address(&my_address);
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, // true for confirmed messages
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
// load the data for the encoding
|
||||
/* load the data for the encoding */
|
||||
characterstring_init_ansi(&password_string, password);
|
||||
pdu_len += rd_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
invoke_id, state, password ? &password_string : NULL);
|
||||
@@ -80,8 +80,8 @@ uint8_t Send_Reinitialize_Device_Request(uint32_t device_id,
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
||||
&dest, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send ReinitializeDevice Request (%s)!\n",
|
||||
|
||||
@@ -67,11 +67,11 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
|
||||
status = tsm_transaction_available();
|
||||
if (status) {
|
||||
datalink_get_my_address(&my_address);
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, // true for confirmed messages
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
// load the data for the encoding
|
||||
/* load the data for the encoding */
|
||||
data.object_type = object_type;
|
||||
data.object_instance = object_instance;
|
||||
data.object_property = object_property;
|
||||
@@ -86,8 +86,8 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
||||
&dest, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send ReadProperty Request (%s)!\n",
|
||||
|
||||
@@ -67,8 +67,8 @@ void Send_WhoHas_Name(int32_t low_limit,
|
||||
pdu_len += whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
&data);
|
||||
/* send the data */
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Who-Has Request (%s)!\n",
|
||||
strerror(errno));
|
||||
@@ -101,8 +101,8 @@ void Send_WhoHas_Object(int32_t low_limit,
|
||||
pdu_len += whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
&data);
|
||||
/* send the data */
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Who-Has Request (%s)!\n",
|
||||
strerror(errno));
|
||||
|
||||
@@ -52,19 +52,19 @@ void Send_WhoIs(int32_t low_limit, int32_t high_limit)
|
||||
if (!dcc_communication_enabled())
|
||||
return;
|
||||
|
||||
// Who-Is is a global broadcast
|
||||
/* Who-Is is a global broadcast */
|
||||
datalink_get_broadcast_address(&dest);
|
||||
|
||||
// encode the NPDU portion of the packet
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, NULL, false, // true for confirmed messages
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, NULL, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
// encode the APDU portion of the packet
|
||||
/* encode the APDU portion of the packet */
|
||||
pdu_len += whois_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||
low_limit, high_limit);
|
||||
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Who-Is Request (%s)!\n",
|
||||
strerror(errno));
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "txbuf.h"
|
||||
|
||||
/* returns the invoke ID for confirmed request, or zero on failure */
|
||||
uint8_t Send_Write_Property_Request(uint32_t device_id, // destination device
|
||||
uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
@@ -69,11 +69,11 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, // destination device
|
||||
status = tsm_transaction_available();
|
||||
if (status) {
|
||||
datalink_get_my_address(&my_address);
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, // true for confirmed messages
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
// load the data for the encoding
|
||||
/* load the data for the encoding */
|
||||
data.object_type = object_type;
|
||||
data.object_instance = object_instance;
|
||||
data.object_property = object_property;
|
||||
@@ -90,8 +90,8 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, // destination device
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
||||
&dest, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send WriteProperty Request (%s)!\n",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
// Analog Input Objects customize for your use
|
||||
/* Analog Input Objects customize for your use */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -31,13 +31,13 @@
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "bacenum.h"
|
||||
#include "config.h" // the custom stuff
|
||||
#include "config.h" /* the custom stuff */
|
||||
|
||||
#define MAX_ANALOG_INPUTS 7
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then you need validate that the
|
||||
// given instance exists
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need validate that the */
|
||||
/* given instance exists */
|
||||
bool Analog_Input_Valid_Instance(uint32_t object_instance)
|
||||
{
|
||||
if (object_instance < MAX_ANALOG_INPUTS)
|
||||
@@ -46,16 +46,16 @@ bool Analog_Input_Valid_Instance(uint32_t object_instance)
|
||||
return false;
|
||||
}
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then count how many you have
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then count how many you have */
|
||||
unsigned Analog_Input_Count(void)
|
||||
{
|
||||
return MAX_ANALOG_INPUTS;
|
||||
}
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then you need to return the instance
|
||||
// that correlates to the correct index
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need to return the instance */
|
||||
/* that correlates to the correct index */
|
||||
uint32_t Analog_Input_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return index;
|
||||
@@ -81,7 +81,7 @@ int Analog_Input_Encode_Property_APDU(uint8_t * apdu,
|
||||
int32_t array_index,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
int apdu_len = 0; // return value
|
||||
int apdu_len = 0; /* return value */
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
float value = 3.14;
|
||||
@@ -149,7 +149,7 @@ void testAnalogInput(Test * pTest)
|
||||
BACNET_ERROR_CODE error_code;
|
||||
|
||||
|
||||
// FIXME: we should do a lot more testing here...
|
||||
/* FIXME: we should do a lot more testing here... */
|
||||
len = Analog_Input_Encode_Property_APDU(&apdu[0],
|
||||
instance,
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
// Analog Output Objects - customize for your use
|
||||
/* Analog Output Objects - customize for your use */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -31,28 +31,28 @@
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "bacenum.h"
|
||||
#include "config.h" // the custom stuff
|
||||
#include "config.h" /* the custom stuff */
|
||||
#include "wp.h"
|
||||
|
||||
#define MAX_ANALOG_OUTPUTS 4
|
||||
|
||||
// we choose to have a NULL level in our system represented by
|
||||
// a particular value. When the priorities are not in use, they
|
||||
// will be relinquished (i.e. set to the NULL level).
|
||||
/* we choose to have a NULL level in our system represented by */
|
||||
/* a particular value. When the priorities are not in use, they */
|
||||
/* will be relinquished (i.e. set to the NULL level). */
|
||||
#define AO_LEVEL_NULL 255
|
||||
// When all the priorities are level null, the present value returns
|
||||
// the Relinquish Default value
|
||||
/* When all the priorities are level null, the present value returns */
|
||||
/* the Relinquish Default value */
|
||||
#define AO_RELINQUISH_DEFAULT 0
|
||||
// Here is our Priority Array. They are supposed to be Real, but
|
||||
// we don't have that kind of memory, so we will use a single byte
|
||||
// and load a Real for returning the value when asked.
|
||||
/* Here is our Priority Array. They are supposed to be Real, but */
|
||||
/* we don't have that kind of memory, so we will use a single byte */
|
||||
/* and load a Real for returning the value when asked. */
|
||||
static uint8_t
|
||||
Analog_Output_Level[MAX_ANALOG_OUTPUTS][BACNET_MAX_PRIORITY];
|
||||
// Writable out-of-service allows others to play with our Present Value
|
||||
// without changing the physical output
|
||||
/* Writable out-of-service allows others to play with our Present Value */
|
||||
/* without changing the physical output */
|
||||
static bool Analog_Output_Out_Of_Service[MAX_ANALOG_OUTPUTS];
|
||||
|
||||
// we need to have our arrays initialized before answering any calls
|
||||
/* we need to have our arrays initialized before answering any calls */
|
||||
static bool Analog_Ouput_Initialized = false;
|
||||
|
||||
void Analog_Output_Init(void)
|
||||
@@ -62,7 +62,7 @@ void Analog_Output_Init(void)
|
||||
if (!Analog_Ouput_Initialized) {
|
||||
Analog_Ouput_Initialized = true;
|
||||
|
||||
// initialize all the analog output priority arrays to NULL
|
||||
/* initialize all the analog output priority arrays to NULL */
|
||||
for (i = 0; i < MAX_ANALOG_OUTPUTS; i++) {
|
||||
for (j = 0; j < BACNET_MAX_PRIORITY; j++) {
|
||||
Analog_Output_Level[i][j] = AO_LEVEL_NULL;
|
||||
@@ -73,9 +73,9 @@ void Analog_Output_Init(void)
|
||||
return;
|
||||
}
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then you need validate that the
|
||||
// given instance exists
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need validate that the */
|
||||
/* given instance exists */
|
||||
bool Analog_Output_Valid_Instance(uint32_t object_instance)
|
||||
{
|
||||
Analog_Output_Init();
|
||||
@@ -85,26 +85,26 @@ bool Analog_Output_Valid_Instance(uint32_t object_instance)
|
||||
return false;
|
||||
}
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then count how many you have
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then count how many you have */
|
||||
unsigned Analog_Output_Count(void)
|
||||
{
|
||||
Analog_Output_Init();
|
||||
return MAX_ANALOG_OUTPUTS;
|
||||
}
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then you need to return the instance
|
||||
// that correlates to the correct index
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need to return the instance */
|
||||
/* that correlates to the correct index */
|
||||
uint32_t Analog_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
Analog_Output_Init();
|
||||
return index;
|
||||
}
|
||||
|
||||
// we simply have 0-n object instances. Yours might be
|
||||
// more complex, and then you need to return the index
|
||||
// that correlates to the correct instance number
|
||||
/* we simply have 0-n object instances. Yours might be */
|
||||
/* more complex, and then you need to return the index */
|
||||
/* that correlates to the correct instance number */
|
||||
unsigned Analog_Output_Instance_To_Index(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = MAX_ANALOG_OUTPUTS;
|
||||
@@ -157,7 +157,7 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
int len = 0;
|
||||
int apdu_len = 0; // return value
|
||||
int apdu_len = 0; /* return value */
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
float real_value = 1.414;
|
||||
@@ -202,24 +202,24 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], UNITS_PERCENT);
|
||||
break;
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
// Array element zero is the number of elements in the array
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (array_index == BACNET_ARRAY_LENGTH_INDEX)
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], BACNET_MAX_PRIORITY);
|
||||
// if no index was specified, then try to encode the entire list
|
||||
// into one packet.
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (array_index == BACNET_ARRAY_ALL) {
|
||||
object_index =
|
||||
Analog_Output_Instance_To_Index(object_instance);
|
||||
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||
// FIXME: check if we have room before adding it to APDU
|
||||
/* FIXME: check if we have room before adding it to APDU */
|
||||
if (Analog_Output_Level[object_index][i] == AO_LEVEL_NULL)
|
||||
len = encode_tagged_null(&apdu[apdu_len]);
|
||||
else {
|
||||
real_value = Analog_Output_Level[object_index][i];
|
||||
len = encode_tagged_real(&apdu[apdu_len], real_value);
|
||||
}
|
||||
// add it if we have room
|
||||
/* add it if we have room */
|
||||
if ((apdu_len + len) < MAX_APDU)
|
||||
apdu_len += len;
|
||||
else {
|
||||
@@ -263,11 +263,11 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
// returns true if successful
|
||||
/* returns true if successful */
|
||||
bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
bool status = false; // return value
|
||||
bool status = false; /* return value */
|
||||
unsigned int object_index = 0;
|
||||
unsigned int priority = 0;
|
||||
uint8_t level = AO_LEVEL_NULL;
|
||||
@@ -278,7 +278,7 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
return false;
|
||||
}
|
||||
// decode the some of the request
|
||||
/* decode the some of the request */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_REAL) {
|
||||
@@ -293,9 +293,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
object_instance);
|
||||
priority--;
|
||||
Analog_Output_Level[object_index][priority] = level;
|
||||
// if Out of Service is TRUE, then don't set the
|
||||
// physical output. This comment may apply to the
|
||||
// main loop (i.e. check out of service before changing output)
|
||||
/* if Out of Service is TRUE, then don't set the */
|
||||
/* physical output. This comment may apply to the */
|
||||
/* main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else if (priority == 6) {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -48,7 +48,7 @@ static BACNET_FILE_LISTING BACnet_File_Listing[] = {
|
||||
{0, "test.log"},
|
||||
{1, "script.txt"},
|
||||
{2, "bacenum.h"},
|
||||
{0, NULL} // last file indication
|
||||
{0, NULL} /* last file indication */
|
||||
};
|
||||
|
||||
char *bacfile_name(uint32_t instance)
|
||||
@@ -56,7 +56,7 @@ char *bacfile_name(uint32_t instance)
|
||||
uint32_t index = 0;
|
||||
char *filename = NULL;
|
||||
|
||||
// linear search for file instance match
|
||||
/* linear search for file instance match */
|
||||
while (BACnet_File_Listing[index].filename) {
|
||||
if (BACnet_File_Listing[index].instance == instance) {
|
||||
filename = BACnet_File_Listing[index].filename;
|
||||
@@ -77,7 +77,7 @@ uint32_t bacfile_count(void)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
|
||||
// linear search for file instance match
|
||||
/* linear search for file instance match */
|
||||
while (BACnet_File_Listing[index].filename) {
|
||||
index++;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ uint32_t bacfile_index_to_instance(unsigned find_index)
|
||||
uint32_t instance = BACNET_MAX_INSTANCE + 1;
|
||||
uint32_t index = 0;
|
||||
|
||||
// bounds checking...
|
||||
/* bounds checking... */
|
||||
while (BACnet_File_Listing[index].filename) {
|
||||
if (index == find_index) {
|
||||
instance = BACnet_File_Listing[index].instance;
|
||||
@@ -141,7 +141,7 @@ int bacfile_encode_property_apdu(uint8_t * apdu,
|
||||
int32_t array_index,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
int apdu_len = 0; // return value
|
||||
int apdu_len = 0; /* return value */
|
||||
char text_string[32] = { "" };
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
|
||||
@@ -173,18 +173,18 @@ int bacfile_encode_property_apdu(uint8_t * apdu,
|
||||
bacfile_file_size(object_instance));
|
||||
break;
|
||||
case PROP_MODIFICATION_DATE:
|
||||
// FIXME: get the actual value
|
||||
/* FIXME: get the actual value */
|
||||
apdu_len = encode_tagged_date(&apdu[0],
|
||||
2005, 12, 25, 7 /* sunday */ );
|
||||
// FIXME: get the actual value
|
||||
/* FIXME: get the actual value */
|
||||
apdu_len += encode_tagged_time(&apdu[apdu_len], 12, 0, 0, 0);
|
||||
break;
|
||||
case PROP_ARCHIVE:
|
||||
// FIXME: get the actual value: note it may be inverse...
|
||||
/* FIXME: get the actual value: note it may be inverse... */
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], true);
|
||||
break;
|
||||
case PROP_READ_ONLY:
|
||||
// FIXME: get the actual value
|
||||
/* FIXME: get the actual value */
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], true);
|
||||
break;
|
||||
case PROP_FILE_ACCESS_METHOD:
|
||||
@@ -205,7 +205,7 @@ uint32_t bacfile_instance(char *filename)
|
||||
uint32_t index = 0;
|
||||
uint32_t instance = BACNET_MAX_INSTANCE + 1;
|
||||
|
||||
// linear search for filename match
|
||||
/* linear search for filename match */
|
||||
while (BACnet_File_Listing[index].filename) {
|
||||
if (strcmp(BACnet_File_Listing[index].filename, filename) == 0) {
|
||||
instance = BACnet_File_Listing[index].instance;
|
||||
@@ -218,37 +218,37 @@ uint32_t bacfile_instance(char *filename)
|
||||
}
|
||||
|
||||
#if TSM_ENABLED
|
||||
// this is one way to match up the invoke ID with
|
||||
// the file ID from the AtomicReadFile request.
|
||||
// Another way would be to store the
|
||||
// invokeID and file instance in a list or table
|
||||
// when the request was sent
|
||||
/* this is one way to match up the invoke ID with */
|
||||
/* the file ID from the AtomicReadFile request. */
|
||||
/* Another way would be to store the */
|
||||
/* invokeID and file instance in a list or table */
|
||||
/* when the request was sent */
|
||||
uint32_t bacfile_instance_from_tsm(uint8_t invokeID)
|
||||
{
|
||||
BACNET_NPDU_DATA npdu_data = { 0 }; // dummy for getting npdu length
|
||||
BACNET_NPDU_DATA npdu_data = { 0 }; /* dummy for getting npdu length */
|
||||
BACNET_CONFIRMED_SERVICE_DATA service_data = { 0 };
|
||||
uint8_t service_choice = 0;
|
||||
uint8_t *service_request = NULL;
|
||||
uint16_t service_request_len = 0;
|
||||
BACNET_ADDRESS dest; // where the original packet was destined
|
||||
uint8_t pdu[MAX_PDU] = { 0 }; // original sent packet
|
||||
uint16_t pdu_len = 0; // original packet length
|
||||
uint16_t len = 0; // apdu header length
|
||||
BACNET_ADDRESS dest; /* where the original packet was destined */
|
||||
uint8_t pdu[MAX_PDU] = { 0 }; /* original sent packet */
|
||||
uint16_t pdu_len = 0; /* original packet length */
|
||||
uint16_t len = 0; /* apdu header length */
|
||||
BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; // return value
|
||||
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */
|
||||
bool found = false;
|
||||
int apdu_offset = 0;
|
||||
|
||||
found = tsm_get_transaction_pdu(invokeID, &dest, &pdu[0], &pdu_len);
|
||||
if (found) {
|
||||
apdu_offset = npdu_decode(&pdu[0], // data to decode
|
||||
NULL, // destination address - get the DNET/DLEN/DADR if in there
|
||||
NULL, // source address - get the SNET/SLEN/SADR if in there
|
||||
&npdu_data); // amount of data to decode
|
||||
apdu_offset = npdu_decode(&pdu[0], /* data to decode */
|
||||
NULL, /* destination address - get the DNET/DLEN/DADR if in there */
|
||||
NULL, /* source address - get the SNET/SLEN/SADR if in there */
|
||||
&npdu_data); /* amount of data to decode */
|
||||
if (!npdu_data.network_layer_message &&
|
||||
((pdu[apdu_offset] & 0xF0) ==
|
||||
PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
|
||||
len = apdu_decode_confirmed_service_request(&pdu[apdu_offset], // APDU data
|
||||
len = apdu_decode_confirmed_service_request(&pdu[apdu_offset], /* APDU data */
|
||||
pdu_len - apdu_offset,
|
||||
&service_data,
|
||||
&service_choice, &service_request, &service_request_len);
|
||||
|
||||
@@ -51,18 +51,18 @@ extern "C" {
|
||||
uint32_t bacfile_index_to_instance(unsigned find_index);
|
||||
uint32_t bacfile_instance(char *filename);
|
||||
#if TSM_ENABLED
|
||||
// this is one way to match up the invoke ID with
|
||||
// the file ID from the AtomicReadFile request.
|
||||
// Another way would be to store the
|
||||
// invokeID and file instance in a list or table
|
||||
// when the request was sent
|
||||
/* this is one way to match up the invoke ID with */
|
||||
/* the file ID from the AtomicReadFile request. */
|
||||
/* Another way would be to store the */
|
||||
/* invokeID and file instance in a list or table */
|
||||
/* when the request was sent */
|
||||
uint32_t bacfile_instance_from_tsm(uint8_t invokeID);
|
||||
#endif
|
||||
|
||||
// AtomicReadFile ACK helper
|
||||
/* AtomicReadFile ACK helper */
|
||||
bool bacfile_read_data(BACNET_ATOMIC_READ_FILE_DATA * data);
|
||||
|
||||
// handling for read property service
|
||||
/* handling for read property service */
|
||||
int bacfile_encode_property_apdu(uint8_t * apdu,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID property,
|
||||
|
||||
@@ -107,7 +107,7 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
|
||||
|
||||
bool Device_Valid_Object_Instance_Number(uint32_t object_id)
|
||||
{
|
||||
// BACnet allows for a wildcard instance number
|
||||
/* BACnet allows for a wildcard instance number */
|
||||
return ((Object_Instance_Number == object_id) ||
|
||||
(object_id == BACNET_MAX_INSTANCE));
|
||||
}
|
||||
@@ -137,7 +137,7 @@ BACNET_DEVICE_STATUS Device_System_Status(void)
|
||||
|
||||
void Device_Set_System_Status(BACNET_DEVICE_STATUS status)
|
||||
{
|
||||
// FIXME: bounds check?
|
||||
/* FIXME: bounds check? */
|
||||
System_Status = status;
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ uint16_t Device_APDU_Timeout(void)
|
||||
return APDU_Timeout;
|
||||
}
|
||||
|
||||
// in milliseconds
|
||||
/* in milliseconds */
|
||||
void Device_Set_APDU_Timeout(uint16_t timeout)
|
||||
{
|
||||
APDU_Timeout = timeout;
|
||||
@@ -311,8 +311,8 @@ void Device_Set_Database_Revision(uint8_t revision)
|
||||
Database_Revision = revision;
|
||||
}
|
||||
|
||||
// Since many network clients depend on the object list
|
||||
// for discovery, it must be consistent!
|
||||
/* Since many network clients depend on the object list */
|
||||
/* for discovery, it must be consistent! */
|
||||
unsigned Device_Object_List_Count(void)
|
||||
{
|
||||
unsigned count = 1;
|
||||
@@ -339,7 +339,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
// array index starts at 1, and 1 for the device object
|
||||
/* array index starts at 1, and 1 for the device object */
|
||||
object_index = array_index - 2;
|
||||
if (object_index < Analog_Input_Count()) {
|
||||
*object_type = OBJECT_ANALOG_INPUT;
|
||||
@@ -426,14 +426,14 @@ char *Device_Valid_Object_Id(int object_type, uint32_t object_instance)
|
||||
return name;
|
||||
}
|
||||
|
||||
// return the length of the apdu encoded or -1 for error
|
||||
/* return the length of the apdu encoded or -1 for error */
|
||||
int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
BACNET_PROPERTY_ID property,
|
||||
int32_t array_index,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
int apdu_len = 0; // return value
|
||||
int len = 0; // apdu len intermediate value
|
||||
int apdu_len = 0; /* return value */
|
||||
int len = 0; /* apdu len intermediate value */
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
unsigned i = 0;
|
||||
@@ -480,31 +480,31 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
Application_Software_Version);
|
||||
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
// if you support time
|
||||
//case PROP_LOCAL_TIME:
|
||||
//t = time(NULL);
|
||||
//my_tm = localtime(&t);
|
||||
//apdu_len =
|
||||
// encode_tagged_time(&apdu[0], my_tm->tm_hour, my_tm->tm_min,
|
||||
// my_tm->tm_sec, 0);
|
||||
//break;
|
||||
// if you support date
|
||||
//case PROP_LOCAL_DATE:
|
||||
//t = time(NULL);
|
||||
//my_tm = localtime(&t);
|
||||
// month 1=Jan
|
||||
// day = day of month
|
||||
// wday 1=Monday...7=Sunday
|
||||
//apdu_len = encode_tagged_date(&apdu[0],
|
||||
// my_tm->tm_year+1900,
|
||||
// my_tm->tm_mon + 1,
|
||||
// my_tm->tm_mday, ((my_tm->tm_wday == 0) ? 7 : my_tm->tm_wday));
|
||||
//break;
|
||||
/* if you support time */
|
||||
/*case PROP_LOCAL_TIME: */
|
||||
/*t = time(NULL); */
|
||||
/*my_tm = localtime(&t); */
|
||||
/*apdu_len = */
|
||||
/* encode_tagged_time(&apdu[0], my_tm->tm_hour, my_tm->tm_min, */
|
||||
/* my_tm->tm_sec, 0); */
|
||||
/*break; */
|
||||
/* if you support date */
|
||||
/*case PROP_LOCAL_DATE: */
|
||||
/*t = time(NULL); */
|
||||
/*my_tm = localtime(&t); */
|
||||
/* month 1=Jan */
|
||||
/* day = day of month */
|
||||
/* wday 1=Monday...7=Sunday */
|
||||
/*apdu_len = encode_tagged_date(&apdu[0], */
|
||||
/* my_tm->tm_year+1900, */
|
||||
/* my_tm->tm_mon + 1, */
|
||||
/* my_tm->tm_mday, ((my_tm->tm_wday == 0) ? 7 : my_tm->tm_wday)); */
|
||||
/*break; */
|
||||
case PROP_PROTOCOL_VERSION:
|
||||
apdu_len =
|
||||
encode_tagged_unsigned(&apdu[0], Device_Protocol_Version());
|
||||
break;
|
||||
// BACnet Legacy Support
|
||||
/* BACnet Legacy Support */
|
||||
case PROP_PROTOCOL_CONFORMANCE_CLASS:
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], 1);
|
||||
break;
|
||||
@@ -523,7 +523,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
not a list of objects that this device can access */
|
||||
bitstring_init(&bit_string);
|
||||
for (i = 0; i < MAX_ASHRAE_OBJECT_TYPE; i++) {
|
||||
// initialize all the object types to not-supported
|
||||
/* initialize all the object types to not-supported */
|
||||
bitstring_set_bit(&bit_string, (uint8_t) i, false);
|
||||
}
|
||||
/* FIXME: indicate the objects that YOU support */
|
||||
@@ -537,13 +537,13 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
break;
|
||||
case PROP_OBJECT_LIST:
|
||||
count = Device_Object_List_Count();
|
||||
// Array element zero is the number of objects in the list
|
||||
/* Array element zero is the number of objects in the list */
|
||||
if (array_index == BACNET_ARRAY_LENGTH_INDEX)
|
||||
apdu_len = encode_tagged_unsigned(&apdu[0], count);
|
||||
// if no index was specified, then try to encode the entire list
|
||||
// into one packet. Note that more than likely you will have
|
||||
// to return an error if the number of encoded objects exceeds
|
||||
// your maximum APDU size.
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. Note that more than likely you will have */
|
||||
/* to return an error if the number of encoded objects exceeds */
|
||||
/* your maximum APDU size. */
|
||||
else if (array_index == BACNET_ARRAY_ALL) {
|
||||
for (i = 1; i <= count; i++) {
|
||||
if (Device_Object_List_Identifier(i, &object_type,
|
||||
@@ -552,8 +552,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
encode_tagged_object_id(&apdu[apdu_len],
|
||||
object_type, instance);
|
||||
apdu_len += len;
|
||||
// assume next one is the same size as this one
|
||||
// can we all fit into the APDU?
|
||||
/* assume next one is the same size as this one */
|
||||
/* can we all fit into the APDU? */
|
||||
if ((apdu_len + len) >= MAX_APDU) {
|
||||
*error_class = ERROR_CLASS_SERVICES;
|
||||
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||
@@ -561,7 +561,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// error: internal error?
|
||||
/* error: internal error? */
|
||||
*error_class = ERROR_CLASS_SERVICES;
|
||||
*error_code = ERROR_CODE_OTHER;
|
||||
apdu_len = -1;
|
||||
@@ -609,21 +609,21 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
// we can send an I-Am when our device ID changes
|
||||
/* we can send an I-Am when our device ID changes */
|
||||
extern bool I_Am_Request;
|
||||
|
||||
// returns true if successful
|
||||
/* returns true if successful */
|
||||
bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||
{
|
||||
bool status = false; // return value
|
||||
bool status = false; /* return value */
|
||||
|
||||
if (!Device_Valid_Object_Instance_Number(wp_data->object_instance)) {
|
||||
*error_class = ERROR_CLASS_OBJECT;
|
||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
return false;
|
||||
}
|
||||
// decode the some of the request
|
||||
/* decode the some of the request */
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
|
||||
@@ -765,7 +765,7 @@ void testDevice(Test * pTest)
|
||||
}
|
||||
|
||||
#ifdef TEST_DEVICE
|
||||
// stubs to dependencies to keep unit test simple
|
||||
/* stubs to dependencies to keep unit test simple */
|
||||
unsigned Analog_Input_Count(void)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ extern "C" {
|
||||
const char *Device_Location(void);
|
||||
bool Device_Set_Location(const char *name, size_t length);
|
||||
|
||||
// some stack-centric constant values - no set methods
|
||||
/* some stack-centric constant values - no set methods */
|
||||
uint8_t Device_Protocol_Version(void);
|
||||
uint8_t Device_Protocol_Revision(void);
|
||||
uint16_t Device_Max_APDU_Length_Accepted(void);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include "handlers.h"
|
||||
#include "txbuf.h"
|
||||
|
||||
// buffer used for receive
|
||||
/* buffer used for receive */
|
||||
static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
|
||||
|
||||
/* global variables used in this file */
|
||||
@@ -117,11 +117,11 @@ static uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
|
||||
status = tsm_transaction_available();
|
||||
if (status) {
|
||||
datalink_get_my_address(&my_address);
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, // true for confirmed messages
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, &my_address, true, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
// load the data for the encoding
|
||||
/* load the data for the encoding */
|
||||
data.object_type = OBJECT_FILE;
|
||||
data.object_instance = file_instance;
|
||||
data.access = FILE_STREAM_ACCESS;
|
||||
@@ -137,8 +137,8 @@ static uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
||||
&dest, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(&dest, // destination address
|
||||
&Handler_Transmit_Buffer[0], pdu_len); // number of bytes of data
|
||||
bytes_sent = datalink_send_pdu(&dest, /* destination address */
|
||||
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send AtomicReadFile Request (%s)!\n",
|
||||
@@ -161,7 +161,7 @@ static void Send_WhoIs(uint32_t device_id)
|
||||
datalink_get_broadcast_address(&dest);
|
||||
|
||||
/* encode the NPDU portion of the packet */
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, NULL, false, // true for confirmed messages
|
||||
pdu_len = npdu_encode_apdu(&Handler_Transmit_Buffer[0], &dest, NULL, false, /* true for confirmed messages */
|
||||
MESSAGE_PRIORITY_NORMAL);
|
||||
|
||||
/* encode the APDU portion of the packet */
|
||||
@@ -268,9 +268,9 @@ static void Init_Service_Handlers(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
BACNET_ADDRESS src = { 0 }; // address where message came from
|
||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
||||
uint16_t pdu_len = 0;
|
||||
unsigned timeout = 100; // milliseconds
|
||||
unsigned timeout = 100; /* milliseconds */
|
||||
unsigned max_apdu = 0;
|
||||
time_t elapsed_seconds = 0;
|
||||
time_t last_seconds = 0;
|
||||
|
||||
Reference in New Issue
Block a user