indented using indent.sh script.

This commit is contained in:
skarg
2013-10-29 01:55:49 +00:00
parent e3da7d7fed
commit 56b65e9694
43 changed files with 785 additions and 659 deletions
+1 -2
View File
@@ -181,8 +181,7 @@ void handler_atomic_read_file(
error = true; error = true;
} else if (bacfile_read_stream_data(&data)) { } else if (bacfile_read_stream_data(&data)) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n",
"ARF: fileStartRecord %d, %u RecordCount.\n",
data.type.record.fileStartRecord, data.type.record.fileStartRecord,
data.type.record.RecordCount); data.type.record.RecordCount);
#endif #endif
+10 -10
View File
@@ -49,7 +49,7 @@
/** @file h_cov.c Handles Change of Value (COV) services. */ /** @file h_cov.c Handles Change of Value (COV) services. */
typedef struct BACnet_COV_Address{ typedef struct BACnet_COV_Address {
bool valid:1; bool valid:1;
BACNET_ADDRESS dest; BACNET_ADDRESS dest;
} BACNET_COV_ADDRESS; } BACNET_COV_ADDRESS;
@@ -106,7 +106,8 @@ static BACNET_ADDRESS *cov_address_get(
* Removes the address from the list of COV addresses, if it is not * Removes the address from the list of COV addresses, if it is not
* used by other COV subscriptions * used by other COV subscriptions
*/ */
static void cov_address_remove_unused(void) static void cov_address_remove_unused(
void)
{ {
unsigned index = 0; unsigned index = 0;
unsigned cov_index = 0; unsigned cov_index = 0;
@@ -137,7 +138,7 @@ static void cov_address_remove_unused(void)
* @return index number 0..N, or -1 if unable to add * @return index number 0..N, or -1 if unable to add
*/ */
static int cov_address_add( static int cov_address_add(
BACNET_ADDRESS *dest) BACNET_ADDRESS * dest)
{ {
int index = -1; int index = -1;
unsigned i = 0; unsigned i = 0;
@@ -475,8 +476,8 @@ static bool cov_send_request(
datalink_get_my_address(&my_address); datalink_get_my_address(&my_address);
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len = pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address,
&my_address, &npdu_data); &npdu_data);
/* load the COV data structure for outgoing message */ /* load the COV data structure for outgoing message */
cov_data.subscriberProcessIdentifier = cov_data.subscriberProcessIdentifier =
cov_subscription->subscriberProcessIdentifier; cov_subscription->subscriberProcessIdentifier;
@@ -504,13 +505,12 @@ static bool cov_send_request(
} }
pdu_len += len; pdu_len += len;
if (cov_subscription->flag.issueConfirmedNotifications) { if (cov_subscription->flag.issueConfirmedNotifications) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, tsm_set_confirmed_unsegmented_transaction(invoke_id, dest, &npdu_data,
dest, &npdu_data, &Handler_Transmit_Buffer[0], &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
(uint16_t) pdu_len);
} }
bytes_sent = bytes_sent =
datalink_send_pdu(dest, &npdu_data, datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
&Handler_Transmit_Buffer[0], pdu_len); pdu_len);
if (bytes_sent > 0) { if (bytes_sent > 0) {
status = true; status = true;
#if PRINT_ENABLED #if PRINT_ENABLED
+1 -1
View File
@@ -87,7 +87,7 @@ void npdu_handler(
routing information cause they are not for us */ routing information cause they are not for us */
if ((dest.net == BACNET_BROADCAST_NETWORK) && if ((dest.net == BACNET_BROADCAST_NETWORK) &&
((pdu[apdu_offset] & 0xF0) == ((pdu[apdu_offset] & 0xF0) ==
PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) { PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
/* hack for 5.4.5.1 - IDLE */ /* hack for 5.4.5.1 - IDLE */
/* ConfirmedBroadcastReceived */ /* ConfirmedBroadcastReceived */
/* then enter IDLE - ignore the PDU */ /* then enter IDLE - ignore the PDU */
+2 -2
View File
@@ -111,8 +111,8 @@ void handler_who_has(
#ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */ #ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */
/* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in /* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in
virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */ virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */
/** Handler for Who-Has requests in the virtual routing setup, /** Handler for Who-Has requests in the virtual routing setup,
* with broadcast I-Have response. * with broadcast I-Have response.
+2 -2
View File
@@ -114,8 +114,8 @@ void handler_who_is_unicast(
#ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */ #ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */
/* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in /* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in
virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */ virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */
/** Local function to check Who-Is requests against our Device IDs. /** Local function to check Who-Is requests against our Device IDs.
+75 -72
View File
@@ -45,86 +45,89 @@
/** @file s_awfs.c Send part of an Atomic Write File Stream request. */ /** @file s_awfs.c Send part of an Atomic Write File Stream request. */
uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id, uint8_t Send_Atomic_Write_File_Stream(
uint32_t file_instance, uint32_t device_id,
int fileStartPosition, uint32_t file_instance,
BACNET_OCTET_STRING * fileData) { int fileStartPosition,
BACNET_ADDRESS dest; BACNET_OCTET_STRING * fileData)
BACNET_ADDRESS my_address; {
BACNET_NPDU_DATA npdu_data; BACNET_ADDRESS dest;
unsigned max_apdu = 0; BACNET_ADDRESS my_address;
uint8_t invoke_id = 0; BACNET_NPDU_DATA npdu_data;
bool status = false; unsigned max_apdu = 0;
int len = 0; uint8_t invoke_id = 0;
int pdu_len = 0; bool status = false;
int bytes_sent = 0; int len = 0;
BACNET_ATOMIC_WRITE_FILE_DATA data; int pdu_len = 0;
int bytes_sent = 0;
BACNET_ATOMIC_WRITE_FILE_DATA data;
/* if we are forbidden to send, don't send! */ /* if we are forbidden to send, don't send! */
if (!dcc_communication_enabled ()) if (!dcc_communication_enabled())
return 0; return 0;
/* is the device bound? */ /* is the device bound? */
status = address_get_by_device (device_id, &max_apdu, &dest); status = address_get_by_device(device_id, &max_apdu, &dest);
/* is there a tsm available? */ /* is there a tsm available? */
if (status) if (status)
invoke_id = tsm_next_free_invokeID (); invoke_id = tsm_next_free_invokeID();
if (invoke_id) { if (invoke_id) {
/* load the data for the encoding */ /* load the data for the encoding */
data.object_type = OBJECT_FILE; data.object_type = OBJECT_FILE;
data.object_instance = file_instance; data.object_instance = file_instance;
data.access = FILE_STREAM_ACCESS; data.access = FILE_STREAM_ACCESS;
data.type.stream.fileStartPosition = fileStartPosition; data.type.stream.fileStartPosition = fileStartPosition;
status = octetstring_copy (&data.fileData[0], fileData); status = octetstring_copy(&data.fileData[0], fileData);
if (status) { if (status) {
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
datalink_get_my_address (&my_address); datalink_get_my_address(&my_address);
npdu_encode_npdu_data (&npdu_data, true, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
pdu_len = pdu_len =
npdu_encode_pdu (&Handler_Transmit_Buffer[0], &dest, &my_address, npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest,
&npdu_data); &my_address, &npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = len =
awf_encode_apdu (&Handler_Transmit_Buffer[pdu_len], invoke_id, &data); awf_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id,
pdu_len += len; &data);
/* will the APDU fit the target device? pdu_len += len;
note: if there is a bottleneck router in between /* will the APDU fit the target device?
us and the destination, we won't know unless note: if there is a bottleneck router in between
we have a way to check for that and update the us and the destination, we won't know unless
max_apdu in the address binding table. */ we have a way to check for that and update the
if ((unsigned) pdu_len <= max_apdu) { max_apdu in the address binding table. */
tsm_set_confirmed_unsegmented_transaction (invoke_id, &dest, if ((unsigned) pdu_len <= max_apdu) {
&npdu_data, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&Handler_Transmit_Buffer &npdu_data, &Handler_Transmit_Buffer[0],
[0], (uint16_t) pdu_len); (uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu (&dest, &npdu_data, &Handler_Transmit_Buffer[0], datalink_send_pdu(&dest, &npdu_data,
pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf (stderr, "Failed to Send AtomicWriteFile Request (%s)!\n", fprintf(stderr,
strerror (errno)); "Failed to Send AtomicWriteFile Request (%s)!\n",
strerror(errno));
#endif #endif
} else { } else {
tsm_free_invoke_id (invoke_id); tsm_free_invoke_id(invoke_id);
invoke_id = 0; invoke_id = 0;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf (stderr, fprintf(stderr,
"Failed to Send AtomicWriteFile Request " "Failed to Send AtomicWriteFile Request "
"(payload [%d] exceeds destination maximum APDU [%u])!\n", "(payload [%d] exceeds destination maximum APDU [%u])!\n",
pdu_len, max_apdu); pdu_len, max_apdu);
#endif #endif
} }
} else { } else {
tsm_free_invoke_id (invoke_id); tsm_free_invoke_id(invoke_id);
invoke_id = 0; invoke_id = 0;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf (stderr, fprintf(stderr,
"Failed to Send AtomicWriteFile Request " "Failed to Send AtomicWriteFile Request "
"(payload [%d] exceeds octet string capacity)!\n", pdu_len); "(payload [%d] exceeds octet string capacity)!\n", pdu_len);
#endif #endif
}
} }
}
return invoke_id; return invoke_id;
} }
+50 -49
View File
@@ -57,63 +57,64 @@
* @return invoke id of outgoing message, or 0 if device is not bound or no tsm available * @return invoke id of outgoing message, or 0 if device is not bound or no tsm available
*/ */
uint8_t Send_Write_Property_Multiple_Request_Data( uint8_t Send_Write_Property_Multiple_Request_Data(
uint32_t device_id, uint32_t device_id,
BACNET_WRITE_ACCESS_DATA * write_access_data) BACNET_WRITE_ACCESS_DATA * write_access_data)
{ {
BACNET_ADDRESS dest; BACNET_ADDRESS dest;
BACNET_ADDRESS my_address; BACNET_ADDRESS my_address;
unsigned max_apdu = 0; unsigned max_apdu = 0;
uint8_t invoke_id = 0; uint8_t invoke_id = 0;
bool status = false; bool status = false;
int len = 0; int len = 0;
int pdu_len = 0; int pdu_len = 0;
int bytes_sent = 0; int bytes_sent = 0;
BACNET_NPDU_DATA npdu_data; BACNET_NPDU_DATA npdu_data;
/* is the device bound? */ /* is the device bound? */
status = address_get_by_device(device_id, &max_apdu, &dest); status = address_get_by_device(device_id, &max_apdu, &dest);
/* is there a tsm available? */ /* is there a tsm available? */
if (status) if (status)
invoke_id = tsm_next_free_invokeID(); invoke_id = tsm_next_free_invokeID();
if (invoke_id) { if (invoke_id) {
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address); datalink_get_my_address(&my_address);
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
pdu_len = pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
&npdu_data); &npdu_data);
len = wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu, len =
invoke_id, write_access_data); wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu,
invoke_id, write_access_data);
pdu_len += len; pdu_len += len;
/* will it fit in the sender? /* will it fit in the sender?
note: if there is a bottleneck router in between note: if there is a bottleneck router in between
us and the destination, we won't know unless us and the destination, we won't know unless
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest, tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len); &npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
bytes_sent = bytes_sent =
datalink_send_pdu(&dest, &npdu_data, datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send WriteProperty Request (%s)!\n", fprintf(stderr, "Failed to Send WriteProperty Request (%s)!\n",
strerror(errno)); strerror(errno));
#endif #endif
} else { } else {
tsm_free_invoke_id(invoke_id); tsm_free_invoke_id(invoke_id);
invoke_id = 0; invoke_id = 0;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
"Failed to Send WriteProperty Request " "Failed to Send WriteProperty Request "
"(exceeds destination maximum APDU)!\n"); "(exceeds destination maximum APDU)!\n");
#endif #endif
} }
} }
return invoke_id; return invoke_id;
} }
+18 -20
View File
@@ -132,7 +132,7 @@ static uint32_t timeval_diff_ms(
static void mstp_monitor_i_am( static void mstp_monitor_i_am(
uint8_t mac, uint8_t mac,
uint8_t *pdu, uint8_t * pdu,
uint16_t pdu_len) uint16_t pdu_len)
{ {
BACNET_ADDRESS src = { 0 }; BACNET_ADDRESS src = { 0 };
@@ -150,10 +150,9 @@ static void mstp_monitor_i_am(
if (pdu[0] == BACNET_PROTOCOL_VERSION) { if (pdu[0] == BACNET_PROTOCOL_VERSION) {
MSTP_Fill_BACnet_Address(&src, mac); MSTP_Fill_BACnet_Address(&src, mac);
apdu_offset = npdu_decode(&pdu[0], &dest, &src, &npdu_data); apdu_offset = npdu_decode(&pdu[0], &dest, &src, &npdu_data);
if ((!npdu_data.network_layer_message) && if ((!npdu_data.network_layer_message) && (apdu_offset > 0) &&
(apdu_offset > 0) && (apdu_offset < pdu_len) && (apdu_offset < pdu_len) && ((dest.net == 0) ||
((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) && (dest.net == BACNET_BROADCAST_NETWORK)) && (src.net == 0)) {
(src.net == 0)) {
apdu_len = pdu_len - apdu_offset; apdu_len = pdu_len - apdu_offset;
apdu = &pdu[apdu_offset]; apdu = &pdu[apdu_offset];
pdu_type = apdu[0] & 0xF0; pdu_type = apdu[0] & 0xF0;
@@ -162,8 +161,9 @@ static void mstp_monitor_i_am(
service_choice = apdu[1]; service_choice = apdu[1];
service_request = &apdu[2]; service_request = &apdu[2];
if (service_choice == SERVICE_UNCONFIRMED_I_AM) { if (service_choice == SERVICE_UNCONFIRMED_I_AM) {
len = iam_decode_service_request(service_request, len =
&device_id, NULL, NULL, NULL); iam_decode_service_request(service_request, &device_id,
NULL, NULL, NULL);
if (len != -1) { if (len != -1) {
MSTP_Statistics[mac].device_id = device_id; MSTP_Statistics[mac].device_id = device_id;
} }
@@ -272,11 +272,10 @@ static void packet_statistics(
} }
} }
if ((mstp_port->ReceivedValidFrame) || if ((mstp_port->ReceivedValidFrame) ||
(mstp_port->ReceivedValidFrameNotForUs)){ (mstp_port->ReceivedValidFrameNotForUs)) {
if ((mstp_port->DataLength <= mstp_port->InputBufferSize) && if ((mstp_port->DataLength <= mstp_port->InputBufferSize) &&
(mstp_port->DataLength > 0)) { (mstp_port->DataLength > 0)) {
mstp_monitor_i_am(src, mstp_monitor_i_am(src, &mstp_port->InputBuffer[0],
&mstp_port->InputBuffer[0],
mstp_port->DataLength); mstp_port->DataLength);
} }
} }
@@ -754,8 +753,8 @@ static bool read_received_packet(
mstp_port->HeaderCRCActual = header[7]; mstp_port->HeaderCRCActual = header[7];
mstp_port->HeaderCRC = 0xFF; mstp_port->HeaderCRC = 0xFF;
for (i = 2; i < 8; i++) { for (i = 2; i < 8; i++) {
mstp_port->HeaderCRC = CRC_Calc_Header(header[i], mstp_port->HeaderCRC =
mstp_port->HeaderCRC); CRC_Calc_Header(header[i], mstp_port->HeaderCRC);
} }
if (mstp_port->HeaderCRC != 0x55) { if (mstp_port->HeaderCRC != 0x55) {
mstp_port->ReceivedInvalidFrame = true; mstp_port->ReceivedInvalidFrame = true;
@@ -792,11 +791,9 @@ static bool read_received_packet(
mstp_port->DataCRC); mstp_port->DataCRC);
} }
mstp_port->DataCRC = mstp_port->DataCRC =
CRC_Calc_Data(mstp_port->DataCRCActualMSB, CRC_Calc_Data(mstp_port->DataCRCActualMSB, mstp_port->DataCRC);
mstp_port->DataCRC);
mstp_port->DataCRC = mstp_port->DataCRC =
CRC_Calc_Data(mstp_port->DataCRCActualLSB, CRC_Calc_Data(mstp_port->DataCRCActualLSB, mstp_port->DataCRC);
mstp_port->DataCRC);
if (mstp_port->DataCRC == 0xF0B8) { if (mstp_port->DataCRC == 0xF0B8) {
mstp_port->ReceivedValidFrame = true; mstp_port->ReceivedValidFrame = true;
mstp_port->ReceivedValidFrameNotForUs = true; mstp_port->ReceivedValidFrameNotForUs = true;
@@ -851,13 +848,14 @@ static BOOL WINAPI CtrlCHandler(
* Returns: none * Returns: none
* Notes: none * Notes: none
**************************************************************************/ **************************************************************************/
static void print_com_ports(void) static void print_com_ports(
void)
{ {
unsigned i = 0; unsigned i = 0;
printf("List of available COM ports:\r\n"); printf("List of available COM ports:\r\n");
/* try to open all 255 COM ports */ /* try to open all 255 COM ports */
for (i=1; i<256; i++) { for (i = 1; i < 256; i++) {
if (RS485_Interface_Valid(i)) { if (RS485_Interface_Valid(i)) {
printf("COM%u\r\n", i); printf("COM%u\r\n", i);
} }
@@ -964,10 +962,10 @@ int main(
if (argc > 1) { if (argc > 1) {
RS485_Set_Interface(argv[1]); RS485_Set_Interface(argv[1]);
} else { } else {
#if defined(_WIN32) #if defined(_WIN32)
print_com_ports(); print_com_ports();
return 0; return 0;
#endif #endif
} }
if (argc > 2) { if (argc > 2) {
my_baud = strtol(argv[2], NULL, 0); my_baud = strtol(argv[2], NULL, 0);
-1
View File
@@ -124,5 +124,4 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+2 -1
View File
@@ -123,7 +123,8 @@ extern "C" {
uint16_t Analog_Value_Units( uint16_t Analog_Value_Units(
uint32_t instance); uint32_t instance);
bool Analog_Value_Units_Set( bool Analog_Value_Units_Set(
uint32_t instance, uint16_t unit); uint32_t instance,
uint16_t unit);
bool Analog_Value_Out_Of_Service( bool Analog_Value_Out_Of_Service(
uint32_t instance); uint32_t instance);
+8 -6
View File
@@ -282,7 +282,7 @@ int bacfile_read_property(
case PROP_FILE_ACCESS_METHOD: case PROP_FILE_ACCESS_METHOD:
apdu_len = apdu_len =
encode_application_enumerated(&apdu[0], encode_application_enumerated(&apdu[0],
FILE_RECORD_AND_STREAM_ACCESS); FILE_RECORD_AND_STREAM_ACCESS);
break; break;
default: default:
rpdata->error_class = ERROR_CLASS_PROPERTY; rpdata->error_class = ERROR_CLASS_PROPERTY;
@@ -551,7 +551,8 @@ bool bacfile_write_record_data(
} }
for (i = 0; i < data->type.record.returnedRecordCount; i++) { for (i = 0; i < data->type.record.returnedRecordCount; i++) {
if (fwrite(octetstring_value(&data->fileData[i]), if (fwrite(octetstring_value(&data->fileData[i]),
octetstring_length(&data->fileData[i]), 1, pFile) != 1) { octetstring_length(&data->fileData[i]), 1,
pFile) != 1) {
/* do something if it fails? */ /* do something if it fails? */
} }
} }
@@ -598,7 +599,7 @@ bool bacfile_read_ack_record_data(
FILE *pFile = NULL; FILE *pFile = NULL;
char *pFilename = NULL; char *pFilename = NULL;
uint32_t i = 0; uint32_t i = 0;
char dummy_data[MAX_OCTET_STRING_BYTES] = {0}; char dummy_data[MAX_OCTET_STRING_BYTES] = { 0 };
char *pData = NULL; char *pData = NULL;
pFilename = bacfile_name(instance); pFilename = bacfile_name(instance);
@@ -616,10 +617,11 @@ bool bacfile_read_ack_record_data(
} }
for (i = 0; i < data->type.record.RecordCount; i++) { for (i = 0; i < data->type.record.RecordCount; i++) {
if (fwrite(octetstring_value(&data->fileData[i]), if (fwrite(octetstring_value(&data->fileData[i]),
octetstring_length(&data->fileData[i]), 1, pFile) != 1) { octetstring_length(&data->fileData[i]), 1,
pFile) != 1) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Failed to write to %s (%lu)!\n", pFilename, fprintf(stderr, "Failed to write to %s (%lu)!\n",
(unsigned long) instance); pFilename, (unsigned long) instance);
#endif #endif
} }
} }
-1
View File
@@ -138,4 +138,3 @@ extern "C" {
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif
+3 -3
View File
@@ -1173,7 +1173,7 @@ int Device_Read_Property_Local(
uint8_t *apdu = NULL; uint8_t *apdu = NULL;
struct object_functions *pObject = NULL; struct object_functions *pObject = NULL;
bool found = false; bool found = false;
uint16_t apdu_max =0; uint16_t apdu_max = 0;
if ((rpdata == NULL) || (rpdata->application_data == NULL) || if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) { (rpdata->application_data_len == 0)) {
@@ -1818,8 +1818,8 @@ void Device_Init(
struct uci_context *ctx; struct uci_context *ctx;
fprintf(stderr, "Device_Init\n"); fprintf(stderr, "Device_Init\n");
ctx = ucix_init("bacnet_dev"); ctx = ucix_init("bacnet_dev");
if(!ctx) if (!ctx)
fprintf(stderr, "Failed to load config file bacnet_dev\n"); fprintf(stderr, "Failed to load config file bacnet_dev\n");
uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name"); uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name");
if (uciname != 0) { if (uciname != 0) {
characterstring_init_ansi(&My_Object_Name, uciname); characterstring_init_ansi(&My_Object_Name, uciname);
+2 -6
View File
@@ -440,15 +440,11 @@ extern "C" {
* - The interface between the implemented Objects and the BAC-stack services, * - The interface between the implemented Objects and the BAC-stack services,
* specifically the handlers, which are mediated through function calls to * specifically the handlers, which are mediated through function calls to
* the Device object. * the Device object.
*/ *//** @defgroup ObjHelpers Object Helper Functions
/** @defgroup ObjHelpers Object Helper Functions
* @ingroup ObjFrmwk * @ingroup ObjFrmwk
* This section describes the function templates for the helper functions that * This section describes the function templates for the helper functions that
* provide common object support. * provide common object support.
*/ *//** @defgroup ObjIntf Handler-to-Object Interface Functions
/** @defgroup ObjIntf Handler-to-Object Interface Functions
* @ingroup ObjFrmwk * @ingroup ObjFrmwk
* This section describes the fairly limited set of functions that link the * This section describes the fairly limited set of functions that link the
* BAC-stack handlers to the BACnet Object instances. All of these calls are * BAC-stack handlers to the BACnet Object instances. All of these calls are
+1 -1
View File
@@ -29,7 +29,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <time.h> /* for time */ #include <time.h> /* for time */
#include <ctype.h> /* for tupper */ #include <ctype.h> /* for tupper */
#if defined(WIN32) || defined(__BORLANDC__) #if defined(WIN32) || defined(__BORLANDC__)
#include <conio.h> #include <conio.h>
#endif #endif
+1 -1
View File
@@ -30,7 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> /* for time */ #include <time.h> /* for time */
#include <errno.h> #include <errno.h>
#include <ctype.h> /* for toupper */ #include <ctype.h> /* for toupper */
#include "bactext.h" #include "bactext.h"
#include "iam.h" #include "iam.h"
#include "address.h" #include "address.h"
+1 -1
View File
@@ -130,7 +130,7 @@ static void AtomicReadFileAckHandler(
/* is there anything to do with this? data.stream.requestedOctetCount */ /* is there anything to do with this? data.stream.requestedOctetCount */
(void) fseek(pFile, data.type.stream.fileStartPosition, (void) fseek(pFile, data.type.stream.fileStartPosition,
SEEK_SET); SEEK_SET);
octets_written = fwrite(octetstring_value(&data.fileData[0]), 1, /* unit to write in bytes - in our case, an octet is one byte */ octets_written = fwrite(octetstring_value(&data.fileData[0]), 1, /* unit to write in bytes - in our case, an octet is one byte */
octetstring_length(&data.fileData[0]), pFile); octetstring_length(&data.fileData[0]), pFile);
if (octets_written != octetstring_length(&data.fileData[0])) { if (octets_written != octetstring_length(&data.fileData[0])) {
fprintf(stderr, "Unable to write data to file \"%s\".\n", fprintf(stderr, "Unable to write data to file \"%s\".\n",
+2 -2
View File
@@ -166,8 +166,8 @@ int main(
struct uci_context *ctx; struct uci_context *ctx;
ctx = ucix_init("bacnet_dev"); ctx = ucix_init("bacnet_dev");
if(!ctx) if (!ctx)
fprintf(stderr, "Failed to load config file bacnet_dev\n"); fprintf(stderr, "Failed to load config file bacnet_dev\n");
uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0); uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0);
printf("ID: %i", uciId); printf("ID: %i", uciId);
if (uciId != 0) { if (uciId != 0) {
+1 -1
View File
@@ -48,7 +48,7 @@ typedef struct BACnet_Atomic_Read_File_Data {
uint32_t RecordCount; uint32_t RecordCount;
} record; } record;
} type; } type;
BACNET_OCTET_STRING fileData[BACNET_READ_FILE_RECORD_COUNT]; BACNET_OCTET_STRING fileData[BACNET_READ_FILE_RECORD_COUNT];
bool endOfFile; bool endOfFile;
} BACNET_ATOMIC_READ_FILE_DATA; } BACNET_ATOMIC_READ_FILE_DATA;
+82 -82
View File
@@ -409,12 +409,12 @@ typedef enum {
PROP_POWER = 384, PROP_POWER = 384,
PROP_TRANSITION = 385, PROP_TRANSITION = 385,
PROP_EGRESS_ACTIVE = 386, PROP_EGRESS_ACTIVE = 386,
/* The special property identifiers all, optional, and required */ /* The special property identifiers all, optional, and required */
/* are reserved for use in the ReadPropertyConditional and */ /* are reserved for use in the ReadPropertyConditional and */
/* ReadPropertyMultiple services or services not defined in this standard. */ /* ReadPropertyMultiple services or services not defined in this standard. */
/* Enumerated values 0-511 are reserved for definition by ASHRAE. */ /* Enumerated values 0-511 are reserved for definition by ASHRAE. */
/* Enumerated values 512-4194303 may be used by others subject to the */ /* Enumerated values 512-4194303 may be used by others subject to the */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
@@ -495,9 +495,9 @@ typedef enum {
UNITS_AMPERES_PER_METER = 167, UNITS_AMPERES_PER_METER = 167,
UNITS_AMPERES_PER_SQUARE_METER = 168, UNITS_AMPERES_PER_SQUARE_METER = 168,
UNITS_AMPERE_SQUARE_METERS = 169, UNITS_AMPERE_SQUARE_METERS = 169,
UNITS_DECIBELS = 199, UNITS_DECIBELS = 199,
UNITS_DECIBELS_MILLIVOLT = 200, UNITS_DECIBELS_MILLIVOLT = 200,
UNITS_DECIBELS_VOLT = 201, UNITS_DECIBELS_VOLT = 201,
UNITS_FARADS = 170, UNITS_FARADS = 170,
UNITS_HENRYS = 171, UNITS_HENRYS = 171,
UNITS_OHMS = 4, UNITS_OHMS = 4,
@@ -702,34 +702,34 @@ typedef enum {
UNITS_WATTS_PER_METER_PER_DEGREE_KELVIN = 189, UNITS_WATTS_PER_METER_PER_DEGREE_KELVIN = 189,
UNITS_WATTS_PER_SQUARE_METER_DEGREE_KELVIN = 141, UNITS_WATTS_PER_SQUARE_METER_DEGREE_KELVIN = 141,
UNITS_PER_MILLE = 207, UNITS_PER_MILLE = 207,
UNITS_GRAMS_PER_GRAM = 208, UNITS_GRAMS_PER_GRAM = 208,
UNITS_KILOGRAMS_PER_KILOGRAM = 209, UNITS_KILOGRAMS_PER_KILOGRAM = 209,
UNITS_GRAMS_PER_KILOGRAM = 210, UNITS_GRAMS_PER_KILOGRAM = 210,
UNITS_MILLIGRAMS_PER_GRAM = 211, UNITS_MILLIGRAMS_PER_GRAM = 211,
UNITS_MILLIGRAMS_PER_KILOGRAM = 212, UNITS_MILLIGRAMS_PER_KILOGRAM = 212,
UNITS_GRAMS_PER_MILLILITER = 213, UNITS_GRAMS_PER_MILLILITER = 213,
UNITS_GRAMS_PER_LITER = 214, UNITS_GRAMS_PER_LITER = 214,
UNITS_MILLIGRAMS_PER_LITER = 215, UNITS_MILLIGRAMS_PER_LITER = 215,
UNITS_MICROGRAMS_PER_LITER = 216, UNITS_MICROGRAMS_PER_LITER = 216,
UNITS_GRAMS_PER_CUBIC_METER = 217, UNITS_GRAMS_PER_CUBIC_METER = 217,
UNITS_MILLIGRAMS_PER_CUBIC_METER = 218, UNITS_MILLIGRAMS_PER_CUBIC_METER = 218,
UNITS_MICROGRAMS_PER_CUBIC_METER = 219, UNITS_MICROGRAMS_PER_CUBIC_METER = 219,
UNITS_NANOGRAMS_PER_CUBIC_METER = 220, UNITS_NANOGRAMS_PER_CUBIC_METER = 220,
UNITS_GRAMS_PER_CUBIC_CENTIMETER = 221, UNITS_GRAMS_PER_CUBIC_CENTIMETER = 221,
UNITS_BECQUERELS = 222, UNITS_BECQUERELS = 222,
UNITS_MEGABECQUERELS = 224, UNITS_MEGABECQUERELS = 224,
UNITS_GRAY = 225, UNITS_GRAY = 225,
UNITS_MILLIGRAY = 226, UNITS_MILLIGRAY = 226,
UNITS_MICROGRAY = 227, UNITS_MICROGRAY = 227,
UNITS_SIEVERTS = 228, UNITS_SIEVERTS = 228,
UNITS_MILLISIEVERTS = 229, UNITS_MILLISIEVERTS = 229,
UNITS_MICROSIEVERTS = 230, UNITS_MICROSIEVERTS = 230,
UNITS_MICROSIEVERTS_PER_HOUR = 231, UNITS_MICROSIEVERTS_PER_HOUR = 231,
UNITS_DECIBELS_A = 232, UNITS_DECIBELS_A = 232,
UNITS_NEPHELOMETRIC_TURBIDITY_UNIT = 233, UNITS_NEPHELOMETRIC_TURBIDITY_UNIT = 233,
UNITS_PH = 234, UNITS_PH = 234,
UNITS_GRAMS_PER_SQUARE_METER = 235, UNITS_GRAMS_PER_SQUARE_METER = 235,
UNITS_MINUTES_PER_DEGREE_KELVIN = 236, UNITS_MINUTES_PER_DEGREE_KELVIN = 236,
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */ /* Enumerated values 0-255 are reserved for definition by ASHRAE. */
/* Enumerated values 256-65535 may be used by others subject to */ /* Enumerated values 256-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */ /* the procedures and constraints described in Clause 23. */
@@ -772,9 +772,9 @@ typedef enum {
PROGRAM_ERROR_INTERNAL = 2, PROGRAM_ERROR_INTERNAL = 2,
PROGRAM_ERROR_PROGRAM = 3, PROGRAM_ERROR_PROGRAM = 3,
PROGRAM_ERROR_OTHER = 4, PROGRAM_ERROR_OTHER = 4,
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */ /* Enumerated values 0-63 are reserved for definition by ASHRAE. */
/* Enumerated values 64-65535 may be used by others subject to */ /* Enumerated values 64-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */ /* the procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
@@ -853,9 +853,9 @@ typedef enum {
RELIABILITY_MEMBER_FAULT = 11, RELIABILITY_MEMBER_FAULT = 11,
RELIABILITY_COMMUNICATION_FAILURE = 12, RELIABILITY_COMMUNICATION_FAILURE = 12,
RELIABILITY_TRIPPED = 13, RELIABILITY_TRIPPED = 13,
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */ /* Enumerated values 0-63 are reserved for definition by ASHRAE. */
/* Enumerated values 64-65535 may be used by others subject to */ /* Enumerated values 64-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */ /* the procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
@@ -876,14 +876,14 @@ typedef enum {
EVENT_EXTENDED = 9, EVENT_EXTENDED = 9,
EVENT_BUFFER_READY = 10, EVENT_BUFFER_READY = 10,
EVENT_UNSIGNED_RANGE = 11, EVENT_UNSIGNED_RANGE = 11,
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */ /* Enumerated values 0-63 are reserved for definition by ASHRAE. */
/* Enumerated values 64-65535 may be used by others subject to */ /* Enumerated values 64-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */ /* the procedures and constraints described in Clause 23. */
/* It is expected that these enumerated values will correspond to */ /* It is expected that these enumerated values will correspond to */
/* the use of the complex-event-type CHOICE [6] of the */ /* the use of the complex-event-type CHOICE [6] of the */
/* BACnetNotificationParameters production. */ /* BACnetNotificationParameters production. */
/* The last enumeration used in this version is 11. */ /* The last enumeration used in this version is 11. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
EVENT_PROPRIETARY_MIN = 64, EVENT_PROPRIETARY_MIN = 64,
@@ -914,10 +914,10 @@ typedef enum {
LIFE_SAFETY_MODE_AUTOMATIC_RELEASE_DISABLED = 13, LIFE_SAFETY_MODE_AUTOMATIC_RELEASE_DISABLED = 13,
LIFE_SAFETY_MODE_DEFAULT = 14, LIFE_SAFETY_MODE_DEFAULT = 14,
MAX_LIFE_SAFETY_MODE = 15, MAX_LIFE_SAFETY_MODE = 15,
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */ /* Enumerated values 0-255 are reserved for definition by ASHRAE. */
/* Enumerated values 256-65535 may be used by others subject to */ /* Enumerated values 256-65535 may be used by others subject to */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
LIFE_SAFETY_MODE_PROPRIETARY_MIN = 256, LIFE_SAFETY_MODE_PROPRIETARY_MIN = 256,
@@ -935,10 +935,10 @@ typedef enum {
LIFE_SAFETY_OP_UNSILENCE = 7, LIFE_SAFETY_OP_UNSILENCE = 7,
LIFE_SAFETY_OP_UNSILENCE_AUDIBLE = 8, LIFE_SAFETY_OP_UNSILENCE_AUDIBLE = 8,
LIFE_SAFETY_OP_UNSILENCE_VISUAL = 9, LIFE_SAFETY_OP_UNSILENCE_VISUAL = 9,
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */ /* Enumerated values 0-63 are reserved for definition by ASHRAE. */
/* Enumerated values 64-65535 may be used by others subject to */ /* Enumerated values 64-65535 may be used by others subject to */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
LIFE_SAFETY_OP_PROPRIETARY_MIN = 64, LIFE_SAFETY_OP_PROPRIETARY_MIN = 64,
@@ -972,10 +972,10 @@ typedef enum {
LIFE_SAFETY_STATE_SUPERVISORY = 22, LIFE_SAFETY_STATE_SUPERVISORY = 22,
LIFE_SAFETY_STATE_TEST_SUPERVISORY = 23, LIFE_SAFETY_STATE_TEST_SUPERVISORY = 23,
MAX_LIFE_SAFETY_STATE = 24, MAX_LIFE_SAFETY_STATE = 24,
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */ /* Enumerated values 0-255 are reserved for definition by ASHRAE. */
/* Enumerated values 256-65535 may be used by others subject to */ /* Enumerated values 256-65535 may be used by others subject to */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
LIFE_SAFETY_STATE_PROPRIETARY_MIN = 256, LIFE_SAFETY_STATE_PROPRIETARY_MIN = 256,
@@ -987,10 +987,10 @@ typedef enum {
SILENCED_STATE_AUDIBLE_SILENCED = 1, SILENCED_STATE_AUDIBLE_SILENCED = 1,
SILENCED_STATE_VISIBLE_SILENCED = 2, SILENCED_STATE_VISIBLE_SILENCED = 2,
SILENCED_STATE_ALL_SILENCED = 3, SILENCED_STATE_ALL_SILENCED = 3,
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */ /* Enumerated values 0-63 are reserved for definition by ASHRAE. */
/* Enumerated values 64-65535 may be used by others subject to */ /* Enumerated values 64-65535 may be used by others subject to */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
SILENCED_STATE_PROPRIETARY_MIN = 64, SILENCED_STATE_PROPRIETARY_MIN = 64,
@@ -1002,10 +1002,10 @@ typedef enum {
MAINTENANCE_PERIODIC_TEST = 1, MAINTENANCE_PERIODIC_TEST = 1,
MAINTENANCE_NEED_SERVICE_OPERATIONAL = 2, MAINTENANCE_NEED_SERVICE_OPERATIONAL = 2,
MAINTENANCE_NEED_SERVICE_INOPERATIVE = 3, MAINTENANCE_NEED_SERVICE_INOPERATIVE = 3,
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */ /* Enumerated values 0-255 are reserved for definition by ASHRAE. */
/* Enumerated values 256-65535 may be used by others subject to */ /* Enumerated values 256-65535 may be used by others subject to */
/* procedures and constraints described in Clause 23. */ /* procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
MAINTENANCE_PROPRIETARY_MIN = 256, MAINTENANCE_PROPRIETARY_MIN = 256,
@@ -1074,10 +1074,10 @@ typedef enum {
OBJECT_ALERT_ENROLLMENT = 52, /* Addendum 2010-af */ OBJECT_ALERT_ENROLLMENT = 52, /* Addendum 2010-af */
OBJECT_CHANNEL = 53, /* Addendum 2010-aa */ OBJECT_CHANNEL = 53, /* Addendum 2010-aa */
OBJECT_LIGHTING_OUTPUT = 54, /* Addendum 2010-i */ OBJECT_LIGHTING_OUTPUT = 54, /* Addendum 2010-i */
/* Enumerated values 0-127 are reserved for definition by ASHRAE. */ /* Enumerated values 0-127 are reserved for definition by ASHRAE. */
/* Enumerated values 128-1023 may be used by others subject to */ /* Enumerated values 128-1023 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */ /* the procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
OBJECT_PROPRIETARY_MIN = 128, OBJECT_PROPRIETARY_MIN = 128,
@@ -1101,10 +1101,10 @@ typedef enum {
VT_CLASS_DEC_VT220 = 4, VT_CLASS_DEC_VT220 = 4,
VT_CLASS_HP_700_94 = 5, /* real name is HP 700/94 */ VT_CLASS_HP_700_94 = 5, /* real name is HP 700/94 */
VT_CLASS_IBM_3130 = 6, VT_CLASS_IBM_3130 = 6,
/* Enumerated values 0-63 are reserved for definition by ASHRAE. */ /* Enumerated values 0-63 are reserved for definition by ASHRAE. */
/* Enumerated values 64-65535 may be used by others subject to */ /* Enumerated values 64-65535 may be used by others subject to */
/* the procedures and constraints described in Clause 23. */ /* the procedures and constraints described in Clause 23. */
/* do the max range inside of enum so that /* do the max range inside of enum so that
compilers will allocate adequate sized datatype for enum compilers will allocate adequate sized datatype for enum
which is used to store decoding */ which is used to store decoding */
VT_CLASS_PROPRIETARY_MIN = 64, VT_CLASS_PROPRIETARY_MIN = 64,
@@ -1307,9 +1307,9 @@ typedef enum {
SERVICE_SUPPORTED_UTC_TIME_SYNCHRONIZATION = 36, SERVICE_SUPPORTED_UTC_TIME_SYNCHRONIZATION = 36,
SERVICE_SUPPORTED_WHO_HAS = 33, SERVICE_SUPPORTED_WHO_HAS = 33,
SERVICE_SUPPORTED_WHO_IS = 34 SERVICE_SUPPORTED_WHO_IS = 34
/* Other services to be added as they are defined. */ /* Other services to be added as they are defined. */
/* All values in this production are reserved */ /* All values in this production are reserved */
/* for definition by ASHRAE. */ /* for definition by ASHRAE. */
} BACNET_SERVICES_SUPPORTED; } BACNET_SERVICES_SUPPORTED;
typedef enum { typedef enum {
+3 -3
View File
@@ -152,9 +152,9 @@ extern "C" {
int application_data_len, int application_data_len,
uint8_t priority, uint8_t priority,
uint32_t array_index); uint32_t array_index);
uint8_t Send_Write_Property_Multiple_Request_Data( uint8_t Send_Write_Property_Multiple_Request_Data(
uint32_t device_id, uint32_t device_id,
BACNET_WRITE_ACCESS_DATA * write_access_data); BACNET_WRITE_ACCESS_DATA * write_access_data);
/* returns the invoke ID for confirmed request, or 0 if failed */ /* returns the invoke ID for confirmed request, or 0 if failed */
uint8_t Send_Reinitialize_Device_Request( uint8_t Send_Reinitialize_Device_Request(
+1 -1
View File
@@ -135,7 +135,7 @@ extern "C" {
* chosen at runtime from among these choices. * chosen at runtime from among these choices.
* - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN * - Clause 10 POINT-TO-POINT (PTP) and Clause 11 EIA/CEA-709.1 ("LonTalk") LAN
* are not currently supported by this project. * are not currently supported by this project.
*//** @defgroup DLTemplates DataLink Template Functions *//** @defgroup DLTemplates DataLink Template Functions
* @ingroup DataLink * @ingroup DataLink
* Most of the functions in this group are function templates which are assigned * Most of the functions in this group are function templates which are assigned
* to a specific DataLink network layer implementation either at compile time or * to a specific DataLink network layer implementation either at compile time or
+8 -8
View File
@@ -89,18 +89,18 @@ extern "C" {
uint8_t hundredths); uint8_t hundredths);
/* utility test for validity */ /* utility test for validity */
bool datetime_is_valid( bool datetime_is_valid(
BACNET_DATE *bdate, BACNET_DATE * bdate,
BACNET_TIME *btime); BACNET_TIME * btime);
bool datetime_time_is_valid( bool datetime_time_is_valid(
BACNET_TIME *btime); BACNET_TIME * btime);
bool datetime_date_is_valid( bool datetime_date_is_valid(
BACNET_DATE *bdate); BACNET_DATE * bdate);
/* date and time calculations and summaries */ /* date and time calculations and summaries */
uint32_t datetime_days_since_epoch( uint32_t datetime_days_since_epoch(
BACNET_DATE *bdate); BACNET_DATE * bdate);
void datetime_days_since_epoch_into_date( void datetime_days_since_epoch_into_date(
uint32_t days, uint32_t days,
BACNET_DATE *bdate); BACNET_DATE * bdate);
bool datetime_is_leap_year( bool datetime_is_leap_year(
uint16_t year); uint16_t year);
uint8_t datetime_month_days( uint8_t datetime_month_days(
@@ -115,9 +115,9 @@ extern "C" {
uint8_t month, uint8_t month,
uint8_t day); uint8_t day);
uint32_t datetime_seconds_since_midnight( uint32_t datetime_seconds_since_midnight(
BACNET_TIME *btime); BACNET_TIME * btime);
uint16_t datetime_minutes_since_midnight( uint16_t datetime_minutes_since_midnight(
BACNET_TIME *btime); BACNET_TIME * btime);
/* utility comparison functions: /* utility comparison functions:
if the date/times are the same, return is 0 if the date/times are the same, return is 0
+2 -2
View File
@@ -94,7 +94,7 @@ extern "C" {
* *
* The network management BIBBs prescribe the BACnet capabilities required to * The network management BIBBs prescribe the BACnet capabilities required to
* interoperably perform network management functions. * interoperably perform network management functions.
*//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC) *//** @defgroup DMDCC Device Management-Device Communication Control (DM-DCC)
* @ingroup RDMS * @ingroup RDMS
* 16.1 DeviceCommunicationControl Service <br> * 16.1 DeviceCommunicationControl Service <br>
* The DeviceCommunicationControl service is used by a client BACnet-user to * The DeviceCommunicationControl service is used by a client BACnet-user to
@@ -107,7 +107,7 @@ extern "C" {
* "indefinite," meaning communication must be re-enabled by a * "indefinite," meaning communication must be re-enabled by a
* DeviceCommunicationControl or, if supported, ReinitializeDevice service, * DeviceCommunicationControl or, if supported, ReinitializeDevice service,
* not by time. * not by time.
*//** @defgroup NMRC Network Management-Router Configuration (NM-RC) *//** @defgroup NMRC Network Management-Router Configuration (NM-RC)
* @ingroup RDMS * @ingroup RDMS
* The A device may query and change the configuration of routers and * The A device may query and change the configuration of routers and
* half-routers. * half-routers.
+2 -2
View File
@@ -202,7 +202,7 @@ extern "C" {
* These BIBBs prescribe the BACnet capabilities required to interoperably * These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the alarm and event management functions enumerated in 22.2.1.2 * perform the alarm and event management functions enumerated in 22.2.1.2
* for the BACnet devices defined therein. * for the BACnet devices defined therein.
*//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N) *//** @defgroup EVNOTFCN Alarm and Event-Notification (AE-N)
* @ingroup ALMEVNT * @ingroup ALMEVNT
* 13.6 ConfirmedCOVNotification Service <br> * 13.6 ConfirmedCOVNotification Service <br>
* The ConfirmedCOVNotification service is used to notify subscribers about * The ConfirmedCOVNotification service is used to notify subscribers about
@@ -219,7 +219,7 @@ extern "C" {
* For unsubscribed notifications, the algorithm for determining when to issue * For unsubscribed notifications, the algorithm for determining when to issue
* this service is a local matter and may be based on a change of value, * this service is a local matter and may be based on a change of value,
* periodic updating, or some other criteria. * periodic updating, or some other criteria.
*//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK) *//** @defgroup ALMACK Alarm and Event-ACK (AE-ACK)
* @ingroup ALMEVNT * @ingroup ALMEVNT
* 13.5 AcknowledgeAlarm Service <br> * 13.5 AcknowledgeAlarm Service <br>
* In some systems a device may need to know that an operator has seen the alarm * In some systems a device may need to know that an operator has seen the alarm
+1 -1
View File
@@ -161,7 +161,7 @@ extern "C" {
/** @defgroup Trend Trending BIBBs /** @defgroup Trend Trending BIBBs
* These BIBBs prescribe the BACnet capabilities required to interoperably * These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the trending functions enumerated in clause 22.2.1.4 for the * perform the trending functions enumerated in clause 22.2.1.4 for the
* BACnet devices defined therein. * BACnet devices defined therein.
*//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT) *//** @defgroup TrendReadRange Trending -Read Range Service (eg, in T-VMT)
* @ingroup Trend * @ingroup Trend
* 15.8 ReadRange Service <br> * 15.8 ReadRange Service <br>
+1 -1
View File
@@ -124,7 +124,7 @@ extern "C" {
/** @defgroup DataShare Data Sharing BIBBs /** @defgroup DataShare Data Sharing BIBBs
* These BIBBs prescribe the BACnet capabilities required to interoperably * These BIBBs prescribe the BACnet capabilities required to interoperably
* perform the data sharing functions enumerated in 22.2.1.1 for the BACnet * perform the data sharing functions enumerated in 22.2.1.1 for the BACnet
* devices defined therein. * devices defined therein.
*//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP) *//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
* @ingroup DataShare * @ingroup DataShare
* 15.5 ReadProperty Service <br> * 15.5 ReadProperty Service <br>
+52 -20
View File
@@ -18,24 +18,56 @@
#ifndef _UCI_H__ #ifndef _UCI_H__
#define _UCI_H__ #define _UCI_H__
struct uci_context* ucix_init(const char *config_file); struct uci_context *ucix_init(
struct uci_context* ucix_init_path(const char *path, const char *config_file); const char *config_file);
void ucix_cleanup(struct uci_context *ctx); struct uci_context *ucix_init_path(
void ucix_save(struct uci_context *ctx); const char *path,
void ucix_save_state(struct uci_context *ctx); const char *config_file);
const char* ucix_get_option(struct uci_context *ctx, void ucix_cleanup(
const char *p, const char *s, const char *o); struct uci_context *ctx);
int ucix_get_option_int(struct uci_context *ctx, void ucix_save(
const char *p, const char *s, const char *o, int def); struct uci_context *ctx);
void ucix_add_section(struct uci_context *ctx, void ucix_save_state(
const char *p, const char *s, const char *t); struct uci_context *ctx);
void ucix_add_option(struct uci_context *ctx, const char *ucix_get_option(
const char *p, const char *s, const char *o, const char *t); struct uci_context *ctx,
void ucix_add_option_int(struct uci_context *ctx, const char *p,
const char *p, const char *s, const char *o, int t); const char *s,
int ucix_commit(struct uci_context *ctx, const char *p); const char *o);
void ucix_revert(struct uci_context *ctx, int ucix_get_option_int(
const char *p, const char *s, const char *o); struct uci_context *ctx,
void ucix_del(struct uci_context *ctx, const char *p, const char *p,
const char *s, const char *o); const char *s,
const char *o,
int def);
void ucix_add_section(
struct uci_context *ctx,
const char *p,
const char *s,
const char *t);
void ucix_add_option(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o,
const char *t);
void ucix_add_option_int(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o,
int t);
int ucix_commit(
struct uci_context *ctx,
const char *p);
void ucix_revert(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o);
void ucix_del(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o);
#endif #endif
+13 -13
View File
@@ -35,14 +35,14 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
struct BACnet_Write_Access_Data; struct BACnet_Write_Access_Data;
typedef struct BACnet_Write_Access_Data { typedef struct BACnet_Write_Access_Data {
BACNET_OBJECT_TYPE object_type; BACNET_OBJECT_TYPE object_type;
uint32_t object_instance; uint32_t object_instance;
/* simple linked list of values */ /* simple linked list of values */
BACNET_PROPERTY_VALUE *listOfProperties; BACNET_PROPERTY_VALUE *listOfProperties;
struct BACnet_Write_Access_Data *next; struct BACnet_Write_Access_Data *next;
} BACNET_WRITE_ACCESS_DATA; } BACNET_WRITE_ACCESS_DATA;
/* decode the service request only */ /* decode the service request only */
int wpm_decode_object_id( int wpm_decode_object_id(
@@ -69,11 +69,11 @@ extern "C" {
int wpm_encode_apdu_object_property( int wpm_encode_apdu_object_property(
uint8_t * apdu, uint8_t * apdu,
BACNET_WRITE_PROPERTY_DATA * wpdata); BACNET_WRITE_PROPERTY_DATA * wpdata);
int wpm_encode_apdu( int wpm_encode_apdu(
uint8_t * apdu, uint8_t * apdu,
size_t max_apdu, size_t max_apdu,
uint8_t invoke_id, uint8_t invoke_id,
BACNET_WRITE_ACCESS_DATA * write_access_data); BACNET_WRITE_ACCESS_DATA * write_access_data);
/* encode service */ /* encode service */
int wpm_ack_encode_apdu_init( int wpm_ack_encode_apdu_init(
+2 -2
View File
@@ -648,7 +648,7 @@ int Device_Read_Property_Local(
return 0; return 0;
} }
apdu = rpdata->application_data; apdu = rpdata->application_data;
switch ((int)rpdata->object_property) { switch ((int) rpdata->object_property) {
case PROP_DESCRIPTION: case PROP_DESCRIPTION:
characterstring_init_ansi(&char_string, "BACnet Demo"); characterstring_init_ansi(&char_string, "BACnet Demo");
apdu_len = apdu_len =
@@ -851,7 +851,7 @@ bool Device_Write_Property_Local(
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY; wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false; return false;
} }
switch ((int)wp_data->object_property) { switch ((int) wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) { if (value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
+6 -3
View File
@@ -7,7 +7,8 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// Default spurious interrupt handler. Infinite loop. /// Default spurious interrupt handler. Infinite loop.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void AT91F_Spurious_handler( void ) void AT91F_Spurious_handler(
void)
{ {
while (1); while (1);
} }
@@ -15,7 +16,8 @@ void AT91F_Spurious_handler( void )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// Default handler for fast interrupt requests. Infinite loop. /// Default handler for fast interrupt requests. Infinite loop.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void AT91F_Default_FIQ_handler( void ) void AT91F_Default_FIQ_handler(
void)
{ {
while (1); while (1);
} }
@@ -23,7 +25,8 @@ void AT91F_Default_FIQ_handler( void )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/// Default handler for standard interrupt requests. Infinite loop. /// Default handler for standard interrupt requests. Infinite loop.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void AT91F_Default_IRQ_handler( void ) void AT91F_Default_IRQ_handler(
void)
{ {
while (1); while (1);
} }
+1 -2
View File
@@ -295,8 +295,7 @@ int Device_Read_Property(
} }
} else { } else {
if (Device_Object_List_Identifier(rpdata->array_index, if (Device_Object_List_Identifier(rpdata->array_index,
&object_type, &object_type, &instance))
&instance))
apdu_len = apdu_len =
encode_application_object_id(&apdu[0], object_type, encode_application_object_id(&apdu[0], object_type,
instance); instance);
+2 -3
View File
@@ -875,9 +875,8 @@ bool dlmstp_init(
return false; return false;
} }
poSharedData = poSharedData = (SHARED_MSTP_DATA *) ((struct mstp_port_struct_t *)
(SHARED_MSTP_DATA *) ((struct mstp_port_struct_t *) mstp_port)-> mstp_port)->UserData;
UserData;
if (!poSharedData) { if (!poSharedData) {
return false; return false;
} }
+1 -1
View File
@@ -112,7 +112,7 @@ bool rs485_receive_error(
return false; return false;
} }
/*********************************************************************//** /*********************************************************************//**
* @brief USARTx interrupt handler sub-routine * @brief USARTx interrupt handler sub-routine
* @param[in] None * @param[in] None
* @return None * @return None
+6 -10
View File
@@ -131,7 +131,8 @@ void RS485_Set_Interface(
* ALGORITHM: none * ALGORITHM: none
* NOTES: none * NOTES: none
*****************************************************************************/ *****************************************************************************/
bool RS485_Interface_Valid(unsigned port_number) bool RS485_Interface_Valid(
unsigned port_number)
{ {
HANDLE h = 0; HANDLE h = 0;
DWORD err = 0; DWORD err = 0;
@@ -139,17 +140,12 @@ bool RS485_Interface_Valid(unsigned port_number)
char ifname[255] = ""; char ifname[255] = "";
sprintf(ifname, "\\\\.\\COM%u", port_number); sprintf(ifname, "\\\\.\\COM%u", port_number);
h = CreateFile( h = CreateFile(ifname, GENERIC_READ | GENERIC_WRITE, 0, NULL,
ifname, OPEN_EXISTING, 0, NULL);
GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0,
NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
err = GetLastError(); err = GetLastError();
if ((err == ERROR_ACCESS_DENIED) || if ((err == ERROR_ACCESS_DENIED) || (err == ERROR_GEN_FAILURE) ||
(err == ERROR_GEN_FAILURE) || (err == ERROR_SHARING_VIOLATION) || (err == ERROR_SEM_TIMEOUT)) {
(err == ERROR_SHARING_VIOLATION) ||
(err == ERROR_SEM_TIMEOUT)) {
status = true; status = true;
} }
} else { } else {
+2 -1
View File
@@ -68,7 +68,8 @@ extern "C" {
void RS485_Print_Error( void RS485_Print_Error(
void); void);
bool RS485_Interface_Valid(unsigned port_number); bool RS485_Interface_Valid(
unsigned port_number);
#ifdef __cplusplus #ifdef __cplusplus
+2 -2
View File
@@ -236,7 +236,7 @@ int arf_ack_encode_apdu(
for (i = 0; i < data->type.record.RecordCount; i++) { for (i = 0; i < data->type.record.RecordCount; i++) {
apdu_len += apdu_len +=
encode_application_octet_string(&apdu[apdu_len], encode_application_octet_string(&apdu[apdu_len],
&data->fileData[i]); &data->fileData[i]);
} }
apdu_len += encode_closing_tag(&apdu[apdu_len], 1); apdu_len += encode_closing_tag(&apdu[apdu_len], 1);
break; break;
@@ -330,7 +330,7 @@ int arf_ack_decode_service_request(
return -1; return -1;
len += len +=
decode_octet_string(&apdu[len], len_value_type, decode_octet_string(&apdu[len], len_value_type,
&data->fileData[i]); &data->fileData[i]);
} }
if (!decode_is_closing_tag_number(&apdu[len], 1)) if (!decode_is_closing_tag_number(&apdu[len], 1))
return -1; return -1;
+2 -2
View File
@@ -79,7 +79,7 @@ int awf_encode_apdu(
for (i = 0; i < data->type.record.returnedRecordCount; i++) { for (i = 0; i < data->type.record.returnedRecordCount; i++) {
apdu_len += apdu_len +=
encode_application_octet_string(&apdu[apdu_len], encode_application_octet_string(&apdu[apdu_len],
&data->fileData[i]); &data->fileData[i]);
} }
apdu_len += encode_closing_tag(&apdu[apdu_len], 1); apdu_len += encode_closing_tag(&apdu[apdu_len], 1);
break; break;
@@ -175,7 +175,7 @@ int awf_decode_service_request(
return -1; return -1;
len += len +=
decode_octet_string(&apdu[len], len_value_type, decode_octet_string(&apdu[len], len_value_type,
&data->fileData[i]); &data->fileData[i]);
} }
if (!decode_is_closing_tag_number(&apdu[len], 1)) if (!decode_is_closing_tag_number(&apdu[len], 1))
return -1; return -1;
+111 -54
View File
@@ -1014,7 +1014,7 @@ INDTEXT_DATA bacnet_property_names[] = {
{PROP_LIGHTING_COMMAND, "lighting-command"} {PROP_LIGHTING_COMMAND, "lighting-command"}
, ,
{PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, {PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY,
"lighting-command-default-priority"} "lighting-command-default-priority"}
, ,
{PROP_MAX_ACTUAL_VALUE, "max-actual-value"} {PROP_MAX_ACTUAL_VALUE, "max-actual-value"}
, ,
@@ -1735,59 +1735,116 @@ INDTEXT_DATA bacnet_error_code_names[] = {
, ,
{ERROR_CODE_COMMUNICATION_DISABLED, "access-denied"} {ERROR_CODE_COMMUNICATION_DISABLED, "access-denied"}
, ,
{ERROR_CODE_SUCCESS, "success"}, {ERROR_CODE_SUCCESS, "success"}
{ERROR_CODE_ACCESS_DENIED, "access-denied"}, ,
{ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"}, {ERROR_CODE_ACCESS_DENIED, "access-denied"}
{ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"}, ,
{ERROR_CODE_BAD_SIGNATURE, "bad-signature"}, {ERROR_CODE_BAD_DESTINATION_ADDRESS, "bad-destination-address"}
{ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"}, ,
{ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"}, {ERROR_CODE_BAD_DESTINATION_DEVICE_ID, "bad-destination-device-id"}
{ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"}, ,
{ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"}, {ERROR_CODE_BAD_SIGNATURE, "bad-signature"}
{ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"}, ,
{ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED, "destination-device-id-required"}, {ERROR_CODE_BAD_SOURCE_ADDRESS, "bad-source-address"}
{ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"}, ,
{ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"}, {ERROR_CODE_BAD_TIMESTAMP, "bad-timestamp"}
{ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"}, ,
{ERROR_CODE_INCORRECT_KEY, "incorrect-key"}, {ERROR_CODE_CANNOT_USE_KEY, "cannot-use-key"}
{ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"}, ,
{ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"}, {ERROR_CODE_CANNOT_VERIFY_MESSAGE_ID, "cannot-verify-message-id"}
{ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"}, ,
{ERROR_CODE_NOT_KEY_SERVER, "not-key-server"}, {ERROR_CODE_CORRECT_KEY_REVISION, "correct-key-revision"}
{ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"}, ,
{ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"}, {ERROR_CODE_DESTINATION_DEVICE_ID_REQUIRED,
{ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"}, "destination-device-id-required"}
{ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"}, ,
{ERROR_CODE_UNKNOWN_KEY, "unknown-key"}, {ERROR_CODE_DUPLICATE_MESSAGE, "duplicate-message"}
{ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"}, ,
{ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"}, {ERROR_CODE_ENCRYPTION_NOT_CONFIGURED, "encryption-not-configured"}
{ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"}, ,
{ERROR_CODE_ROUTER_BUSY, "router-busy"}, {ERROR_CODE_ENCRYPTION_REQUIRED, "encryption-required"}
{ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"}, ,
{ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"}, {ERROR_CODE_INCORRECT_KEY, "incorrect-key"}
{ERROR_CODE_SECURITY_ERROR, "security-error"}, ,
{ERROR_CODE_ADDRESSING_ERROR, "addressing-error"}, {ERROR_CODE_INVALID_KEY_DATA, "invalid-key-data"}
{ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"}, ,
{ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"}, {ERROR_CODE_KEY_UPDATE_IN_PROGRESS, "key-update-in-progress"}
{ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED, "register-foreign-device-failed"}, ,
{ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"}, {ERROR_CODE_MALFORMED_MESSAGE, "malformed-message"}
{ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"}, ,
{ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"}, {ERROR_CODE_NOT_KEY_SERVER, "not-key-server"}
{ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"}, ,
{ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"}, {ERROR_CODE_SECURITY_NOT_CONFIGURED, "security-not-configured"}
{ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME, "abort-application-exceeded-reply-time"}, ,
{ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"}, {ERROR_CODE_SOURCE_SECURITY_REQUIRED, "source-security-required"}
{ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"}, ,
{ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE, "abort-window-size-out-of-range"}, {ERROR_CODE_TOO_MANY_KEYS, "too-many-keys"}
{ERROR_CODE_FILE_FULL, "file-full"}, ,
{ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"}, {ERROR_CODE_UNKNOWN_AUTHENTICATION_TYPE, "unknown-authentication-type"}
{ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"}, ,
{ERROR_CODE_INTERNAL_ERROR, "internal-error"}, {ERROR_CODE_UNKNOWN_KEY, "unknown-key"}
{ERROR_CODE_NOT_CONFIGURED, "not-configured"}, ,
{ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"}, {ERROR_CODE_UNKNOWN_KEY_REVISION, "unknown-key-revision"}
{ERROR_CODE_VALUE_TOO_LONG, "value-too-long"}, ,
{ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"}, {ERROR_CODE_UNKNOWN_SOURCE_MESSAGE, "unknown-source-message"}
{ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"}, ,
{ERROR_CODE_NOT_ROUTER_TO_DNET, "not-router-to-dnet"}
,
{ERROR_CODE_ROUTER_BUSY, "router-busy"}
,
{ERROR_CODE_UNKNOWN_NETWORK_MESSAGE, "unknown-network-message"}
,
{ERROR_CODE_MESSAGE_TOO_LONG, "message-too-long"}
,
{ERROR_CODE_SECURITY_ERROR, "security-error"}
,
{ERROR_CODE_ADDRESSING_ERROR, "addressing-error"}
,
{ERROR_CODE_WRITE_BDT_FAILED, "write-bdt-failed"}
,
{ERROR_CODE_READ_BDT_FAILED, "read-bdt-failed"}
,
{ERROR_CODE_REGISTER_FOREIGN_DEVICE_FAILED,
"register-foreign-device-failed"}
,
{ERROR_CODE_READ_FDT_FAILED, "read-fdt-failed"}
,
{ERROR_CODE_DELETE_FDT_ENTRY_FAILED, "delete-fdt-entry-failed"}
,
{ERROR_CODE_DISTRIBUTE_BROADCAST_FAILED, "distribute-broadcast-failed"}
,
{ERROR_CODE_UNKNOWN_FILE_SIZE, "unknown-file-size"}
,
{ERROR_CODE_ABORT_APDU_TOO_LONG, "abort-apdu-too-long"}
,
{ERROR_CODE_ABORT_APPLICATION_EXCEEDED_REPLY_TIME,
"abort-application-exceeded-reply-time"}
,
{ERROR_CODE_ABORT_OUT_OF_RESOURCES, "abort-out-of-resources"}
,
{ERROR_CODE_ABORT_TSM_TIMEOUT, "abort-tsm-timeout"}
,
{ERROR_CODE_ABORT_WINDOW_SIZE_OUT_OF_RANGE,
"abort-window-size-out-of-range"}
,
{ERROR_CODE_FILE_FULL, "file-full"}
,
{ERROR_CODE_INCONSISTENT_CONFIGURATION, "inconsistent-configuration"}
,
{ERROR_CODE_INCONSISTENT_OBJECT_TYPE, "inconsistent-object-type"}
,
{ERROR_CODE_INTERNAL_ERROR, "internal-error"}
,
{ERROR_CODE_NOT_CONFIGURED, "not-configured"}
,
{ERROR_CODE_OUT_OF_MEMORY, "out-of-memory"}
,
{ERROR_CODE_VALUE_TOO_LONG, "value-too-long"}
,
{ERROR_CODE_ABORT_INSUFFICIENT_SECURITY, "abort-insufficient-security"}
,
{ERROR_CODE_ABORT_SECURITY_ERROR, "abort-security-error"}
,
{0, NULL} {0, NULL}
}; };
+16 -22
View File
@@ -89,12 +89,11 @@ bool datetime_ymd_is_valid(
uint8_t month, uint8_t month,
uint8_t day) uint8_t day)
{ {
bool status = false; /* true if value date */ bool status = false; /* true if value date */
uint8_t monthdays = 0; /* days in a month */ uint8_t monthdays = 0; /* days in a month */
monthdays = datetime_month_days(year, month); monthdays = datetime_month_days(year, month);
if ((year >= 1900) && (monthdays > 0) && if ((year >= 1900) && (monthdays > 0) && (day >= 1) && (day <= monthdays)) {
(day >= 1) && (day <= monthdays)) {
status = true; status = true;
} }
@@ -102,10 +101,10 @@ bool datetime_ymd_is_valid(
} }
bool datetime_date_is_valid( bool datetime_date_is_valid(
BACNET_DATE *bdate) BACNET_DATE * bdate)
{ {
bool status = false; /* true if value date */ bool status = false; /* true if value date */
if (bdate) { if (bdate) {
status = datetime_ymd_is_valid(bdate->year, bdate->month, bdate->day); status = datetime_ymd_is_valid(bdate->year, bdate->month, bdate->day);
@@ -139,7 +138,7 @@ static uint32_t days_since_epoch(
} }
uint32_t datetime_days_since_epoch( uint32_t datetime_days_since_epoch(
BACNET_DATE *bdate) BACNET_DATE * bdate)
{ {
uint32_t days = 0; uint32_t days = 0;
@@ -188,7 +187,7 @@ static void days_since_epoch_into_ymd(
void datetime_days_since_epoch_into_date( void datetime_days_since_epoch_into_date(
uint32_t days, uint32_t days,
BACNET_DATE *bdate) BACNET_DATE * bdate)
{ {
uint16_t year = 0; uint16_t year = 0;
uint8_t month = 0; uint8_t month = 0;
@@ -209,7 +208,7 @@ uint8_t datetime_day_of_week(
} }
bool datetime_time_is_valid( bool datetime_time_is_valid(
BACNET_TIME *btime) BACNET_TIME * btime)
{ {
bool status = false; bool status = false;
@@ -232,8 +231,8 @@ bool datetime_time_is_valid(
* @return true if the date and time are valid * @return true if the date and time are valid
*/ */
bool datetime_is_valid( bool datetime_is_valid(
BACNET_DATE *bdate, BACNET_DATE * bdate,
BACNET_TIME *btime) BACNET_TIME * btime)
{ {
return datetime_date_is_valid(bdate) && datetime_time_is_valid(btime); return datetime_date_is_valid(bdate) && datetime_time_is_valid(btime);
} }
@@ -447,15 +446,12 @@ static void seconds_since_midnight_into_hms(
* @return seconds since midnight * @return seconds since midnight
*/ */
uint32_t datetime_seconds_since_midnight( uint32_t datetime_seconds_since_midnight(
BACNET_TIME *btime) BACNET_TIME * btime)
{ {
uint32_t seconds = 0; uint32_t seconds = 0;
if (btime) { if (btime) {
seconds = seconds_since_midnight( seconds = seconds_since_midnight(btime->hour, btime->min, btime->sec);
btime->hour,
btime->min,
btime->sec);
} }
return seconds; return seconds;
@@ -468,14 +464,12 @@ uint32_t datetime_seconds_since_midnight(
* @return minutes since midnight * @return minutes since midnight
*/ */
uint16_t datetime_minutes_since_midnight( uint16_t datetime_minutes_since_midnight(
BACNET_TIME *btime) BACNET_TIME * btime)
{ {
uint32_t minutes = 0; uint32_t minutes = 0;
if (btime) { if (btime) {
minutes = minutes_since_midnight( minutes = minutes_since_midnight(btime->hour, btime->min);
btime->hour,
btime->min);
} }
return minutes; return minutes;
@@ -983,8 +977,8 @@ void testDateEpoch(
for (month = 1; month <= 12; month++) { for (month = 1; month <= 12; month++) {
for (day = 1; day <= datetime_month_days(year, month); day++) { for (day = 1; day <= datetime_month_days(year, month); day++) {
days = days_since_epoch(year, month, day); days = days_since_epoch(year, month, day);
days_since_epoch_into_ymd(days, days_since_epoch_into_ymd(days, &test_year, &test_month,
&test_year, &test_month, &test_day); &test_day);
ct_test(pTest, year == test_year); ct_test(pTest, year == test_year);
ct_test(pTest, month == test_month); ct_test(pTest, month == test_month);
ct_test(pTest, day == test_day); ct_test(pTest, day == test_day);
+6 -7
View File
@@ -923,7 +923,7 @@ BACNET_PROPERTY_ID property_list_special_property(
{ {
int property = -1; /* return value */ int property = -1; /* return value */
unsigned required, optional, proprietary; unsigned required, optional, proprietary;
struct special_property_list_t PropertyList = {{0}}; struct special_property_list_t PropertyList = { {0} };
property_list_special(object_type, &PropertyList); property_list_special(object_type, &PropertyList);
required = PropertyList.Required.count; required = PropertyList.Required.count;
@@ -967,7 +967,7 @@ unsigned property_list_special_count(
BACNET_PROPERTY_ID special_property) BACNET_PROPERTY_ID special_property)
{ {
unsigned count = 0; /* return value */ unsigned count = 0; /* return value */
struct special_property_list_t PropertyList = {{0}}; struct special_property_list_t PropertyList = { {0} };
property_list_special(object_type, &PropertyList); property_list_special(object_type, &PropertyList);
if (special_property == PROP_ALL) { if (special_property == PROP_ALL) {
@@ -997,16 +997,15 @@ void testPropList(
unsigned object_id = 0, object_name = 0, object_type = 0; unsigned object_id = 0, object_name = 0, object_type = 0;
for (i = 0; i < OBJECT_PROPRIETARY_MIN; i++) { for (i = 0; i < OBJECT_PROPRIETARY_MIN; i++) {
count = property_list_special_count((BACNET_OBJECT_TYPE)i, PROP_ALL); count = property_list_special_count((BACNET_OBJECT_TYPE) i, PROP_ALL);
ct_test(pTest, count >= 3); ct_test(pTest, count >= 3);
object_id = 0; object_id = 0;
object_name = 0; object_name = 0;
object_type = 0; object_type = 0;
for (j = 0; j < count; j++) { for (j = 0; j < count; j++) {
property = property_list_special_property( property =
(BACNET_OBJECT_TYPE)i, property_list_special_property((BACNET_OBJECT_TYPE) i,
PROP_ALL, PROP_ALL, j);
j);
if (property == PROP_OBJECT_TYPE) { if (property == PROP_OBJECT_TYPE) {
object_type++; object_type++;
} }
+146 -100
View File
@@ -27,149 +27,195 @@
static struct uci_ptr ptr; static struct uci_ptr ptr;
static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t) static inline int ucix_get_ptr(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o,
const char *t)
{ {
memset(&ptr, 0, sizeof(ptr)); memset(&ptr, 0, sizeof(ptr));
ptr.package = p; ptr.package = p;
ptr.section = s; ptr.section = s;
ptr.option = o; ptr.option = o;
ptr.value = t; ptr.value = t;
return uci_lookup_ptr(ctx, &ptr, NULL, true); return uci_lookup_ptr(ctx, &ptr, NULL, true);
} }
struct uci_context* ucix_init(const char *config_file) struct uci_context *ucix_init(
const char *config_file)
{ {
struct uci_context *ctx = uci_alloc_context(); struct uci_context *ctx = uci_alloc_context();
// uci_add_history_path(ctx, "/var/state"); // uci_add_history_path(ctx, "/var/state");
uci_add_delta_path(ctx, "/var/state"); uci_add_delta_path(ctx, "/var/state");
if(uci_load(ctx, config_file, NULL) != UCI_OK) if (uci_load(ctx, config_file, NULL) != UCI_OK) {
{ fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir,
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file); config_file);
return NULL; return NULL;
} }
return ctx; return ctx;
} }
struct uci_context* ucix_init_path(const char *path, const char *config_file) struct uci_context *ucix_init_path(
const char *path,
const char *config_file)
{ {
struct uci_context *ctx = uci_alloc_context(); struct uci_context *ctx = uci_alloc_context();
if(path) if (path)
uci_set_confdir(ctx, path); uci_set_confdir(ctx, path);
if(uci_load(ctx, config_file, NULL) != UCI_OK) if (uci_load(ctx, config_file, NULL) != UCI_OK) {
{ fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir,
fprintf(stderr, "%s/%s is missing or corrupt\n", ctx->savedir, config_file); config_file);
return NULL; return NULL;
} }
return ctx; return ctx;
} }
void ucix_cleanup(struct uci_context *ctx) void ucix_cleanup(
struct uci_context *ctx)
{ {
uci_free_context(ctx); uci_free_context(ctx);
} }
void ucix_save(struct uci_context *ctx) void ucix_save(
struct uci_context *ctx)
{ {
uci_set_savedir(ctx, "/tmp/.uci/"); uci_set_savedir(ctx, "/tmp/.uci/");
uci_save(ctx, NULL); uci_save(ctx, NULL);
} }
void ucix_save_state(struct uci_context *ctx) void ucix_save_state(
struct uci_context *ctx)
{ {
uci_set_savedir(ctx, "/var/state/"); uci_set_savedir(ctx, "/var/state/");
uci_save(ctx, NULL); uci_save(ctx, NULL);
} }
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o) const char *ucix_get_option(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o)
{ {
struct uci_element *e = NULL; struct uci_element *e = NULL;
const char *value = NULL; const char *value = NULL;
if(ucix_get_ptr(ctx, p, s, o, NULL)) if (ucix_get_ptr(ctx, p, s, o, NULL))
return NULL; return NULL;
if (!(ptr.flags & UCI_LOOKUP_COMPLETE)) if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
return NULL; return NULL;
e = ptr.last; e = ptr.last;
switch (e->type) switch (e->type) {
{ case UCI_TYPE_SECTION:
case UCI_TYPE_SECTION: value = uci_to_section(e)->type;
value = uci_to_section(e)->type; break;
break; case UCI_TYPE_OPTION:
case UCI_TYPE_OPTION: switch (ptr.o->type) {
switch(ptr.o->type) { case UCI_TYPE_STRING:
case UCI_TYPE_STRING: value = ptr.o->v.string;
value = ptr.o->v.string; break;
break; default:
default: value = NULL;
value = NULL; break;
break; }
} break;
break; default:
default: return 0;
return 0; }
}
return value; return value;
} }
int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def) int ucix_get_option_int(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o,
int def)
{ {
const char *tmp = ucix_get_option(ctx, p, s, o); const char *tmp = ucix_get_option(ctx, p, s, o);
int ret = def; int ret = def;
if (tmp) if (tmp)
ret = atoi(tmp); ret = atoi(tmp);
return ret; return ret;
} }
void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t) void ucix_add_section(
struct uci_context *ctx,
const char *p,
const char *s,
const char *t)
{ {
if(ucix_get_ptr(ctx, p, s, NULL, t)) if (ucix_get_ptr(ctx, p, s, NULL, t))
return; return;
uci_set(ctx, &ptr); uci_set(ctx, &ptr);
} }
void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t) void ucix_add_option(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o,
const char *t)
{ {
if(ucix_get_ptr(ctx, p, s, o, (t)?(t):(""))) if (ucix_get_ptr(ctx, p, s, o, (t) ? (t) : ("")))
return; return;
uci_set(ctx, &ptr); uci_set(ctx, &ptr);
} }
void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t) void ucix_add_option_int(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o,
int t)
{ {
char tmp[64]; char tmp[64];
snprintf(tmp, 64, "%d", t); snprintf(tmp, 64, "%d", t);
ucix_add_option(ctx, p, s, o, tmp); ucix_add_option(ctx, p, s, o, tmp);
} }
void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o) void ucix_del(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o)
{ {
if(!ucix_get_ptr(ctx, p, s, o, NULL)) if (!ucix_get_ptr(ctx, p, s, o, NULL))
uci_delete(ctx, &ptr); uci_delete(ctx, &ptr);
} }
void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o) void ucix_revert(
struct uci_context *ctx,
const char *p,
const char *s,
const char *o)
{ {
if(!ucix_get_ptr(ctx, p, s, o, NULL)) if (!ucix_get_ptr(ctx, p, s, o, NULL))
uci_revert(ctx, &ptr); uci_revert(ctx, &ptr);
} }
void ucix_for_each_section_type(struct uci_context *ctx, void ucix_for_each_section_type(
const char *p, const char *t, struct uci_context *ctx,
void (*cb)(const char*, void*), void *priv) const char *p,
const char *t,
void (*cb) (const char *,
void *),
void *priv)
{ {
struct uci_element *e; struct uci_element *e;
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL)) if (ucix_get_ptr(ctx, p, NULL, NULL, NULL))
return; return;
uci_foreach_element(&ptr.p->sections, e) uci_foreach_element(&ptr.p->sections, e)
if (!strcmp(t, uci_to_section(e)->type)) if (!strcmp(t, uci_to_section(e)->type))
cb(e->name, priv); cb(e->name, priv);
} }
int ucix_commit(struct uci_context *ctx, const char *p) int ucix_commit(
struct uci_context *ctx,
const char *p)
{ {
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL)) if (ucix_get_ptr(ctx, p, NULL, NULL, NULL))
return 1; return 1;
return uci_commit(ctx, &ptr.p, false); return uci_commit(ctx, &ptr.p, false);
} }
+39 -37
View File
@@ -256,56 +256,58 @@ int wpm_encode_apdu_object_property(
} }
int wpm_encode_apdu( int wpm_encode_apdu(
uint8_t * apdu, uint8_t * apdu,
size_t max_apdu, size_t max_apdu,
uint8_t invoke_id, uint8_t invoke_id,
BACNET_WRITE_ACCESS_DATA * write_access_data) BACNET_WRITE_ACCESS_DATA * write_access_data)
{ {
int apdu_len = 0; int apdu_len = 0;
int len = 0; int len = 0;
BACNET_WRITE_ACCESS_DATA *wpm_object; /* current object */ BACNET_WRITE_ACCESS_DATA *wpm_object; /* current object */
uint8_t apdu_temp[MAX_APDU]; /* temp for data before copy */ uint8_t apdu_temp[MAX_APDU]; /* temp for data before copy */
BACNET_PROPERTY_VALUE *wpm_property; /* current property */ BACNET_PROPERTY_VALUE *wpm_property; /* current property */
BACNET_WRITE_PROPERTY_DATA wpdata; /* for compatibility with wpm_encode_apdu_object_property function */ BACNET_WRITE_PROPERTY_DATA wpdata; /* for compatibility with wpm_encode_apdu_object_property function */
if (apdu) { if (apdu) {
len = wpm_encode_apdu_init(&apdu[0], invoke_id); len = wpm_encode_apdu_init(&apdu[0], invoke_id);
apdu_len += len; apdu_len += len;
wpm_object = write_access_data; wpm_object = write_access_data;
while(wpm_object){ while (wpm_object) {
len = wpm_encode_apdu_object_begin(&apdu[apdu_len], len =
wpm_object->object_type, wpm_object->object_instance); wpm_encode_apdu_object_begin(&apdu[apdu_len],
apdu_len += len; wpm_object->object_type, wpm_object->object_instance);
apdu_len += len;
wpm_property = wpm_object->listOfProperties; wpm_property = wpm_object->listOfProperties;
while(wpm_property){ while (wpm_property) {
wpdata.object_property = wpm_property->propertyIdentifier; wpdata.object_property = wpm_property->propertyIdentifier;
wpdata.array_index = wpm_property->propertyArrayIndex; wpdata.array_index = wpm_property->propertyArrayIndex;
wpdata.priority = wpm_property->priority; wpdata.priority = wpm_property->priority;
wpdata.application_data_len = bacapp_encode_data(&apdu_temp[0], wpdata.application_data_len =
&wpm_property->value); bacapp_encode_data(&apdu_temp[0], &wpm_property->value);
memcpy(&wpdata.application_data[0], &apdu_temp[0], memcpy(&wpdata.application_data[0], &apdu_temp[0],
wpdata.application_data_len); wpdata.application_data_len);
len = wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata); len =
apdu_len += len; wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata);
apdu_len += len;
wpm_property = wpm_property->next; wpm_property = wpm_property->next;
} }
len = wpm_encode_apdu_object_end(&apdu[apdu_len]); len = wpm_encode_apdu_object_end(&apdu[apdu_len]);
apdu_len += len; apdu_len += len;
wpm_object = wpm_object->next; wpm_object = wpm_object->next;
} }
} }
return apdu_len; return apdu_len;
} }
int wpm_ack_encode_apdu_init( int wpm_ack_encode_apdu_init(