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
+8 -8
View File
@@ -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;
@@ -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
+14 -11
View File
@@ -45,10 +45,12 @@
/** @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 device_id,
uint32_t file_instance, uint32_t file_instance,
int fileStartPosition, int fileStartPosition,
BACNET_OCTET_STRING * fileData) { BACNET_OCTET_STRING * fileData)
{
BACNET_ADDRESS dest; BACNET_ADDRESS dest;
BACNET_ADDRESS my_address; BACNET_ADDRESS my_address;
BACNET_NPDU_DATA npdu_data; BACNET_NPDU_DATA npdu_data;
@@ -81,11 +83,12 @@ uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id,
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,
&data);
pdu_len += len; pdu_len += len;
/* will the APDU fit the target device? /* will the APDU fit the target device?
note: if there is a bottleneck router in between note: if there is a bottleneck router in between
@@ -94,15 +97,15 @@ uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id,
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, &npdu_data, &Handler_Transmit_Buffer[0],
&Handler_Transmit_Buffer (uint16_t) pdu_len);
[0], (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,
"Failed to Send AtomicWriteFile Request (%s)!\n",
strerror(errno)); strerror(errno));
#endif #endif
} else { } else {
+2 -1
View File
@@ -83,7 +83,8 @@ uint8_t Send_Write_Property_Multiple_Request_Data(
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 =
wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu,
invoke_id, write_access_data); invoke_id, write_access_data);
pdu_len += len; pdu_len += len;
+13 -15
View File
@@ -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;
} }
@@ -275,8 +275,7 @@ static void packet_statistics(
(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,7 +848,8 @@ 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;
-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);
+6 -4
View File
@@ -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? */
} }
} }
@@ -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
+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
+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
+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;
} }
+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
+110 -53
View File
@@ -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}
}; };
+5 -11
View File
@@ -93,8 +93,7 @@ bool datetime_ymd_is_valid(
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;
} }
@@ -452,10 +451,7 @@ uint32_t datetime_seconds_since_midnight(
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;
@@ -473,9 +469,7 @@ uint16_t datetime_minutes_since_midnight(
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);
+3 -4
View File
@@ -1003,10 +1003,9 @@ void testPropList(
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++;
} }
+72 -26
View File
@@ -27,7 +27,12 @@
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;
@@ -37,50 +42,60 @@ static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const cha
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;
@@ -89,8 +104,7 @@ const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *
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;
@@ -111,7 +125,12 @@ const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *
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;
@@ -121,42 +140,68 @@ int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, c
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))
@@ -166,10 +211,11 @@ void ucix_for_each_section_type(struct uci_context *ctx,
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);
} }
+6 -4
View File
@@ -276,7 +276,8 @@ int wpm_encode_apdu(
while (wpm_object) { while (wpm_object) {
len = wpm_encode_apdu_object_begin(&apdu[apdu_len], len =
wpm_encode_apdu_object_begin(&apdu[apdu_len],
wpm_object->object_type, wpm_object->object_instance); wpm_object->object_type, wpm_object->object_instance);
apdu_len += len; apdu_len += len;
@@ -287,12 +288,13 @@ int wpm_encode_apdu(
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 =
wpm_encode_apdu_object_property(&apdu[apdu_len], &wpdata);
apdu_len += len; apdu_len += len;
wpm_property = wpm_property->next; wpm_property = wpm_property->next;