Performed standard indent script indent.sh on project files.

This commit is contained in:
skarg
2010-12-15 19:02:40 +00:00
parent f820697464
commit 2a0bf4926a
107 changed files with 974 additions and 1033 deletions
+24 -25
View File
@@ -277,8 +277,8 @@ static void Init_Service_Handlers(
uint32_t Object_Instance; uint32_t Object_Instance;
/* Put this client Device into the Routing table (first entry) */ /* Put this client Device into the Routing table (first entry) */
Object_Instance = Device_Object_Instance_Number(); Object_Instance = Device_Object_Instance_Number();
Add_Routed_Device( Object_Instance, Device_Object_Name(), Add_Routed_Device(Object_Instance, Device_Object_Name(),
Device_Description() ); Device_Description());
#endif #endif
/* we need to handle who-is /* we need to handle who-is
@@ -797,10 +797,8 @@ void PrintUsage(
(" -t: declare target's MAC instead of using Who-Is to bind to \r\n"); (" -t: declare target's MAC instead of using Who-Is to bind to \r\n");
printf printf
(" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n"); (" device-instance. Format is \"C0:A8:00:18:BA:C0\" (as usual) \r\n");
printf printf(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n");
(" Use \"7F:00:00:01:BA:C0\" for loopback testing \r\n"); printf(" -n: specify target's DNET if not local BACnet network \r\n");
printf
(" -n: specify target's DNET if not local BACnet network \r\n");
printf(" or on routed Virtual Network \r\n"); printf(" or on routed Virtual Network \r\n");
printf("\r\n"); printf("\r\n");
printf("Insert the output in your EPICS file as the last section: \r\n"); printf("Insert the output in your EPICS file as the last section: \r\n");
@@ -839,10 +837,12 @@ int CheckCommandLineArgs(
break; break;
case 'n': case 'n':
/* Destination Network Number */ /* Destination Network Number */
if ( Target_Address.mac_len == 0 ) if (Target_Address.mac_len == 0)
fprintf(stderr, "Must provide a Target MAC before DNET \r\n"); fprintf(stderr,
"Must provide a Target MAC before DNET \r\n");
if (++i < argc) if (++i < argc)
Target_Address.net = (uint16_t) strtol(argv[i], NULL, 0); Target_Address.net =
(uint16_t) strtol(argv[i], NULL, 0);
/* Used strtol so dest.net can be either 0x1234 or 4660 */ /* Used strtol so dest.net can be either 0x1234 or 4660 */
break; break;
case 't': case 't':
@@ -854,10 +854,9 @@ int CheckCommandLineArgs(
/* loop counter */ /* loop counter */
unsigned j; unsigned j;
count = count =
sscanf(argv[i], "%x:%x:%x:%x:%x:%x", sscanf(argv[i], "%x:%x:%x:%x:%x:%x", &mac[0],
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
&mac[5]); if (count == 6) { /* success */
if (count == 6) { /* success */
Target_Address.mac_len = count; Target_Address.mac_len = count;
for (j = 0; j < 6; j++) { for (j = 0; j < 6; j++) {
Target_Address.mac[j] = (uint8_t) mac[j]; Target_Address.mac[j] = (uint8_t) mac[j];
@@ -967,30 +966,30 @@ int main(
timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
if (My_BIP_Port > 0) if (My_BIP_Port > 0)
bip_set_port(htons(0xBAC0)); /* Set back to std BACnet/IP port */ bip_set_port(htons(0xBAC0)); /* Set back to std BACnet/IP port */
/* try to bind with the target device */ /* try to bind with the target device */
found = found =
address_bind_request(Target_Device_Object_Instance, &max_apdu, address_bind_request(Target_Device_Object_Instance, &max_apdu,
&Target_Address); &Target_Address);
if (!found) { if (!found) {
if (Provided_Targ_MAC) { if (Provided_Targ_MAC) {
if ( Target_Address.net > 0 ) { if (Target_Address.net > 0) {
/* We specified a DNET; call Who-Is to find the full /* We specified a DNET; call Who-Is to find the full
* routed path to this Device */ * routed path to this Device */
Send_WhoIs_Remote(&Target_Address, Send_WhoIs_Remote(&Target_Address,
Target_Device_Object_Instance, Target_Device_Object_Instance,
Target_Device_Object_Instance); Target_Device_Object_Instance);
} else { } else {
/* Update by adding the MAC address */ /* Update by adding the MAC address */
if (max_apdu == 0) if (max_apdu == 0)
max_apdu = MAX_APDU; /* Whatever set for this datalink. */ max_apdu = MAX_APDU; /* Whatever set for this datalink. */
address_add_binding(Target_Device_Object_Instance, max_apdu, address_add_binding(Target_Device_Object_Instance, max_apdu,
&Target_Address); &Target_Address);
} }
} else { } else {
Send_WhoIs(Target_Device_Object_Instance, Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance); Target_Device_Object_Instance);
} }
} }
myObject.type = OBJECT_DEVICE; myObject.type = OBJECT_DEVICE;
@@ -1036,7 +1035,7 @@ int main(
} else { } else {
/* Print out the header information */ /* Print out the header information */
printf("List of Objects in device %u: \r\n", printf("List of Objects in device %u: \r\n",
Target_Device_Object_Instance); Target_Device_Object_Instance);
/* Print Opening brace, then kick off the Device Object */ /* Print Opening brace, then kick off the Device Object */
printf("{ \r\n"); printf("{ \r\n");
printf(" { \r\n"); /* And opening brace for the first object */ printf(" { \r\n"); /* And opening brace for the first object */
@@ -1158,11 +1157,11 @@ int main(
(invoke_id == (invoke_id ==
Read_Property_Multiple_Data.service_data.invoke_id)) { Read_Property_Multiple_Data.service_data.invoke_id)) {
Read_Property_Multiple_Data.new_data = false; Read_Property_Multiple_Data.new_data = false;
PrintReadPropertyData(Read_Property_Multiple_Data. PrintReadPropertyData
rpm_data->object_type, (Read_Property_Multiple_Data.rpm_data->object_type,
Read_Property_Multiple_Data.rpm_data->object_instance, Read_Property_Multiple_Data.rpm_data->object_instance,
Read_Property_Multiple_Data.rpm_data-> Read_Property_Multiple_Data.
listOfProperties); rpm_data->listOfProperties);
if (tsm_invoke_id_free(invoke_id)) { if (tsm_invoke_id_free(invoke_id)) {
invoke_id = 0; invoke_id = 0;
} else { } else {
+1 -1
View File
@@ -38,7 +38,7 @@
/* Device configuration definitions. */ /* Device configuration definitions. */
#define FIRST_DEVICE_NUMBER 260001 #define FIRST_DEVICE_NUMBER 260001
#define VIRTUAL_DNET 2709 /* your choice of number here */ #define VIRTUAL_DNET 2709 /* your choice of number here */
#define DEV_NAME_BASE "Gateway Demo Device" #define DEV_NAME_BASE "Gateway Demo Device"
#define DEV_DESCR_GATEWAY "Gateway Device and Router" #define DEV_DESCR_GATEWAY "Gateway Device and Router"
#define DEV_DESCR_REMOTE "Routed Remote Device" #define DEV_DESCR_REMOTE "Routed Remote Device"
+49 -51
View File
@@ -85,7 +85,7 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{ANALOG_INPUT_OBJ_FUNCTIONS}, {ANALOG_INPUT_OBJ_FUNCTIONS},
{ANALOG_OUTPUT_OBJ_FUNCTIONS}, {ANALOG_OUTPUT_OBJ_FUNCTIONS},
{ANALOG_VALUE_OBJ_FUNCTIONS}, {ANALOG_VALUE_OBJ_FUNCTIONS},
@@ -110,7 +110,7 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
* Only one entry since we don't support downstream routers. * Only one entry since we don't support downstream routers.
*/ */
int DNET_list[2] = { int DNET_list[2] = {
VIRTUAL_DNET, -1 /* Need -1 terminator */ VIRTUAL_DNET, -1 /* Need -1 terminator */
}; };
@@ -120,7 +120,7 @@ int DNET_list[2] = {
instance number, and subsequent devices to incremented values. instance number, and subsequent devices to incremented values.
*/ */
void Devices_Init( void Devices_Init(
uint32_t first_object_instance ) uint32_t first_object_instance)
{ {
int i; int i;
char nameText[MAX_DEV_NAME_LEN]; char nameText[MAX_DEV_NAME_LEN];
@@ -128,24 +128,20 @@ void Devices_Init(
/* Gateway Device has already been initialized. /* Gateway Device has already been initialized.
* But give it a better Description. */ * But give it a better Description. */
Routed_Device_Set_Description(DEV_DESCR_GATEWAY, strlen(DEV_DESCR_GATEWAY)); Routed_Device_Set_Description(DEV_DESCR_GATEWAY,
strlen(DEV_DESCR_GATEWAY));
/* Now initialize the remote Device objects. */ /* Now initialize the remote Device objects. */
for ( i = 1; i < MAX_NUM_DEVICES; i++ ) for (i = 1; i < MAX_NUM_DEVICES; i++) {
{
#ifdef _MSC_VER #ifdef _MSC_VER
_snprintf( nameText, MAX_DEV_NAME_LEN, "%s %d", _snprintf(nameText, MAX_DEV_NAME_LEN, "%s %d", DEV_NAME_BASE, i + 1);
DEV_NAME_BASE, i+1); _snprintf(descText, MAX_DEV_DESC_LEN, "%s %d", DEV_DESCR_REMOTE, i);
_snprintf( descText, MAX_DEV_DESC_LEN, "%s %d",
DEV_DESCR_REMOTE, i);
#else #else
snprintf( nameText, MAX_DEV_NAME_LEN, "%s %d", snprintf(nameText, MAX_DEV_NAME_LEN, "%s %d", DEV_NAME_BASE, i + 1);
DEV_NAME_BASE, i+1); snprintf(descText, MAX_DEV_DESC_LEN, "%s %d", DEV_DESCR_REMOTE, i);
snprintf( descText, MAX_DEV_DESC_LEN, "%s %d",
DEV_DESCR_REMOTE, i);
#endif #endif
Add_Routed_Device( (first_object_instance+i), nameText, descText ); Add_Routed_Device((first_object_instance + i), nameText, descText);
} }
} }
@@ -155,18 +151,18 @@ void Devices_Init(
* @see Device_Init, apdu_set_unconfirmed_handler, apdu_set_confirmed_handler * @see Device_Init, apdu_set_unconfirmed_handler, apdu_set_confirmed_handler
*/ */
static void Init_Service_Handlers( static void Init_Service_Handlers(
uint32_t first_object_instance ) uint32_t first_object_instance)
{ {
Device_Initialize_Object_Functions(&Object_Table[0]); Device_Initialize_Object_Functions(&Object_Table[0]);
Routing_Device_Init( first_object_instance ); Routing_Device_Init(first_object_instance);
/* we need to handle who-is to support dynamic device binding /* we need to handle who-is to support dynamic device binding
* For the gateway, we want the routing handlers, and we will use the * For the gateway, we want the routing handlers, and we will use the
* unicast variety so we can get back through switches to different subnets */ * unicast variety so we can get back through switches to different subnets */
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
handler_who_is_unicast_for_routing); handler_who_is_unicast_for_routing);
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
handler_who_has_for_routing); handler_who_has_for_routing);
/* set the handler for all the services we don't implement */ /* set the handler for all the services we don't implement */
/* It is required to send the proper reject message... */ /* It is required to send the proper reject message... */
apdu_set_unrecognized_service_handler_handler apdu_set_unrecognized_service_handler_handler
@@ -210,21 +206,22 @@ static void Init_Service_Handlers(
* device.) This is sure to be unique! The port number stays the same. * device.) This is sure to be unique! The port number stays the same.
* - For MS/TP, [Steve inserts a good idea here] * - For MS/TP, [Steve inserts a good idea here]
*/ */
void Initialize_Device_Addresses( ) void Initialize_Device_Addresses(
)
{ {
int i = 0; /* First entry is Gateway Device */ int i = 0; /* First entry is Gateway Device */
DEVICE_OBJECT_DATA* pDev; DEVICE_OBJECT_DATA *pDev;
uint16_t myPort; uint16_t myPort;
/* Setup info for the main gateway device first */ /* Setup info for the main gateway device first */
#if defined(BACDL_BIP) #if defined(BACDL_BIP)
struct in_addr *netPtr; /* Lets us cast to this type */ struct in_addr *netPtr; /* Lets us cast to this type */
uint8_t *gatewayMac = NULL; uint8_t *gatewayMac = NULL;
uint32_t myAddr = bip_get_addr(); uint32_t myAddr = bip_get_addr();
pDev = Get_Routed_Device_Object( i ); pDev = Get_Routed_Device_Object(i);
gatewayMac = pDev->bacDevAddr.mac; /* Keep pointer to the main MAC */ gatewayMac = pDev->bacDevAddr.mac; /* Keep pointer to the main MAC */
memcpy( pDev->bacDevAddr.mac, &myAddr, 4 ); memcpy(pDev->bacDevAddr.mac, &myAddr, 4);
myPort = bip_get_port(); myPort = bip_get_port();
memcpy( &pDev->bacDevAddr.mac[4], &myPort, 2 ); memcpy(&pDev->bacDevAddr.mac[4], &myPort, 2);
pDev->bacDevAddr.mac_len = 6; pDev->bacDevAddr.mac_len = 6;
#elif defined(BACDL_MSTP) #elif defined(BACDL_MSTP)
/* Todo: */ /* Todo: */
@@ -235,23 +232,23 @@ void Initialize_Device_Addresses( )
/* broadcast an I-Am on startup */ /* broadcast an I-Am on startup */
Send_I_Am(&Handler_Transmit_Buffer[0]); Send_I_Am(&Handler_Transmit_Buffer[0]);
for (i = 1; i < MAX_NUM_DEVICES; i++ ) { for (i = 1; i < MAX_NUM_DEVICES; i++) {
pDev = Get_Routed_Device_Object( i ); pDev = Get_Routed_Device_Object(i);
if ( pDev == NULL ) if (pDev == NULL)
continue; continue;
#if defined(BACDL_BIP) #if defined(BACDL_BIP)
netPtr = (struct in_addr *) pDev->bacDevAddr.mac; netPtr = (struct in_addr *) pDev->bacDevAddr.mac;
pDev->bacDevAddr.mac[0] = gatewayMac[3]; pDev->bacDevAddr.mac[0] = gatewayMac[3];
pDev->bacDevAddr.mac[1] = gatewayMac[2]; pDev->bacDevAddr.mac[1] = gatewayMac[2];
pDev->bacDevAddr.mac[2] = gatewayMac[1]; pDev->bacDevAddr.mac[2] = gatewayMac[1];
pDev->bacDevAddr.mac[3] = i; pDev->bacDevAddr.mac[3] = i;
memcpy( &pDev->bacDevAddr.mac[4], &myPort, 2 ); memcpy(&pDev->bacDevAddr.mac[4], &myPort, 2);
pDev->bacDevAddr.mac_len = 6; pDev->bacDevAddr.mac_len = 6;
pDev->bacDevAddr.net = VIRTUAL_DNET; pDev->bacDevAddr.net = VIRTUAL_DNET;
memcpy( &pDev->bacDevAddr.adr[0], &pDev->bacDevAddr.mac[0], 6 ); memcpy(&pDev->bacDevAddr.adr[0], &pDev->bacDevAddr.mac[0], 6);
pDev->bacDevAddr.len = 6; pDev->bacDevAddr.len = 6;
printf( " - Routed device [%d] ID %u at %s \n", i, printf(" - Routed device [%d] ID %u at %s \n", i,
pDev->bacObj.Object_Instance_Number, inet_ntoa( *netPtr ) ); pDev->bacObj.Object_Instance_Number, inet_ntoa(*netPtr));
#elif defined(BACDL_MSTP) #elif defined(BACDL_MSTP)
/* Todo: set MS/TP net and port #s */ /* Todo: set MS/TP net and port #s */
pDev->bacDevAddr.mac_len = 2; pDev->bacDevAddr.mac_len = 2;
@@ -298,34 +295,35 @@ int main(
time_t current_seconds = 0; time_t current_seconds = 0;
uint32_t elapsed_seconds = 0; uint32_t elapsed_seconds = 0;
uint32_t elapsed_milliseconds = 0; uint32_t elapsed_milliseconds = 0;
uint32_t first_object_instance = FIRST_DEVICE_NUMBER; uint32_t first_object_instance = FIRST_DEVICE_NUMBER;
#ifdef BACNET_TEST_VMAC #ifdef BACNET_TEST_VMAC
/* Router data */ /* Router data */
BACNET_DEVICE_PROFILE* device; BACNET_DEVICE_PROFILE *device;
BACNET_VMAC_ADDRESS adr; BACNET_VMAC_ADDRESS adr;
#endif #endif
/* allow the device ID to be set */ /* allow the device ID to be set */
if (argc > 1) { if (argc > 1) {
first_object_instance = strtol(argv[1], NULL, 0); first_object_instance = strtol(argv[1], NULL, 0);
if ( ( first_object_instance == 0 ) || if ((first_object_instance == 0) ||
( first_object_instance >= BACNET_MAX_INSTANCE ) ) { (first_object_instance >= BACNET_MAX_INSTANCE)) {
printf( "Error: Invalid Object Instance %s \n", argv[1] ); printf("Error: Invalid Object Instance %s \n", argv[1]);
printf( "Provide a number from 1 to %ul \n", BACNET_MAX_INSTANCE -1 ); printf("Provide a number from 1 to %ul \n",
exit(1); BACNET_MAX_INSTANCE - 1);
} exit(1);
}
} }
printf("BACnet Router Demo\n" "BACnet Stack Version %s\n" printf("BACnet Router Demo\n" "BACnet Stack Version %s\n"
"BACnet Device ID: %u\n" "Max APDU: %d\n", BACnet_Version, "BACnet Device ID: %u\n" "Max APDU: %d\n", BACnet_Version,
first_object_instance, MAX_APDU); first_object_instance, MAX_APDU);
Init_Service_Handlers( first_object_instance ); Init_Service_Handlers(first_object_instance);
dlenv_init(); dlenv_init();
Devices_Init( first_object_instance ); Devices_Init(first_object_instance);
Initialize_Device_Addresses( ); Initialize_Device_Addresses();
atexit(cleanup); atexit(cleanup);
#ifdef BACNET_TEST_VMAC #ifdef BACNET_TEST_VMAC
/* initialize vmac table and router device */ /* initialize vmac table and router device */
device = vmac_initialize(99, 2001); device = vmac_initialize(99, 2001);
debug_printf(device->name, "ROUTER:%u", vmac_get_subnet()); debug_printf(device->name, "ROUTER:%u", vmac_get_subnet());
#endif #endif
@@ -333,8 +331,8 @@ int main(
last_seconds = time(NULL); last_seconds = time(NULL);
/* broadcast an I-am-router-to-network on startup */ /* broadcast an I-am-router-to-network on startup */
printf( "Remote Network DNET Number %d \n", DNET_list[0] ); printf("Remote Network DNET Number %d \n", DNET_list[0]);
Send_I_Am_Router_To_Network( DNET_list ); Send_I_Am_Router_To_Network(DNET_list);
/* loop forever */ /* loop forever */
for (;;) { for (;;) {
@@ -346,7 +344,7 @@ int main(
/* process */ /* process */
if (pdu_len) { if (pdu_len) {
routing_npdu_handler(&src, DNET_list, &Rx_Buf[0], pdu_len); routing_npdu_handler(&src, DNET_list, &Rx_Buf[0], pdu_len);
} }
/* at least one second has passed */ /* at least one second has passed */
elapsed_seconds = current_seconds - last_seconds; elapsed_seconds = current_seconds - last_seconds;
+4 -5
View File
@@ -346,9 +346,8 @@ static bool cov_send_request(
value_list[1].next = NULL; value_list[1].next = NULL;
switch (cov_subscription->monitoredObjectIdentifier.type) { switch (cov_subscription->monitoredObjectIdentifier.type) {
case OBJECT_BINARY_INPUT: case OBJECT_BINARY_INPUT:
Binary_Input_Encode_Value_List Binary_Input_Encode_Value_List(cov_subscription->
(cov_subscription->monitoredObjectIdentifier.instance, monitoredObjectIdentifier.instance, &value_list[0]);
&value_list[0]);
break; break;
default: default:
goto COV_FAILED; goto COV_FAILED;
@@ -465,8 +464,8 @@ static bool cov_subscribe(
switch (cov_data->monitoredObjectIdentifier.type) { switch (cov_data->monitoredObjectIdentifier.type) {
case OBJECT_BINARY_INPUT: case OBJECT_BINARY_INPUT:
if (Binary_Input_Valid_Instance if (Binary_Input_Valid_Instance(cov_data->
(cov_data->monitoredObjectIdentifier.instance)) { monitoredObjectIdentifier.instance)) {
status = status =
cov_list_subscribe(src, cov_data, error_class, error_code); cov_list_subscribe(src, cov_data, error_class, error_code);
} else { } else {
+67 -71
View File
@@ -67,9 +67,9 @@
*/ */
static void network_control_handler( static void network_control_handler(
BACNET_ADDRESS * src, BACNET_ADDRESS * src,
int * DNET_list, int *DNET_list,
BACNET_NPDU_DATA * npdu_data, BACNET_NPDU_DATA * npdu_data,
uint8_t * npdu, uint8_t * npdu,
uint16_t npdu_len) uint16_t npdu_len)
{ {
uint16_t npdu_offset = 0; uint16_t npdu_offset = 0;
@@ -78,23 +78,19 @@ static void network_control_handler(
switch (npdu_data->network_message_type) { switch (npdu_data->network_message_type) {
case NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK: case NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK:
/* Send I-am-router-to-network with our one-network list if /* Send I-am-router-to-network with our one-network list if
* our specific network is requested, or no specific * our specific network is requested, or no specific
* network is requested. Silently drop other DNET requests. * network is requested. Silently drop other DNET requests.
*/ */
if (npdu_len >= 2) if (npdu_len >= 2) {
{ uint16_t network;
uint16_t network; len += decode_unsigned16(&npdu[len], &network);
len += decode_unsigned16(&npdu[len], &network); if (network == DNET_list[0]) {
if (network == DNET_list[0] ) Send_I_Am_Router_To_Network(DNET_list);
{ }
Send_I_Am_Router_To_Network( DNET_list ); } else {
} Send_I_Am_Router_To_Network(DNET_list);
} }
else
{
Send_I_Am_Router_To_Network( DNET_list );
}
break; break;
case NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK: case NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK:
/* Per the standard, we are supposed to process this message and /* Per the standard, we are supposed to process this message and
@@ -108,9 +104,9 @@ static void network_control_handler(
* -- Unless we act upon NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK * -- Unless we act upon NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK
* later for congestion control - then it could matter. * later for congestion control - then it could matter.
*/ */
debug_printf("%s for Networks: ", debug_printf("%s for Networks: ",
bactext_network_layer_msg_name( bactext_network_layer_msg_name
NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK ) ); (NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK));
while (npdu_len) { while (npdu_len) {
len = decode_unsigned16(&npdu[npdu_offset], &dnet); len = decode_unsigned16(&npdu[npdu_offset], &dnet);
debug_printf("%hu", dnet); debug_printf("%hu", dnet);
@@ -126,12 +122,12 @@ static void network_control_handler(
/* Do nothing, same as previous case. */ /* Do nothing, same as previous case. */
break; break;
case NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK: case NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK:
if ( npdu_len >= 3 ) { if (npdu_len >= 3) {
decode_unsigned16(&npdu[1], &dnet); decode_unsigned16(&npdu[1], &dnet);
debug_printf("Received %s for Network: ", debug_printf("Received %s for Network: ",
bactext_network_layer_msg_name( bactext_network_layer_msg_name
NETWORK_MESSAGE_I_COULD_BE_ROUTER_TO_NETWORK ) ); (NETWORK_MESSAGE_I_COULD_BE_ROUTER_TO_NETWORK));
debug_printf("%hu, Reason code: %d \n", dnet, npdu[0] ); debug_printf("%hu, Reason code: %d \n", dnet, npdu[0]);
} }
break; break;
case NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK: case NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK:
@@ -143,18 +139,18 @@ static void network_control_handler(
* NETWORK_MESSAGE_INIT_RT_TABLE_ACK and a list of all our * NETWORK_MESSAGE_INIT_RT_TABLE_ACK and a list of all our
* reachable networks. * reachable networks.
*/ */
if ( npdu_len > 0) { if (npdu_len > 0) {
/* If Number of Ports is 0, broadcast our "full" table */ /* If Number of Ports is 0, broadcast our "full" table */
if (npdu[0] == 0) if (npdu[0] == 0)
Send_Initialize_Routing_Table_Ack( NULL, DNET_list ); Send_Initialize_Routing_Table_Ack(NULL, DNET_list);
else { else {
/* If they sent us a list, just politely ACK it /* If they sent us a list, just politely ACK it
* with no routing list of our own. But we don't DO * with no routing list of our own. But we don't DO
* anything with the info, either. * anything with the info, either.
*/ */
int listTerminator = -1; int listTerminator = -1;
Send_Initialize_Routing_Table_Ack( src, &listTerminator ); Send_Initialize_Routing_Table_Ack(src, &listTerminator);
} }
break; break;
} }
/* Else, fall through to do nothing. */ /* Else, fall through to do nothing. */
@@ -168,9 +164,9 @@ static void network_control_handler(
break; break;
default: default:
/* An unrecognized message is bad; send an error response. */ /* An unrecognized message is bad; send an error response. */
Send_Reject_Message_To_Network( src, Send_Reject_Message_To_Network(src,
NETWORK_REJECT_UNKNOWN_MESSAGE_TYPE, DNET_list[0] ); NETWORK_REJECT_UNKNOWN_MESSAGE_TYPE, DNET_list[0]);
/* Sending our DNET doesn't make a lot of sense, does it? */ /* Sending our DNET doesn't make a lot of sense, does it? */
break; break;
} }
} }
@@ -190,31 +186,32 @@ static void network_control_handler(
* Normally just one valid entry; terminated with a -1 value. * Normally just one valid entry; terminated with a -1 value.
* @param apdu [in] The apdu portion of the request, to be processed. * @param apdu [in] The apdu portion of the request, to be processed.
* @param apdu_len [in] The total (remaining) length of the apdu. * @param apdu_len [in] The total (remaining) length of the apdu.
*/ */
static void routed_apdu_handler( static void routed_apdu_handler(
BACNET_ADDRESS * src, BACNET_ADDRESS * src,
BACNET_ADDRESS * dest, BACNET_ADDRESS * dest,
int * DNET_list, int *DNET_list,
uint8_t * apdu, uint8_t * apdu,
uint16_t apdu_len) uint16_t apdu_len)
{ {
int cursor = 0; /* Starting hint */ int cursor = 0; /* Starting hint */
bool bGotOne = false; bool bGotOne = false;
if (!Routed_Device_Is_Valid_Network( dest->net, DNET_list ) ) { if (!Routed_Device_Is_Valid_Network(dest->net, DNET_list)) {
/* We don't know how to reach this one */ /* We don't know how to reach this one */
Send_Reject_Message_To_Network( src, NETWORK_REJECT_NO_ROUTE, dest->net ); Send_Reject_Message_To_Network(src, NETWORK_REJECT_NO_ROUTE,
dest->net);
return; return;
} }
while ( Routed_Device_GetNext( dest, DNET_list, &cursor ) ) { while (Routed_Device_GetNext(dest, DNET_list, &cursor)) {
apdu_handler(src, apdu, apdu_len); apdu_handler(src, apdu, apdu_len);
bGotOne = true; bGotOne = true;
if ( cursor < 0 ) /* If no more matches, */ if (cursor < 0) /* If no more matches, */
break; /* We don't need to keep looking */ break; /* We don't need to keep looking */
} }
if ( !bGotOne ) { if (!bGotOne) {
/* Just silently drop this packet. */ /* Just silently drop this packet. */
} }
} }
@@ -249,10 +246,10 @@ static void routed_apdu_handler(
*/ */
void routing_npdu_handler( void routing_npdu_handler(
BACNET_ADDRESS * src, BACNET_ADDRESS * src,
int * DNET_list, int *DNET_list,
uint8_t * pdu, uint8_t * pdu,
uint16_t pdu_len) uint16_t pdu_len)
{ {
int apdu_offset = 0; int apdu_offset = 0;
BACNET_ADDRESS dest = { 0 }; BACNET_ADDRESS dest = { 0 };
BACNET_NPDU_DATA npdu_data = { 0 }; BACNET_NPDU_DATA npdu_data = { 0 };
@@ -260,29 +257,28 @@ void routing_npdu_handler(
/* only handle the version that we know how to handle */ /* only handle the version that we know how to handle */
if (pdu[0] == BACNET_PROTOCOL_VERSION) { if (pdu[0] == BACNET_PROTOCOL_VERSION) {
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data); apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
if ( apdu_offset <= 0 ) { if (apdu_offset <= 0) {
debug_printf("NPDU: Decoding failed; Discarded!\n"); debug_printf("NPDU: Decoding failed; Discarded!\n");
} else if (npdu_data.network_layer_message) { } else if (npdu_data.network_layer_message) {
if ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) { if ((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) {
network_control_handler( src, DNET_list, &npdu_data, network_control_handler(src, DNET_list, &npdu_data,
&pdu[apdu_offset], &pdu[apdu_offset], (uint16_t) (pdu_len - apdu_offset));
(uint16_t) (pdu_len - apdu_offset));
} else { } else {
/* The DNET is set, but we don't support downstream routers, /* The DNET is set, but we don't support downstream routers,
* so we just silently drop this network layer message, * so we just silently drop this network layer message,
* since only routers can handle it (even if for our DNET) */ * since only routers can handle it (even if for our DNET) */
} }
} else if (apdu_offset <= pdu_len) { } else if (apdu_offset <= pdu_len) {
if ( (dest.net == 0) || (npdu_data.hop_count > 1) ) if ((dest.net == 0) || (npdu_data.hop_count > 1))
routed_apdu_handler(src, &dest, DNET_list, &pdu[apdu_offset], routed_apdu_handler(src, &dest, DNET_list, &pdu[apdu_offset],
(uint16_t) (pdu_len - apdu_offset)); (uint16_t) (pdu_len - apdu_offset));
/* Else, hop_count bottomed out and we discard this one. */ /* Else, hop_count bottomed out and we discard this one. */
} }
} else { } else {
/* Should we send NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK? */ /* Should we send NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK? */
debug_printf( debug_printf
"NPDU: Unsupported BACnet Protocol Version=%u. Discarded!\n", ("NPDU: Unsupported BACnet Protocol Version=%u. Discarded!\n",
(unsigned) pdu[0]); (unsigned) pdu[0]);
} }
return; return;
+2 -2
View File
@@ -170,7 +170,7 @@ int rp_ack_fully_decode_service_request(
read_access_data->listOfProperties = rp1_property; read_access_data->listOfProperties = rp1_property;
if (rp1_property == NULL) { if (rp1_property == NULL) {
/* can't proceed if calloc failed. */ /* can't proceed if calloc failed. */
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
rp1_property->propertyIdentifier = rp1data.object_property; rp1_property->propertyIdentifier = rp1data.object_property;
rp1_property->propertyArrayIndex = rp1data.array_index; rp1_property->propertyArrayIndex = rp1data.array_index;
@@ -227,7 +227,7 @@ int rp_ack_fully_decode_service_request(
read_access_data->listOfProperties = NULL; read_access_data->listOfProperties = NULL;
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
if (vlen > 0) { if (vlen > 0) {
/* If more values */ /* If more values */
old_value = value; old_value = value;
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE)); value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
+6 -6
View File
@@ -220,8 +220,8 @@ void rpm_ack_print_data(
#if PRINT_ENABLED #if PRINT_ENABLED
if (listOfProperties->propertyIdentifier < 512) { if (listOfProperties->propertyIdentifier < 512) {
fprintf(stdout, " %s: ", fprintf(stdout, " %s: ",
bactext_property_name(listOfProperties-> bactext_property_name
propertyIdentifier)); (listOfProperties->propertyIdentifier));
} else { } else {
fprintf(stdout, " proprietary %u: ", fprintf(stdout, " proprietary %u: ",
(unsigned) listOfProperties->propertyIdentifier); (unsigned) listOfProperties->propertyIdentifier);
@@ -268,10 +268,10 @@ void rpm_ack_print_data(
#if PRINT_ENABLED #if PRINT_ENABLED
/* AccessError */ /* AccessError */
fprintf(stdout, "BACnet Error: %s: %s\r\n", fprintf(stdout, "BACnet Error: %s: %s\r\n",
bactext_error_class_name((int) listOfProperties-> bactext_error_class_name((int) listOfProperties->error.
error.error_class), error_class),
bactext_error_code_name((int) listOfProperties-> bactext_error_code_name((int) listOfProperties->error.
error.error_code)); error_code));
#endif #endif
} }
listOfProperties = listOfProperties->next; listOfProperties = listOfProperties->next;
+2 -2
View File
@@ -104,8 +104,8 @@ void handler_ucov_notification(
fprintf(stderr, "UCOV: "); fprintf(stderr, "UCOV: ");
if (pProperty_value->propertyIdentifier < 512) { if (pProperty_value->propertyIdentifier < 512) {
fprintf(stderr, "%s ", fprintf(stderr, "%s ",
bactext_property_name bactext_property_name(pProperty_value->
(pProperty_value->propertyIdentifier)); propertyIdentifier));
} else { } else {
fprintf(stderr, "proprietary %u ", fprintf(stderr, "proprietary %u ",
pProperty_value->propertyIdentifier); pProperty_value->propertyIdentifier);
+15 -15
View File
@@ -42,8 +42,8 @@
* or object ID, if the Device has a match. * or object ID, if the Device has a match.
* @param data [in] The decoded who-has payload from the request. * @param data [in] The decoded who-has payload from the request.
*/ */
static void match_name_or_object( static void match_name_or_object(
BACNET_WHO_HAS_DATA * data) BACNET_WHO_HAS_DATA * data)
{ {
char *object_name = NULL; char *object_name = NULL;
int object_type = 0; int object_type = 0;
@@ -98,10 +98,10 @@ void handler_who_has(
if ((data.low_limit == -1) || (data.high_limit == -1)) if ((data.low_limit == -1) || (data.high_limit == -1))
directed_to_me = true; directed_to_me = true;
else if ((Device_Object_Instance_Number() >= (uint32_t) data.low_limit) else if ((Device_Object_Instance_Number() >= (uint32_t) data.low_limit)
&& (Device_Object_Instance_Number() <= (uint32_t) data.high_limit)) && (Device_Object_Instance_Number() <= (uint32_t) data.high_limit))
directed_to_me = true; directed_to_me = true;
if (directed_to_me) { if (directed_to_me) {
match_name_or_object(&data); match_name_or_object(&data);
} }
} }
} }
@@ -126,23 +126,23 @@ void handler_who_has_for_routing(
int len = 0; int len = 0;
BACNET_WHO_HAS_DATA data; BACNET_WHO_HAS_DATA data;
int32_t dev_instance; int32_t dev_instance;
int cursor = 0; /* Starting hint */ int cursor = 0; /* Starting hint */
int my_list[2] = {0, -1}; /* Not really used, so dummy values */ int my_list[2] = { 0, -1 }; /* Not really used, so dummy values */
BACNET_ADDRESS bcast_net; BACNET_ADDRESS bcast_net;
(void) src; (void) src;
len = whohas_decode_service_request(service_request, service_len, &data); len = whohas_decode_service_request(service_request, service_len, &data);
if (len > 0) { if (len > 0) {
/* Go through all devices, starting with the root gateway Device */ /* Go through all devices, starting with the root gateway Device */
memset( &bcast_net, 0, sizeof(BACNET_ADDRESS)); memset(&bcast_net, 0, sizeof(BACNET_ADDRESS));
bcast_net.net = BACNET_BROADCAST_NETWORK; /* That's all we have to set */ bcast_net.net = BACNET_BROADCAST_NETWORK; /* That's all we have to set */
while ( Routed_Device_GetNext( &bcast_net, my_list, &cursor ) ) { while (Routed_Device_GetNext(&bcast_net, my_list, &cursor)) {
dev_instance = Device_Object_Instance_Number(); dev_instance = Device_Object_Instance_Number();
if ( (data.low_limit == -1) || (data.high_limit == -1) || if ((data.low_limit == -1) || (data.high_limit == -1) ||
((dev_instance >= data.low_limit) && ((dev_instance >= data.low_limit) &&
(dev_instance <= data.high_limit))) (dev_instance <= data.high_limit)))
match_name_or_object(&data); match_name_or_object(&data);
} }
} }
} }
#endif /* BAC_ROUTING */ #endif /* BAC_ROUTING */
+24 -24
View File
@@ -127,44 +127,44 @@ static void check_who_is_for_routing(
uint8_t * service_request, uint8_t * service_request,
uint16_t service_len, uint16_t service_len,
BACNET_ADDRESS * src, BACNET_ADDRESS * src,
bool is_unicast ) bool is_unicast)
{ {
int len = 0; int len = 0;
int32_t low_limit = 0; int32_t low_limit = 0;
int32_t high_limit = 0; int32_t high_limit = 0;
int32_t dev_instance; int32_t dev_instance;
int cursor = 0; /* Starting hint */ int cursor = 0; /* Starting hint */
int my_list[2] = {0, -1}; /* Not really used, so dummy values */ int my_list[2] = { 0, -1 }; /* Not really used, so dummy values */
BACNET_ADDRESS bcast_net; BACNET_ADDRESS bcast_net;
len = len =
whois_decode_service_request(service_request, service_len, &low_limit, whois_decode_service_request(service_request, service_len, &low_limit,
&high_limit); &high_limit);
if (len == -1) { if (len == -1) {
/* Invalid; just leave */ /* Invalid; just leave */
return; return;
} }
/* If len == 0, then high_limit is untouched and still == 0 */ /* If len == 0, then high_limit is untouched and still == 0 */
/* BACnet wildcard is the max instance number - everyone responds */ /* BACnet wildcard is the max instance number - everyone responds */
if ((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) && if ((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) &&
(BACNET_MAX_INSTANCE <= (uint32_t) high_limit)) (BACNET_MAX_INSTANCE <= (uint32_t) high_limit))
high_limit = 0; high_limit = 0;
/* This is the "always accept" case we will test for below */ /* This is the "always accept" case we will test for below */
/* Go through all devices, starting with the root gateway Device */ /* Go through all devices, starting with the root gateway Device */
memset( &bcast_net, 0, sizeof(BACNET_ADDRESS)); memset(&bcast_net, 0, sizeof(BACNET_ADDRESS));
bcast_net.net = BACNET_BROADCAST_NETWORK; /* That's all we have to set */ bcast_net.net = BACNET_BROADCAST_NETWORK; /* That's all we have to set */
while ( Routed_Device_GetNext( &bcast_net, my_list, &cursor ) ) { while (Routed_Device_GetNext(&bcast_net, my_list, &cursor)) {
dev_instance = Device_Object_Instance_Number(); dev_instance = Device_Object_Instance_Number();
if ( (high_limit == 0) || if ((high_limit == 0) || ((dev_instance >= low_limit) &&
((dev_instance >= low_limit) && (dev_instance <= high_limit))) { (dev_instance <= high_limit))) {
if ( is_unicast ) if (is_unicast)
Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src); Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src);
else else
Send_I_Am(&Handler_Transmit_Buffer[0]); Send_I_Am(&Handler_Transmit_Buffer[0]);
} }
} }
} }
@@ -185,7 +185,7 @@ void handler_who_is_bcast_for_routing(
uint16_t service_len, uint16_t service_len,
BACNET_ADDRESS * src) BACNET_ADDRESS * src)
{ {
check_who_is_for_routing(service_request, service_len, src, false ); check_who_is_for_routing(service_request, service_len, src, false);
} }
@@ -205,6 +205,6 @@ void handler_who_is_unicast_for_routing(
uint16_t service_len, uint16_t service_len,
BACNET_ADDRESS * src) BACNET_ADDRESS * src)
{ {
check_who_is_for_routing(service_request, service_len, src, true ); check_who_is_for_routing(service_request, service_len, src, true);
} }
#endif /* BAC_ROUTING */ #endif /* BAC_ROUTING */
+3 -4
View File
@@ -178,12 +178,11 @@ bool WPValidateString(
0)) { 0)) {
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE; *pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if ((bEmptyAllowed == false) && } else if ((bEmptyAllowed == false) &&
(!characterstring_printable( (!characterstring_printable(&pValue->type.Character_String))) {
&pValue->type.Character_String))) {
/* assumption: non-empty also means must be "printable" */ /* assumption: non-empty also means must be "printable" */
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE; *pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
} else if (characterstring_length(&pValue-> } else if (characterstring_length(&pValue->type.
type.Character_String) >= iMaxLen) { Character_String) >= iMaxLen) {
*pErrorClass = ERROR_CLASS_RESOURCES; *pErrorClass = ERROR_CLASS_RESOURCES;
*pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY; *pErrorCode = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
} else } else
+1 -1
View File
@@ -70,7 +70,7 @@ uint8_t Send_CEvent_Notify(
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,
+5 -3
View File
@@ -65,7 +65,8 @@ int iam_encode_pdu(
pdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data); pdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(), len =
iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(),
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier()); MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
pdu_len += len; pdu_len += len;
@@ -139,8 +140,9 @@ int iam_unicast_encode_pdu(
npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL);
npdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data); npdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
apdu_len = iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(), apdu_len =
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier()); iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(),
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
pdu_len = npdu_len + apdu_len; pdu_len = npdu_len + apdu_len;
return pdu_len; return pdu_len;
+3 -1
View File
@@ -75,7 +75,9 @@ void Send_I_Have(
datalink_get_broadcast_address(&dest); datalink_get_broadcast_address(&dest);
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
data.device_id.type = OBJECT_DEVICE; data.device_id.type = OBJECT_DEVICE;
+103 -105
View File
@@ -71,7 +71,7 @@ static void npdu_encode_npdu_network(
npdu_data->network_message_type = network_message_type; /* optional */ npdu_data->network_message_type = network_message_type; /* optional */
npdu_data->vendor_id = 0; /* optional, if net message type is > 0x80 */ npdu_data->vendor_id = 0; /* optional, if net message type is > 0x80 */
npdu_data->priority = priority; npdu_data->priority = priority;
npdu_data->hop_count = DFLT_HOP_COUNT; npdu_data->hop_count = DFLT_HOP_COUNT;
} }
} }
@@ -97,119 +97,117 @@ static void npdu_encode_npdu_network(
* the type of message. * the type of message.
* @return Number of bytes sent, or <=0 if no message was sent. * @return Number of bytes sent, or <=0 if no message was sent.
*/ */
int Send_Network_Layer_Message( int Send_Network_Layer_Message(
BACNET_NETWORK_MESSAGE_TYPE network_message_type, BACNET_NETWORK_MESSAGE_TYPE network_message_type,
BACNET_ADDRESS * dst, BACNET_ADDRESS * dst,
int * iArgs ) int *iArgs)
{ {
int len = 0; int len = 0;
int pdu_len = 0; int pdu_len = 0;
int bytes_sent = 0; int bytes_sent = 0;
int *pVal = iArgs; /* Start with first value */ int *pVal = iArgs; /* Start with first value */
bool data_expecting_reply = false; bool data_expecting_reply = false;
BACNET_NPDU_DATA npdu_data; BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS bcastDest; BACNET_ADDRESS bcastDest;
if ( iArgs == NULL ) if (iArgs == NULL)
return 0; /* Can't do anything here */ return 0; /* Can't do anything here */
/* If dst was NULL, get our (local net) broadcast MAC address. */ /* If dst was NULL, get our (local net) broadcast MAC address. */
if ( dst == NULL ) { if (dst == NULL) {
datalink_get_broadcast_address(&bcastDest); datalink_get_broadcast_address(&bcastDest);
dst = &bcastDest; dst = &bcastDest;
} }
if ( network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE ) if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE)
data_expecting_reply = true; /* DER in this one case */ data_expecting_reply = true; /* DER in this one case */
npdu_encode_npdu_network(&npdu_data, npdu_encode_npdu_network(&npdu_data, network_message_type,
network_message_type, data_expecting_reply, data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
MESSAGE_PRIORITY_NORMAL);
/* We don't need src information, since a message can't originate from /* We don't need src information, since a message can't originate from
* our downstream BACnet network. * our downstream BACnet network.
*/ */
pdu_len = pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dst, NULL, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], dst, NULL, &npdu_data);
/* Now encode the optional payload bytes, per message type */
switch ( network_message_type )
{
case NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK:
if (*pVal >= 0) {
len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) *pVal);
pdu_len += len;
}
/* else, don't encode a DNET */
break;
case NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK:
case NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK:
case NETWORK_MESSAGE_ROUTER_AVAILABLE_TO_NETWORK:
while ( *pVal >= 0 ) {
len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) *pVal);
pdu_len += len;
pVal++;
}
break;
case NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK:
/* Encode the Reason byte, then the DNET */
Handler_Transmit_Buffer[pdu_len++] = (uint8_t) *pVal;
pVal++;
len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) *pVal);
pdu_len += len;
break;
case NETWORK_MESSAGE_INIT_RT_TABLE: /* Now encode the optional payload bytes, per message type */
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK: switch (network_message_type) {
/* First, count the number of Ports we will encode */ case NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK:
len = 0; /* Re-purpose len as our counter here */ if (*pVal >= 0) {
while ( *pVal >= 0 ) {
len++;
pVal++;
}
Handler_Transmit_Buffer[pdu_len++] = (uint8_t) len;
if ( len > 0 ) {
uint8_t portID = 1;
pVal = iArgs; /* Reset to beginning */
/* Now encode each (virtual) BACNET_ROUTER_PORT.
* We will simply use a positive index for PortID,
* and have no PortInfo.
*/
while ( *pVal >= 0 ) {
len = len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len], encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) *pVal); (uint16_t) * pVal);
pdu_len += len;
}
/* else, don't encode a DNET */
break;
case NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK:
case NETWORK_MESSAGE_ROUTER_BUSY_TO_NETWORK:
case NETWORK_MESSAGE_ROUTER_AVAILABLE_TO_NETWORK:
while (*pVal >= 0) {
len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) * pVal);
pdu_len += len; pdu_len += len;
Handler_Transmit_Buffer[pdu_len++] = portID++;
Handler_Transmit_Buffer[pdu_len++] = 0;
debug_printf( " Sending Routing Table entry for %u \n", *pVal );
pVal++; pVal++;
} }
} break;
break;
case NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK:
default: /* Encode the Reason byte, then the DNET */
debug_printf("Not sent: %s message unsupported \n", Handler_Transmit_Buffer[pdu_len++] = (uint8_t) * pVal;
bactext_network_layer_msg_name( network_message_type ) ); pVal++;
return 0; len =
break; /* Will never reach this line */ encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) * pVal);
pdu_len += len;
break;
case NETWORK_MESSAGE_INIT_RT_TABLE:
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
/* First, count the number of Ports we will encode */
len = 0; /* Re-purpose len as our counter here */
while (*pVal >= 0) {
len++;
pVal++;
}
Handler_Transmit_Buffer[pdu_len++] = (uint8_t) len;
if (len > 0) {
uint8_t portID = 1;
pVal = iArgs; /* Reset to beginning */
/* Now encode each (virtual) BACNET_ROUTER_PORT.
* We will simply use a positive index for PortID,
* and have no PortInfo.
*/
while (*pVal >= 0) {
len =
encode_unsigned16(&Handler_Transmit_Buffer[pdu_len],
(uint16_t) * pVal);
pdu_len += len;
Handler_Transmit_Buffer[pdu_len++] = portID++;
Handler_Transmit_Buffer[pdu_len++] = 0;
debug_printf(" Sending Routing Table entry for %u \n",
*pVal);
pVal++;
}
}
break;
default:
debug_printf("Not sent: %s message unsupported \n",
bactext_network_layer_msg_name(network_message_type));
return 0;
break; /* Will never reach this line */
} }
if ( dst != NULL ) if (dst != NULL)
debug_printf("Sending %s message to BACnet network %u \n", debug_printf("Sending %s message to BACnet network %u \n",
bactext_network_layer_msg_name( network_message_type ), bactext_network_layer_msg_name(network_message_type), dst->net);
dst->net );
else else
debug_printf("Sending %s message to local BACnet network \n", debug_printf("Sending %s message to local BACnet network \n",
bactext_network_layer_msg_name( network_message_type ) ); bactext_network_layer_msg_name(network_message_type));
/* Now send the message */ /* Now send the message */
bytes_sent = bytes_sent =
@@ -217,13 +215,13 @@ int Send_Network_Layer_Message(
pdu_len); pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) { if (bytes_sent <= 0) {
int wasErrno = errno; /* preserve the errno */ int wasErrno = errno; /* preserve the errno */
debug_printf("Failed to send %s message (%s)!\n", debug_printf("Failed to send %s message (%s)!\n",
bactext_network_layer_msg_name( network_message_type ), bactext_network_layer_msg_name(network_message_type),
strerror(wasErrno)); strerror(wasErrno));
} }
#endif #endif
return bytes_sent; return bytes_sent;
} }
@@ -242,8 +240,8 @@ void Send_Who_Is_Router_To_Network(
BACNET_ADDRESS * dst, BACNET_ADDRESS * dst,
int dnet) int dnet)
{ {
Send_Network_Layer_Message( NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, Send_Network_Layer_Message(NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, dst,
dst, &dnet ); &dnet);
} }
/** Broadcast an I-am-router-to-network message, giving the list of networks /** Broadcast an I-am-router-to-network message, giving the list of networks
@@ -259,8 +257,8 @@ void Send_I_Am_Router_To_Network(
const int DNET_list[]) const int DNET_list[])
{ {
/* Use a NULL dst here since we want a broadcast MAC address. */ /* Use a NULL dst here since we want a broadcast MAC address. */
Send_Network_Layer_Message( NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK, Send_Network_Layer_Message(NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK, NULL,
NULL, (int *) DNET_list ); (int *) DNET_list);
} }
/** Finds a specific router, or all reachable BACnet networks. /** Finds a specific router, or all reachable BACnet networks.
@@ -281,9 +279,9 @@ void Send_Reject_Message_To_Network(
int iArgs[2]; int iArgs[2];
iArgs[0] = reject_reason; iArgs[0] = reject_reason;
iArgs[1] = dnet; iArgs[1] = dnet;
Send_Network_Layer_Message( NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK, Send_Network_Layer_Message(NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK, dst,
dst, iArgs ); iArgs);
debug_printf(" Reject Reason=%d, DNET=%u\n", reject_reason, dnet ); debug_printf(" Reject Reason=%d, DNET=%u\n", reject_reason, dnet);
} }
@@ -308,8 +306,8 @@ void Send_Initialize_Routing_Table(
const int DNET_list[]) const int DNET_list[])
{ {
/* Use a NULL dst here since we want a broadcast MAC address. */ /* Use a NULL dst here since we want a broadcast MAC address. */
Send_Network_Layer_Message( NETWORK_MESSAGE_INIT_RT_TABLE, Send_Network_Layer_Message(NETWORK_MESSAGE_INIT_RT_TABLE, dst,
dst, (int *) DNET_list ); (int *) DNET_list);
} }
@@ -334,6 +332,6 @@ void Send_Initialize_Routing_Table_Ack(
BACNET_ADDRESS * dst, BACNET_ADDRESS * dst,
const int DNET_list[]) const int DNET_list[])
{ {
Send_Network_Layer_Message( NETWORK_MESSAGE_INIT_RT_TABLE_ACK, Send_Network_Layer_Message(NETWORK_MESSAGE_INIT_RT_TABLE_ACK, dst,
dst, (int *) DNET_list ); (int *) DNET_list);
} }
+4 -2
View File
@@ -65,7 +65,8 @@ void Send_TimeSync(
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
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, &my_address, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = len =
@@ -101,7 +102,8 @@ void Send_TimeSyncUTC(
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
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, &my_address, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
pdu_len = pdu_len =
+3 -1
View File
@@ -61,7 +61,9 @@ void Send_UnconfirmedPrivateTransfer(
datalink_get_my_address(&my_address); datalink_get_my_address(&my_address);
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address, &npdu_data); pdu_len =
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = len =
+4 -2
View File
@@ -77,7 +77,8 @@ void Send_WhoHas_Name(
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
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, &my_address, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
data.low_limit = low_limit; data.low_limit = low_limit;
@@ -131,7 +132,8 @@ void Send_WhoHas_Object(
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
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, &my_address, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
&npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
data.low_limit = low_limit; data.low_limit = low_limit;
+2 -1
View File
@@ -72,7 +72,8 @@ void Send_WhoIs_To_Network(
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], target_address, &my_address, &npdu_data); npdu_encode_pdu(&Handler_Transmit_Buffer[0], target_address,
&my_address, &npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = len =
whois_encode_apdu(&Handler_Transmit_Buffer[pdu_len], low_limit, whois_encode_apdu(&Handler_Transmit_Buffer[pdu_len], low_limit,
+2 -3
View File
@@ -155,9 +155,8 @@ uint8_t Send_Write_Property_Request(
#if PRINT_ENABLED_DEBUG #if PRINT_ENABLED_DEBUG
fprintf(stderr, "WriteProperty service: " "%s tag=%d\n", fprintf(stderr, "WriteProperty service: " "%s tag=%d\n",
(object_value->context_specific ? "context" : "application"), (object_value->context_specific ? "context" : "application"),
(int) (object_value-> (int) (object_value->context_specific ? object_value->
context_specific ? object_value->context_tag : object_value-> context_tag : object_value->tag));
tag));
#endif #endif
len = bacapp_encode_data(&application_data[apdu_len], object_value); len = bacapp_encode_data(&application_data[apdu_len], object_value);
if ((len + apdu_len) < MAX_APDU) { if ((len + apdu_len) < MAX_APDU) {
+2 -2
View File
@@ -48,8 +48,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+5 -6
View File
@@ -50,8 +50,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
@@ -61,12 +61,12 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
static BACNET_ADDRESS Target_Router_Address; static BACNET_ADDRESS Target_Router_Address;
/* static BACNET_ROUTER_PORT *Target_Router_Port_List; */ /* static BACNET_ROUTER_PORT *Target_Router_Port_List; */
#define VIRTUAL_DNET 2709 /* your choice of number here */ #define VIRTUAL_DNET 2709 /* your choice of number here */
/** The list of DNETs that our router can reach. /** The list of DNETs that our router can reach.
* Only one entry since we don't support downstream routers. * Only one entry since we don't support downstream routers.
*/ */
int DNET_list[2] = { int DNET_list[2] = {
VIRTUAL_DNET, -1 /* Need -1 terminator */ VIRTUAL_DNET, -1 /* Need -1 terminator */
}; };
static bool Error_Detected = false; static bool Error_Detected = false;
@@ -333,8 +333,7 @@ int main(
last_seconds = time(NULL); last_seconds = time(NULL);
timeout_seconds = apdu_timeout() / 1000; timeout_seconds = apdu_timeout() / 1000;
/* send the request */ /* send the request */
Send_Initialize_Routing_Table(&Target_Router_Address, Send_Initialize_Routing_Table(&Target_Router_Address, DNET_list);
DNET_list);
/* loop forever */ /* loop forever */
for (;;) { for (;;) {
/* increment timer - exit if timed out */ /* increment timer - exit if timed out */
+1 -1
View File
@@ -182,7 +182,7 @@ int Analog_Input_Read_Property(
return 0; return 0;
} }
apdu = rpdata->application_data; apdu = rpdata->application_data;
switch ((int)rpdata->object_property) { switch ((int) rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
apdu_len = apdu_len =
encode_application_object_id(&apdu[0], OBJECT_ANALOG_INPUT, encode_application_object_id(&apdu[0], OBJECT_ANALOG_INPUT,
+4 -4
View File
@@ -446,11 +446,11 @@ bool Analog_Output_Write_Property(
if (status) { if (status) {
level = AO_LEVEL_NULL; level = AO_LEVEL_NULL;
object_index = object_index =
Analog_Output_Instance_To_Index Analog_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
status = status =
Analog_Output_Present_Value_Relinquish Analog_Output_Present_Value_Relinquish(wp_data->
(wp_data->object_instance, wp_data->priority); object_instance, wp_data->priority);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
+2 -2
View File
@@ -396,8 +396,8 @@ bool Analog_Value_Write_Property(
if (status) { if (status) {
level = ANALOG_LEVEL_NULL; level = ANALOG_LEVEL_NULL;
object_index = object_index =
Analog_Value_Instance_To_Index Analog_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
+4 -4
View File
@@ -375,8 +375,8 @@ bool Binary_Output_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated; level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index = object_index =
Binary_Output_Instance_To_Index Binary_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Binary_Output_Level[object_index][priority] = level; Binary_Output_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
@@ -402,8 +402,8 @@ bool Binary_Output_Write_Property(
if (status) { if (status) {
level = BINARY_NULL; level = BINARY_NULL;
object_index = object_index =
Binary_Output_Instance_To_Index Binary_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
+4 -4
View File
@@ -358,8 +358,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = (BACNET_BINARY_PV) value.type.Enumerated; level = (BACNET_BINARY_PV) value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Binary_Value_Level[object_index][priority] = level; Binary_Value_Level[object_index][priority] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
@@ -385,8 +385,8 @@ bool Binary_Value_Write_Property(
if (status) { if (status) {
level = BINARY_NULL; level = BINARY_NULL;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
+21 -20
View File
@@ -354,7 +354,7 @@ uint32_t Device_Object_Instance_Number(
void) void)
{ {
#ifdef BAC_ROUTING #ifdef BAC_ROUTING
return Routed_Device_Object_Instance_Number(); return Routed_Device_Object_Instance_Number();
#else #else
return Object_Instance_Number; return Object_Instance_Number;
#endif #endif
@@ -1141,8 +1141,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */ /* FIXME: we could send an I-Am broadcast to let the world know */
} else { } else {
status = false; status = false;
@@ -1175,8 +1175,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
/* FIXME: bounds check? */ /* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t) value. Device_Set_Vendor_Identifier((uint16_t) value.type.
type.Unsigned_Int); Unsigned_Int);
} }
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
@@ -1203,8 +1203,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false, WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Object_Name(characterstring_value(&value. Device_Set_Object_Name(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1213,8 +1213,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_LOC_LEN, true, WPValidateString(&value, MAX_DEV_LOC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Location(characterstring_value(&value. Device_Set_Location(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1224,8 +1224,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_DESC_LEN, true, WPValidateString(&value, MAX_DEV_DESC_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Description(characterstring_value(&value. Device_Set_Description(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1234,8 +1234,8 @@ bool Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_MOD_LEN, true, WPValidateString(&value, MAX_DEV_MOD_LEN, true,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Device_Set_Model_Name(characterstring_value(&value. Device_Set_Model_Name(characterstring_value(&value.type.
type.Character_String), Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
@@ -1247,8 +1247,8 @@ bool Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if (value.type.Unsigned_Int <= 255) { if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames((uint8_t) value. dlmstp_set_max_info_frames((uint8_t) value.type.
type.Unsigned_Int); Unsigned_Int);
} else { } else {
status = false; status = false;
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1328,7 +1328,7 @@ bool Device_Write_Property(
* functions in order to properly support the default handlers. * functions in order to properly support the default handlers.
*/ */
void Device_Initialize_Object_Functions( void Device_Initialize_Object_Functions(
object_functions_t *object_table) object_functions_t * object_table)
{ {
Object_Table = object_table; Object_Table = object_table;
} }
@@ -1407,25 +1407,26 @@ bool DeviceGetRRInfo(
instance number. instance number.
*/ */
void Routing_Device_Init( void Routing_Device_Init(
uint32_t first_object_instance ) uint32_t first_object_instance)
{ {
struct object_functions *pDevObject = NULL; struct object_functions *pDevObject = NULL;
/* First, do the usual Device_Init() functions: */ /* First, do the usual Device_Init() functions: */
Device_Init(); Device_Init();
/* Initialize with our preset strings */ /* Initialize with our preset strings */
Add_Routed_Device( first_object_instance, My_Object_Name, Description ); Add_Routed_Device(first_object_instance, My_Object_Name, Description);
/* Now substitute our routed versions of the main object functions. */ /* Now substitute our routed versions of the main object functions. */
pDevObject = &Object_Table[0]; pDevObject = &Object_Table[0];
pDevObject->Object_Index_To_Instance = Routed_Device_Index_To_Instance; pDevObject->Object_Index_To_Instance = Routed_Device_Index_To_Instance;
pDevObject->Object_Valid_Instance = Routed_Device_Valid_Object_Instance_Number; pDevObject->Object_Valid_Instance =
Routed_Device_Valid_Object_Instance_Number;
pDevObject->Object_Name = Routed_Device_Name; pDevObject->Object_Name = Routed_Device_Name;
pDevObject->Object_Read_Property = Routed_Device_Read_Property_Local; pDevObject->Object_Read_Property = Routed_Device_Read_Property_Local;
pDevObject->Object_Write_Property = Routed_Device_Write_Property_Local; pDevObject->Object_Write_Property = Routed_Device_Write_Property_Local;
} }
#endif /* BAC_ROUTING */ #endif /* BAC_ROUTING */
#ifdef TEST #ifdef TEST
+130 -139
View File
@@ -114,32 +114,30 @@ uint16_t iCurrent_Device_Idx = 0;
* @return The index of this instance in the Devices[] array, * @return The index of this instance in the Devices[] array,
* or -1 if there isn't enough room to add this Device. * or -1 if there isn't enough room to add this Device.
*/ */
uint16_t Add_Routed_Device( uint16_t Add_Routed_Device(
uint32_t Object_Instance, uint32_t Object_Instance,
const char * sObject_Name, const char *sObject_Name,
const char * sDescription ) const char *sDescription)
{ {
int i = Num_Managed_Devices; int i = Num_Managed_Devices;
if ( i < MAX_NUM_DEVICES ) if (i < MAX_NUM_DEVICES) {
{ DEVICE_OBJECT_DATA *pDev = &Devices[i];
DEVICE_OBJECT_DATA *pDev = &Devices[i]; Num_Managed_Devices++;
Num_Managed_Devices++; iCurrent_Device_Idx = i;
iCurrent_Device_Idx = i; pDev->bacObj.mObject_Type = OBJECT_DEVICE;
pDev->bacObj.mObject_Type = OBJECT_DEVICE; pDev->bacObj.Object_Instance_Number = Object_Instance;
pDev->bacObj.Object_Instance_Number = Object_Instance; if (sObject_Name != NULL)
if ( sObject_Name != NULL ) Routed_Device_Set_Object_Name(sObject_Name, strlen(sObject_Name));
Routed_Device_Set_Object_Name( sObject_Name, strlen( sObject_Name )); else
else Routed_Device_Set_Object_Name("No Name", strlen("No Name"));
Routed_Device_Set_Object_Name( "No Name", strlen( "No Name" )); if (sDescription != NULL)
if ( sDescription != NULL ) Routed_Device_Set_Description(sDescription, strlen(sDescription));
Routed_Device_Set_Description( sDescription, strlen( sDescription )); else
else Routed_Device_Set_Description("No Descr", strlen("No Descr"));
Routed_Device_Set_Description( "No Descr", strlen( "No Descr" )); pDev->Database_Revision = 0; /* Reset/Initialize now */
pDev->Database_Revision = 0; /* Reset/Initialize now */ return i;
return i; } else
} return -1;
else
return -1;
} }
@@ -152,17 +150,16 @@ uint16_t Add_Routed_Device(
* @return Pointer to the requested Device Object data, or NULL if the idx * @return Pointer to the requested Device Object data, or NULL if the idx
* is for an invalid row entry (eg, after the last good Device). * is for an invalid row entry (eg, after the last good Device).
*/ */
DEVICE_OBJECT_DATA * Get_Routed_Device_Object( DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
int idx ) int idx)
{ {
if ( idx == -1 ) if (idx == -1)
return &Devices[iCurrent_Device_Idx]; return &Devices[iCurrent_Device_Idx];
else if ( (idx >= 0) && (idx < MAX_NUM_DEVICES) ) { else if ((idx >= 0) && (idx < MAX_NUM_DEVICES)) {
iCurrent_Device_Idx = idx; iCurrent_Device_Idx = idx;
return &Devices[idx]; return &Devices[idx];
} } else
else return NULL;
return NULL;
} }
/** Return the BACnet address for the indicated entry. /** Return the BACnet address for the indicated entry.
@@ -174,17 +171,16 @@ DEVICE_OBJECT_DATA * Get_Routed_Device_Object(
* @return Pointer to the requested Device Object BACnet address, or NULL if the idx * @return Pointer to the requested Device Object BACnet address, or NULL if the idx
* is for an invalid row entry (eg, after the last good Device). * is for an invalid row entry (eg, after the last good Device).
*/ */
BACNET_ADDRESS * Get_Routed_Device_Address( BACNET_ADDRESS *Get_Routed_Device_Address(
int idx ) int idx)
{ {
if ( idx == -1 ) if (idx == -1)
return &Devices[iCurrent_Device_Idx].bacDevAddr; return &Devices[iCurrent_Device_Idx].bacDevAddr;
else if ( (idx >= 0) && (idx < MAX_NUM_DEVICES) ) { else if ((idx >= 0) && (idx < MAX_NUM_DEVICES)) {
iCurrent_Device_Idx = idx; iCurrent_Device_Idx = idx;
return &Devices[idx].bacDevAddr; return &Devices[idx].bacDevAddr;
} } else
else return NULL;
return NULL;
} }
@@ -198,11 +194,10 @@ BACNET_ADDRESS * Get_Routed_Device_Address(
*/ */
void routed_get_my_address( void routed_get_my_address(
BACNET_ADDRESS * my_address) BACNET_ADDRESS * my_address)
{ {
if (my_address) { if (my_address) {
memcpy(my_address, &Devices[iCurrent_Device_Idx].bacDevAddr, memcpy(my_address, &Devices[iCurrent_Device_Idx].bacDevAddr,
sizeof( BACNET_ADDRESS )); sizeof(BACNET_ADDRESS));
} }
} }
@@ -224,32 +219,32 @@ void routed_get_my_address(
* meaning MAC broadcast, so it's an automatic match). * meaning MAC broadcast, so it's an automatic match).
* Else False if no match or invalid idx is given. * Else False if no match or invalid idx is given.
*/ */
bool Routed_Device_Address_Lookup( bool Routed_Device_Address_Lookup(
int idx, int idx,
uint8_t address_len, uint8_t address_len,
uint8_t * mac_adress ) uint8_t * mac_adress)
{ {
bool result = false; bool result = false;
DEVICE_OBJECT_DATA *pDev = &Devices[idx]; DEVICE_OBJECT_DATA *pDev = &Devices[idx];
int i; int i;
if ( (idx >= 0) && (idx < MAX_NUM_DEVICES) ) { if ((idx >= 0) && (idx < MAX_NUM_DEVICES)) {
if ( address_len == 0 ) { if (address_len == 0) {
/* Automatic match */ /* Automatic match */
iCurrent_Device_Idx = idx; iCurrent_Device_Idx = idx;
result = true; result = true;
} else if ( mac_adress != NULL ) { } else if (mac_adress != NULL) {
for (i = 0; i < address_len; i++) { for (i = 0; i < address_len; i++) {
if (pDev->bacDevAddr.mac[i] != mac_adress[i]) if (pDev->bacDevAddr.mac[i] != mac_adress[i])
break; break;
} }
if ( i == address_len ) { /* Success! */ if (i == address_len) { /* Success! */
iCurrent_Device_Idx = idx; iCurrent_Device_Idx = idx;
result = true; result = true;
} }
} }
} }
return result; return result;
} }
@@ -279,63 +274,61 @@ bool Routed_Device_Address_Lookup(
* Else False if no match or invalid idx is given; the cursor will * Else False if no match or invalid idx is given; the cursor will
* be returned as -1 in these cases. * be returned as -1 in these cases.
*/ */
bool Routed_Device_GetNext( bool Routed_Device_GetNext(
BACNET_ADDRESS * dest, BACNET_ADDRESS * dest,
int * DNET_list, int *DNET_list,
int * cursor ) int *cursor)
{ {
int dnet = DNET_list[0]; /* Get the DNET of our virtual network */ int dnet = DNET_list[0]; /* Get the DNET of our virtual network */
int idx = *cursor; int idx = *cursor;
bool bSuccess = false; bool bSuccess = false;
/* First, see if the index is out of range. /* First, see if the index is out of range.
* Eg, last call to GetNext may have been the last successful one. * Eg, last call to GetNext may have been the last successful one.
*/ */
if ( (idx < 0) || (idx >= MAX_NUM_DEVICES) ) if ((idx < 0) || (idx >= MAX_NUM_DEVICES))
idx = -1; idx = -1;
/* Next, see if it's a BACnet broadcast. /* Next, see if it's a BACnet broadcast.
* For broadcasts, all Devices get a chance at it. * For broadcasts, all Devices get a chance at it.
*/ */
else if (dest->net == BACNET_BROADCAST_NETWORK) { else if (dest->net == BACNET_BROADCAST_NETWORK) {
/* Just take the entry indexed by the cursor */ /* Just take the entry indexed by the cursor */
bSuccess = Routed_Device_Address_Lookup( idx++, bSuccess = Routed_Device_Address_Lookup(idx++, dest->len, dest->adr);
dest->len, dest->adr );
} }
/* Or see if it's for the main Gateway Device, because /* Or see if it's for the main Gateway Device, because
* there's no routing info. * there's no routing info.
*/ */
else if (dest->net == 0) { else if (dest->net == 0) {
/* Handle like a normal, non-routed access of the Gateway Device. /* Handle like a normal, non-routed access of the Gateway Device.
* But first, make sure our internal access is pointing at * But first, make sure our internal access is pointing at
* that Device in our table by telling it "no routing info" : */ * that Device in our table by telling it "no routing info" : */
bSuccess = Routed_Device_Address_Lookup( 0, bSuccess = Routed_Device_Address_Lookup(0, dest->len, dest->adr);
dest->len, dest->adr ); /* Next step: no more matches: */
/* Next step: no more matches: */ idx = -1;
idx = -1;
} }
/* Or if is our virtual DNET, check /* Or if is our virtual DNET, check
* against each of our virtually routed Devices. * against each of our virtually routed Devices.
* If we get a match, have it handle the APDU. * If we get a match, have it handle the APDU.
* For broadcasts, all Devices get a chance at it. * For broadcasts, all Devices get a chance at it.
*/ */
else if (dest->net == dnet) { else if (dest->net == dnet) {
if ( idx == 0 ) /* Step over this case (starting point) */ if (idx == 0) /* Step over this case (starting point) */
idx = 1; idx = 1;
while (idx < MAX_NUM_DEVICES) { while (idx < MAX_NUM_DEVICES) {
bSuccess = Routed_Device_Address_Lookup( idx++, bSuccess =
dest->len, dest->adr ); Routed_Device_Address_Lookup(idx++, dest->len, dest->adr);
if ( bSuccess ) if (bSuccess)
break; /* We don't need to keep looking */ break; /* We don't need to keep looking */
} }
} }
if ( !bSuccess ) if (!bSuccess)
*cursor = -1; *cursor = -1;
else if ( idx == MAX_NUM_DEVICES ) /* No more to GetNext */ else if (idx == MAX_NUM_DEVICES) /* No more to GetNext */
*cursor = -1; *cursor = -1;
else else
*cursor = idx; *cursor = idx;
return bSuccess; return bSuccess;
} }
@@ -353,24 +346,24 @@ bool Routed_Device_GetNext(
* an automatic match. * an automatic match.
* Else False if not a reachable network. * Else False if not a reachable network.
*/ */
bool Routed_Device_Is_Valid_Network( bool Routed_Device_Is_Valid_Network(
uint16_t dest_net, uint16_t dest_net,
int * DNET_list ) int *DNET_list)
{ {
int dnet = DNET_list[0]; /* Get the DNET of our virtual network */ int dnet = DNET_list[0]; /* Get the DNET of our virtual network */
bool bSuccess = false; bool bSuccess = false;
/* First, see if it's a BACnet broadcast (automatic pass). */ /* First, see if it's a BACnet broadcast (automatic pass). */
if ( dest_net == BACNET_BROADCAST_NETWORK) if (dest_net == BACNET_BROADCAST_NETWORK)
bSuccess = true; bSuccess = true;
/* Or see if it's for the main Gateway Device, because /* Or see if it's for the main Gateway Device, because
* there's no routing info. * there's no routing info.
*/ */
else if (dest_net == 0) else if (dest_net == 0)
bSuccess = true; bSuccess = true;
/* Or see if matches our virtual DNET */ /* Or see if matches our virtual DNET */
else if (dest_net == dnet) else if (dest_net == dnet)
bSuccess = true; bSuccess = true;
return bSuccess; return bSuccess;
} }
@@ -396,20 +389,20 @@ uint32_t Routed_Device_Index_To_Instance(
bool Routed_Device_Valid_Object_Instance_Number( bool Routed_Device_Valid_Object_Instance_Number(
uint32_t object_id) uint32_t object_id)
{ {
bool bResult = false; bool bResult = false;
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
/* BACnet allows for a wildcard instance number */ /* BACnet allows for a wildcard instance number */
if (object_id == BACNET_MAX_INSTANCE) if (object_id == BACNET_MAX_INSTANCE)
bResult = true; bResult = true;
if ( pDev->bacObj.Object_Instance_Number == object_id ) if (pDev->bacObj.Object_Instance_Number == object_id)
bResult = true; bResult = true;
return bResult; return bResult;
} }
char *Routed_Device_Name( char *Routed_Device_Name(
uint32_t object_instance) uint32_t object_instance)
{ {
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if (object_instance == pDev->bacObj.Object_Instance_Number) { if (object_instance == pDev->bacObj.Object_Instance_Number) {
return pDev->bacObj.Object_Name; return pDev->bacObj.Object_Name;
} }
@@ -429,7 +422,7 @@ int Routed_Device_Read_Property_Local(
int apdu_len = 0; /* return value */ int apdu_len = 0; /* return value */
BACNET_CHARACTER_STRING char_string; BACNET_CHARACTER_STRING char_string;
uint8_t *apdu = NULL; uint8_t *apdu = NULL;
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if ((rpdata == NULL) || (rpdata->application_data == NULL) || if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) { (rpdata->application_data_len == 0)) {
@@ -440,7 +433,7 @@ int Routed_Device_Read_Property_Local(
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
apdu_len = apdu_len =
encode_application_object_id(&apdu[0], OBJECT_DEVICE, encode_application_object_id(&apdu[0], OBJECT_DEVICE,
pDev->bacObj.Object_Instance_Number); pDev->bacObj.Object_Instance_Number);
break; break;
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
characterstring_init_ansi(&char_string, pDev->bacObj.Object_Name); characterstring_init_ansi(&char_string, pDev->bacObj.Object_Name);
@@ -457,11 +450,11 @@ int Routed_Device_Read_Property_Local(
encode_application_unsigned(&apdu[0], pDev->Database_Revision); encode_application_unsigned(&apdu[0], pDev->Database_Revision);
break; break;
default: default:
apdu_len = Device_Read_Property_Local( rpdata); apdu_len = Device_Read_Property_Local(rpdata);
break; break;
} }
return ( apdu_len ); return (apdu_len);
} }
bool Routed_Device_Write_Property_Local( bool Routed_Device_Write_Property_Local(
@@ -489,8 +482,8 @@ bool Routed_Device_Write_Property_Local(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) && if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Routed_Device_Set_Object_Instance_Number(value.type. (Routed_Device_Set_Object_Instance_Number(value.
Object_Id.instance))) { type.Object_Id.instance))) {
/* FIXME: we could send an I-Am broadcast to let the world know */ /* FIXME: we could send an I-Am broadcast to let the world know */
} else { } else {
status = false; status = false;
@@ -504,13 +497,13 @@ bool Routed_Device_Write_Property_Local(
WPValidateString(&value, MAX_DEV_NAME_LEN, false, WPValidateString(&value, MAX_DEV_NAME_LEN, false,
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
Routed_Device_Set_Object_Name(characterstring_value(&value. Routed_Device_Set_Object_Name(characterstring_value
type.Character_String), (&value.type.Character_String),
characterstring_length(&value.type.Character_String)); characterstring_length(&value.type.Character_String));
} }
break; break;
default: default:
status = Device_Write_Property_Local( wp_data); status = Device_Write_Property_Local(wp_data);
break; break;
} }
return status; return status;
@@ -537,7 +530,7 @@ bool Routed_Device_Set_Object_Instance_Number(
if (object_id <= BACNET_MAX_INSTANCE) { if (object_id <= BACNET_MAX_INSTANCE) {
/* Make the change and update the database revision */ /* Make the change and update the database revision */
Devices[iCurrent_Device_Idx].bacObj.Object_Instance_Number = object_id; Devices[iCurrent_Device_Idx].bacObj.Object_Instance_Number = object_id;
Routed_Device_Inc_Database_Revision(); Routed_Device_Inc_Database_Revision();
} else } else
status = false; status = false;
@@ -558,7 +551,7 @@ bool Routed_Device_Set_Object_Name(
size_t length) size_t length)
{ {
bool status = false; /*return value */ bool status = false; /*return value */
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if (length < MAX_DEV_NAME_LEN) { if (length < MAX_DEV_NAME_LEN) {
/* Make the change and update the database revision */ /* Make the change and update the database revision */
@@ -576,7 +569,7 @@ bool Routed_Device_Set_Description(
size_t length) size_t length)
{ {
bool status = false; /*return value */ bool status = false; /*return value */
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
if (length < MAX_DEV_DESC_LEN) { if (length < MAX_DEV_DESC_LEN) {
memmove(pDev->Description, name, length); memmove(pDev->Description, name, length);
@@ -596,8 +589,6 @@ bool Routed_Device_Set_Description(
void Routed_Device_Inc_Database_Revision( void Routed_Device_Inc_Database_Revision(
void) void)
{ {
DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx]; DEVICE_OBJECT_DATA *pDev = &Devices[iCurrent_Device_Idx];
pDev->Database_Revision++; pDev->Database_Revision++;
} }
+8 -8
View File
@@ -469,8 +469,8 @@ int Lighting_Output_Read_Property(
object_index = object_index =
Lighting_Output_Instance_To_Index(rpdata->object_instance); Lighting_Output_Instance_To_Index(rpdata->object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Lighting_Output_Level[object_index][rpdata->array_index if (Lighting_Output_Level[object_index][rpdata->
- 1] == LIGHTING_LEVEL_NULL) array_index - 1] == LIGHTING_LEVEL_NULL)
apdu_len = encode_application_null(&apdu[0]); apdu_len = encode_application_null(&apdu[0]);
else { else {
real_value = Lighting_Output_Level[object_index] real_value = Lighting_Output_Level[object_index]
@@ -554,11 +554,11 @@ bool Lighting_Output_Write_Property(
if (status) { if (status) {
level = LIGHTING_LEVEL_NULL; level = LIGHTING_LEVEL_NULL;
object_index = object_index =
Lighting_Output_Instance_To_Index Lighting_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
status = status =
Lighting_Output_Present_Value_Relinquish Lighting_Output_Present_Value_Relinquish(wp_data->
(wp_data->object_instance, wp_data->priority); object_instance, wp_data->priority);
if (wp_data->priority == 6) { if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any algorithm and may not be used for other purposes in any
@@ -585,8 +585,8 @@ bool Lighting_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Lighting_Output_Instance_To_Index Lighting_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Lighting_Output_Out_Of_Service[object_index] = Lighting_Output_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+4 -4
View File
@@ -323,8 +323,8 @@ bool Life_Safety_Point_Write_Property(
if (status) { if (status) {
if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) { if (value.type.Enumerated <= MAX_LIFE_SAFETY_MODE) {
object_index = object_index =
Life_Safety_Point_Instance_To_Index Life_Safety_Point_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Life_Safety_Point_Mode[object_index] = Life_Safety_Point_Mode[object_index] =
value.type.Enumerated; value.type.Enumerated;
} else { } else {
@@ -340,8 +340,8 @@ bool Life_Safety_Point_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Life_Safety_Point_Instance_To_Index Life_Safety_Point_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Life_Safety_Point_Out_Of_Service[object_index] = Life_Safety_Point_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+10 -12
View File
@@ -277,8 +277,7 @@ static char *Multistate_Input_State_Text(
char *pName = NULL; /* return value */ char *pName = NULL; /* return value */
index = Multistate_Input_Instance_To_Index(object_instance); index = Multistate_Input_Instance_To_Index(object_instance);
if ((index < MAX_MULTISTATE_INPUTS) && if ((index < MAX_MULTISTATE_INPUTS) && (state_index > 0) &&
(state_index > 0) &&
(state_index <= MULTISTATE_NUMBER_OF_STATES)) { (state_index <= MULTISTATE_NUMBER_OF_STATES)) {
state_index--; state_index--;
pName = State_Text[index][state_index]; pName = State_Text[index][state_index];
@@ -298,8 +297,7 @@ bool Multistate_Input_State_Text_Set(
bool status = false; /* return value */ bool status = false; /* return value */
index = Multistate_Input_Instance_To_Index(object_instance); index = Multistate_Input_Instance_To_Index(object_instance);
if ((index < MAX_MULTISTATE_INPUTS) && if ((index < MAX_MULTISTATE_INPUTS) && (state_index > 0) &&
(state_index > 0) &&
(state_index <= MULTISTATE_NUMBER_OF_STATES)) { (state_index <= MULTISTATE_NUMBER_OF_STATES)) {
state_index--; state_index--;
status = true; status = true;
@@ -405,8 +403,8 @@ int Multistate_Input_Read_Property(
/* if no index was specified, then try to encode the entire list */ /* if no index was specified, then try to encode the entire list */
/* into one packet. */ /* into one packet. */
object_index = object_index =
Multistate_Input_Instance_To_Index Multistate_Input_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) { for (i = 1; i <= MULTISTATE_NUMBER_OF_STATES; i++) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance, Multistate_Input_State_Text(rpdata->object_instance,
@@ -427,8 +425,8 @@ int Multistate_Input_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Input_Instance_To_Index Multistate_Input_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) { if (rpdata->array_index <= MULTISTATE_NUMBER_OF_STATES) {
characterstring_init_ansi(&char_string, characterstring_init_ansi(&char_string,
Multistate_Input_State_Text(rpdata->object_instance, Multistate_Input_State_Text(rpdata->object_instance,
@@ -488,8 +486,8 @@ bool Multistate_Input_Write_Property(
if (status) { if (status) {
if (Out_Of_Service[object_index]) { if (Out_Of_Service[object_index]) {
status = status =
Multistate_Input_Present_Value_Set Multistate_Input_Present_Value_Set(wp_data->
(wp_data->object_instance, value.type.Unsigned_Int); object_instance, value.type.Unsigned_Int);
if (!status) { if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY; wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE; wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -507,8 +505,8 @@ bool Multistate_Input_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Multistate_Input_Instance_To_Index Multistate_Input_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Out_Of_Service[object_index] = value.type.Boolean; Out_Of_Service[object_index] = value.type.Boolean;
} }
break; break;
+10 -10
View File
@@ -266,8 +266,8 @@ int Multistate_Output_Read_Property(
/* into one packet. */ /* into one packet. */
else if (rpdata->array_index == BACNET_ARRAY_ALL) { else if (rpdata->array_index == BACNET_ARRAY_ALL) {
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) { for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
/* FIXME: check if we have room before adding it to APDU */ /* FIXME: check if we have room before adding it to APDU */
if (Multistate_Output_Level[object_index][i] == if (Multistate_Output_Level[object_index][i] ==
@@ -292,8 +292,8 @@ int Multistate_Output_Read_Property(
} }
} else { } else {
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(rpdata->
(rpdata->object_instance); object_instance);
if (rpdata->array_index <= BACNET_MAX_PRIORITY) { if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
if (Multistate_Output_Level[object_index] if (Multistate_Output_Level[object_index]
[rpdata->array_index - 1] == MULTISTATE_NULL) [rpdata->array_index - 1] == MULTISTATE_NULL)
@@ -375,8 +375,8 @@ bool Multistate_Output_Write_Property(
(value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) { (value.type.Unsigned_Int <= MULTISTATE_NUMBER_OF_STATES)) {
level = value.type.Unsigned_Int; level = value.type.Unsigned_Int;
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Multistate_Output_Level[object_index][priority] = Multistate_Output_Level[object_index][priority] =
(uint8_t) level; (uint8_t) level;
@@ -403,8 +403,8 @@ bool Multistate_Output_Write_Property(
if (status) { if (status) {
level = MULTISTATE_NULL; level = MULTISTATE_NULL;
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
@@ -430,8 +430,8 @@ bool Multistate_Output_Write_Property(
&wp_data->error_class, &wp_data->error_code); &wp_data->error_class, &wp_data->error_code);
if (status) { if (status) {
object_index = object_index =
Multistate_Output_Instance_To_Index Multistate_Output_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
Multistate_Output_Out_Of_Service[object_index] = Multistate_Output_Out_Of_Service[object_index] =
value.type.Boolean; value.type.Boolean;
} }
+7 -7
View File
@@ -735,9 +735,9 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) { if (wp_data->application_data_len != 0) {
iOffset += len; iOffset += len;
len = len =
bacapp_decode_context_data(&wp_data->application_data bacapp_decode_context_data(&wp_data->
[iOffset], wp_data->application_data_len, &value, application_data[iOffset], wp_data->application_data_len,
PROP_LOG_DEVICE_OBJECT_PROPERTY); &value, PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || ((value.context_tag != 2) && if ((len == 0) || ((value.context_tag != 2) &&
(value.context_tag != 3))) { (value.context_tag != 3))) {
/* Bad decode or wrong tag */ /* Bad decode or wrong tag */
@@ -754,8 +754,8 @@ bool Trend_Log_Write_Property(
if (wp_data->application_data_len != 0) { if (wp_data->application_data_len != 0) {
iOffset += len; iOffset += len;
len = len =
bacapp_decode_context_data bacapp_decode_context_data(&wp_data->
(&wp_data->application_data[iOffset], application_data[iOffset],
wp_data->application_data_len, &value, wp_data->application_data_len, &value,
PROP_LOG_DEVICE_OBJECT_PROPERTY); PROP_LOG_DEVICE_OBJECT_PROPERTY);
if ((len == 0) || (value.context_tag != 3)) { if ((len == 0) || (value.context_tag != 3)) {
@@ -1097,8 +1097,8 @@ int rr_trend_log_encode(
pRequest->ItemCount = 0; /* Start out with nothing */ pRequest->ItemCount = 0; /* Start out with nothing */
/* Bail out now if nowt - should never happen for a Trend Log but ... */ /* Bail out now if nowt - should never happen for a Trend Log but ... */
if (LogInfo[Trend_Log_Instance_To_Index(pRequest-> if (LogInfo[Trend_Log_Instance_To_Index(pRequest->object_instance)].
object_instance)].ulRecordCount == 0) ulRecordCount == 0)
return (0); return (0);
if ((pRequest->RequestType == RR_BY_POSITION) || if ((pRequest->RequestType == RR_BY_POSITION) ||
+2 -2
View File
@@ -52,8 +52,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -55,8 +55,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -56,8 +56,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -53,8 +53,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+1 -1
View File
@@ -82,7 +82,7 @@ static object_functions_t Object_Table[] = {
#if defined(BACFILE) #if defined(BACFILE)
{FILE_OBJ_FUNCTIONS}, {FILE_OBJ_FUNCTIONS},
#endif #endif
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/** @file server/main.c Example server application using the BACnet Stack. */ /** @file server/main.c Example server application using the BACnet Stack. */
+2 -2
View File
@@ -48,8 +48,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -52,8 +52,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
static void Init_Service_Handlers( static void Init_Service_Handlers(
+2 -2
View File
@@ -52,8 +52,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -51,8 +51,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -53,8 +53,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -52,8 +52,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
+2 -2
View File
@@ -58,8 +58,8 @@
/* All included BACnet objects */ /* All included BACnet objects */
static object_functions_t Object_Table[] = { static object_functions_t Object_Table[] = {
{DEVICE_OBJ_FUNCTIONS}, {DEVICE_OBJ_FUNCTIONS},
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, {MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
}; };
/* buffer used for receive */ /* buffer used for receive */
-2
View File
@@ -91,11 +91,9 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define ANALOG_INPUT_OBJ_FUNCTIONS \ #define ANALOG_INPUT_OBJ_FUNCTIONS \
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count, \ OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count, \
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance, \ Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance, \
Analog_Input_Name, Analog_Input_Read_Property, NULL, \ Analog_Input_Name, Analog_Input_Read_Property, NULL, \
Analog_Input_Property_Lists, NULL, NULL Analog_Input_Property_Lists, NULL, NULL
#endif #endif
-2
View File
@@ -99,12 +99,10 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define ANALOG_OUTPUT_OBJ_FUNCTIONS \ #define ANALOG_OUTPUT_OBJ_FUNCTIONS \
OBJECT_ANALOG_OUTPUT, Analog_Output_Init, Analog_Output_Count, \ OBJECT_ANALOG_OUTPUT, Analog_Output_Init, Analog_Output_Count, \
Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance, \ Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance, \
Analog_Output_Name, Analog_Output_Read_Property, \ Analog_Output_Name, Analog_Output_Read_Property, \
Analog_Output_Write_Property, Analog_Output_Property_Lists, \ Analog_Output_Write_Property, Analog_Output_Property_Lists, \
NULL, NULL NULL, NULL
#endif #endif
-2
View File
@@ -75,12 +75,10 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define ANALOG_VALUE_OBJ_FUNCTIONS \ #define ANALOG_VALUE_OBJ_FUNCTIONS \
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count, \ OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count, \
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance, \ Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance, \
Analog_Value_Name, Analog_Value_Read_Property, \ Analog_Value_Name, Analog_Value_Read_Property, \
Analog_Value_Write_Property, Analog_Value_Property_Lists, NULL, \ Analog_Value_Write_Property, Analog_Value_Property_Lists, NULL, \
NULL NULL
#endif #endif
+1 -1
View File
@@ -197,7 +197,7 @@ extern "C" {
unsigned max_apdu_len, unsigned max_apdu_len,
BACNET_PROPERTY_ID property); BACNET_PROPERTY_ID property);
#ifndef BACAPP_PRINT_ENABLED #ifndef BACAPP_PRINT_ENABLED
#if PRINT_ENABLED || defined TEST #if PRINT_ENABLED || defined TEST
#define BACAPP_PRINT_ENABLED #define BACAPP_PRINT_ENABLED
#endif #endif
-2
View File
@@ -94,10 +94,8 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define FILE_OBJ_FUNCTIONS \ #define FILE_OBJ_FUNCTIONS \
OBJECT_FILE, bacfile_init, bacfile_count, bacfile_index_to_instance, \ OBJECT_FILE, bacfile_init, bacfile_count, bacfile_index_to_instance, \
bacfile_valid_instance, bacfile_name, bacfile_read_property, \ bacfile_valid_instance, bacfile_name, bacfile_read_property, \
bacfile_write_property, BACfile_Property_Lists, NULL bacfile_write_property, BACfile_Property_Lists, NULL
#endif #endif
+1 -1
View File
@@ -122,7 +122,7 @@ extern "C" {
const char *bactext_network_layer_msg_name( const char *bactext_network_layer_msg_name(
unsigned index); unsigned index);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
-2
View File
@@ -113,11 +113,9 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define BINARY_INPUT_OBJ_FUNCTIONS \ #define BINARY_INPUT_OBJ_FUNCTIONS \
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count, \ OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count, \
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance, \ Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance, \
Binary_Input_Name, Binary_Input_Read_Property, NULL, \ Binary_Input_Name, Binary_Input_Read_Property, NULL, \
Binary_Input_Property_Lists, NULL, NULL Binary_Input_Property_Lists, NULL, NULL
#endif #endif
-2
View File
@@ -108,12 +108,10 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define BINARY_OUTPUT_OBJ_FUNCTIONS \ #define BINARY_OUTPUT_OBJ_FUNCTIONS \
OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count, \ OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count, \
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance, \ Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance, \
Binary_Output_Name, Binary_Output_Read_Property, \ Binary_Output_Name, Binary_Output_Read_Property, \
Binary_Output_Write_Property, Binary_Output_Property_Lists, \ Binary_Output_Write_Property, Binary_Output_Property_Lists, \
NULL, NULL NULL, NULL
#endif #endif
-2
View File
@@ -69,12 +69,10 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define BINARY_VALUE_OBJ_FUNCTIONS \ #define BINARY_VALUE_OBJ_FUNCTIONS \
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count, \ OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count, \
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance, \ Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance, \
Binary_Value_Name, Binary_Value_Read_Property, \ Binary_Value_Name, Binary_Value_Read_Property, \
Binary_Value_Write_Property, Binary_Value_Property_Lists, NULL, \ Binary_Value_Write_Property, Binary_Value_Property_Lists, NULL, \
NULL NULL
#endif #endif
+2 -2
View File
@@ -80,8 +80,8 @@ extern "C" {
uint8_t * pdu); uint8_t * pdu);
int bvlc_encode_delete_fdt_entry( int bvlc_encode_delete_fdt_entry(
uint8_t * pdu, uint8_t * pdu,
uint32_t address, /* in network byte order */ uint32_t address, /* in network byte order */
uint16_t port); /* in network byte order */ uint16_t port); /* in network byte order */
int bvlc_encode_original_unicast_npdu( int bvlc_encode_original_unicast_npdu(
uint8_t * pdu, uint8_t * pdu,
uint8_t * npdu, uint8_t * npdu,
+5 -5
View File
@@ -185,10 +185,10 @@ extern "C" {
uint32_t device_id, uint32_t device_id,
BACNET_EVENT_NOTIFICATION_DATA * data); BACNET_EVENT_NOTIFICATION_DATA * data);
int Send_Network_Layer_Message( int Send_Network_Layer_Message(
BACNET_NETWORK_MESSAGE_TYPE network_message_type, BACNET_NETWORK_MESSAGE_TYPE network_message_type,
BACNET_ADDRESS * dst, BACNET_ADDRESS * dst,
int * iArgs ); int *iArgs);
void Send_Who_Is_Router_To_Network( void Send_Who_Is_Router_To_Network(
BACNET_ADDRESS * dst, BACNET_ADDRESS * dst,
int dnet); int dnet);
@@ -203,7 +203,7 @@ extern "C" {
const int DNET_list[]); const int DNET_list[]);
void Send_Initialize_Routing_Table_Ack( void Send_Initialize_Routing_Table_Ack(
BACNET_ADDRESS * dst, BACNET_ADDRESS * dst,
const int DNET_list[]); const int DNET_list[]);
uint8_t Send_Life_Safety_Operation_Data( uint8_t Send_Life_Safety_Operation_Data(
uint32_t device_id, uint32_t device_id,
+2 -2
View File
@@ -48,9 +48,9 @@
/* Enable the Gateway (Routing) functionality here, if desired. */ /* Enable the Gateway (Routing) functionality here, if desired. */
#if !defined(MAX_NUM_DEVICES) #if !defined(MAX_NUM_DEVICES)
#ifdef BAC_ROUTING #ifdef BAC_ROUTING
#define MAX_NUM_DEVICES 3 /* Eg, Gateway + two remote devices */ #define MAX_NUM_DEVICES 3 /* Eg, Gateway + two remote devices */
#else #else
#define MAX_NUM_DEVICES 1 /* Just the one normal BACnet Device Object */ #define MAX_NUM_DEVICES 1 /* Just the one normal BACnet Device Object */
#endif #endif
#endif #endif
+1 -1
View File
@@ -143,7 +143,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
+2 -8
View File
@@ -104,9 +104,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
@@ -119,9 +117,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.
@@ -134,6 +130,4 @@ extern "C" {
* auto-configuration, router table maintenance, and network layer congestion * auto-configuration, router table maintenance, and network layer congestion
* control. * control.
*/ */
#endif #endif
+6 -6
View File
@@ -50,12 +50,12 @@ extern "C" {
/* Nothing more here */ /* Nothing more here */
#else #else
/* If your compiler supports it, this is more compact: /* If your compiler supports it, this is more compact:
inline void debug_printf( inline void debug_printf(
const char *format, const char *format,
...) { ...) {
format = format; format = format;
} }
*/ */
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
+22 -26
View File
@@ -131,8 +131,7 @@ typedef struct object_functions {
#define MAX_DEV_DESC_LEN 64 #define MAX_DEV_DESC_LEN 64
/** Structure to define the Object Properties common to all Objects. */ /** Structure to define the Object Properties common to all Objects. */
typedef struct commonBacObj_s typedef struct commonBacObj_s {
{
/** The BACnet type of this object (ie, what class is this object from?). /** The BACnet type of this object (ie, what class is this object from?).
* This property, of type BACnetObjectType, indicates membership in a * This property, of type BACnetObjectType, indicates membership in a
@@ -160,13 +159,12 @@ typedef struct commonBacObj_s
* This may be useful for implementations which manage multiple Devices, * This may be useful for implementations which manage multiple Devices,
* eg, a Gateway. * eg, a Gateway.
*/ */
typedef struct devObj_s typedef struct devObj_s {
{
/** The BACnet Device Address for this device; ->len depends on DLL type. */ /** The BACnet Device Address for this device; ->len depends on DLL type. */
BACNET_ADDRESS bacDevAddr; BACNET_ADDRESS bacDevAddr;
/** Structure for the Object Properties common to all Objects. */ /** Structure for the Object Properties common to all Objects. */
COMMON_BAC_OBJECT bacObj; COMMON_BAC_OBJECT bacObj;
/** Device Description. */ /** Device Description. */
char Description[MAX_DEV_DESC_LEN]; char Description[MAX_DEV_DESC_LEN];
@@ -183,7 +181,7 @@ extern "C" {
void Device_Init( void Device_Init(
void); void);
void Device_Initialize_Object_Functions( void Device_Initialize_Object_Functions(
object_functions_t *object_table); object_functions_t * object_table);
bool Device_Reinitialize( bool Device_Reinitialize(
BACNET_REINITIALIZE_DEVICE_DATA * rd_data); BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
@@ -311,31 +309,31 @@ extern "C" {
* in the build (lib/Makefile). * in the build (lib/Makefile).
*/ */
void Routing_Device_Init( void Routing_Device_Init(
uint32_t first_object_instance ); uint32_t first_object_instance);
uint16_t Add_Routed_Device( uint16_t Add_Routed_Device(
uint32_t Object_Instance, uint32_t Object_Instance,
const char * Object_Name, const char *Object_Name,
const char * Description ); const char *Description);
DEVICE_OBJECT_DATA * Get_Routed_Device_Object( DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
int idx ); int idx);
BACNET_ADDRESS * Get_Routed_Device_Address( BACNET_ADDRESS *Get_Routed_Device_Address(
int idx ); int idx);
void routed_get_my_address( void routed_get_my_address(
BACNET_ADDRESS * my_address); BACNET_ADDRESS * my_address);
bool Routed_Device_Address_Lookup( bool Routed_Device_Address_Lookup(
int idx, int idx,
uint8_t address_len, uint8_t address_len,
uint8_t * mac_adress ); uint8_t * mac_adress);
bool Routed_Device_GetNext( bool Routed_Device_GetNext(
BACNET_ADDRESS * dest, BACNET_ADDRESS * dest,
int * DNET_list, int *DNET_list,
int * cursor ); int *cursor);
bool Routed_Device_Is_Valid_Network( bool Routed_Device_Is_Valid_Network(
uint16_t dest_net, uint16_t dest_net,
int * DNET_list ); int *DNET_list);
uint32_t Routed_Device_Index_To_Instance( uint32_t Routed_Device_Index_To_Instance(
unsigned index); unsigned index);
@@ -362,13 +360,11 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define DEVICE_OBJ_FUNCTIONS \ #define DEVICE_OBJ_FUNCTIONS \
OBJECT_DEVICE, NULL, Device_Count, Device_Index_To_Instance, \ OBJECT_DEVICE, NULL, Device_Count, Device_Index_To_Instance, \
Device_Valid_Object_Instance_Number, Device_Name, \ Device_Valid_Object_Instance_Number, Device_Name, \
Device_Read_Property_Local, Device_Write_Property_Local, \ Device_Read_Property_Local, Device_Write_Property_Local, \
Device_Property_Lists, DeviceGetRRInfo, NULL Device_Property_Lists, DeviceGetRRInfo, NULL
/** @defgroup ObjFrmwk Object Framework /** @defgroup ObjFrmwk Object Framework
* The modules in this section describe the BACnet-stack's framework for * The modules in this section describe the BACnet-stack's framework for
* BACnet-defined Objects (Device, Analog Input, etc). There are two submodules * BACnet-defined Objects (Device, Analog Input, etc). There are two submodules
@@ -378,11 +374,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
+2 -2
View File
@@ -213,7 +213,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
@@ -230,7 +230,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
+2 -2
View File
@@ -56,8 +56,8 @@ extern "C" {
void routing_npdu_handler( void routing_npdu_handler(
BACNET_ADDRESS * src, BACNET_ADDRESS * src,
int * DNET_list, int *DNET_list,
uint8_t * pdu, uint8_t * pdu,
uint16_t pdu_len); uint16_t pdu_len);
void handler_who_is( void handler_who_is(
-2
View File
@@ -74,12 +74,10 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define LOAD_CONTROL_OBJ_FUNCTIONS \ #define LOAD_CONTROL_OBJ_FUNCTIONS \
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count, \ OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count, \
Load_Control_Index_To_Instance, Load_Control_Valid_Instance, \ Load_Control_Index_To_Instance, Load_Control_Valid_Instance, \
Load_Control_Name, Load_Control_Read_Property, \ Load_Control_Name, Load_Control_Read_Property, \
Load_Control_Write_Property, Load_Control_Property_Lists, NULL, \ Load_Control_Write_Property, Load_Control_Property_Lists, NULL, \
NULL NULL
#endif #endif
-2
View File
@@ -68,7 +68,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define LIFE_SAFETY_POINT_OBJ_FUNCTIONS \ #define LIFE_SAFETY_POINT_OBJ_FUNCTIONS \
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init, \ OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init, \
Life_Safety_Point_Count, Life_Safety_Point_Index_To_Instance, \ Life_Safety_Point_Count, Life_Safety_Point_Index_To_Instance, \
@@ -76,5 +75,4 @@ extern "C" {
Life_Safety_Point_Read_Property, \ Life_Safety_Point_Read_Property, \
Life_Safety_Point_Write_Property, \ Life_Safety_Point_Write_Property, \
Life_Safety_Point_Property_Lists, NULL, NULL Life_Safety_Point_Property_Lists, NULL, NULL
#endif #endif
-2
View File
@@ -93,7 +93,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define MULTI_STATE_INPUT_OBJ_FUNCTIONS \ #define MULTI_STATE_INPUT_OBJ_FUNCTIONS \
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init, \ OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init, \
Multistate_Input_Count, Multistate_Input_Index_To_Instance, \ Multistate_Input_Count, Multistate_Input_Index_To_Instance, \
@@ -101,5 +100,4 @@ extern "C" {
Multistate_Input_Read_Property, \ Multistate_Input_Read_Property, \
Multistate_Input_Write_Property, \ Multistate_Input_Write_Property, \
Multistate_Input_Property_Lists, NULL, NULL Multistate_Input_Property_Lists, NULL, NULL
#endif #endif
-2
View File
@@ -69,7 +69,6 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define MULTI_STATE_OUTPUT_OBJ_FUNCTIONS \ #define MULTI_STATE_OUTPUT_OBJ_FUNCTIONS \
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init, \ OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init, \
Multistate_Output_Count, Multistate_Output_Index_To_Instance, \ Multistate_Output_Count, Multistate_Output_Index_To_Instance, \
@@ -77,5 +76,4 @@ extern "C" {
Multistate_Output_Read_Property, \ Multistate_Output_Read_Property, \
Multistate_Output_Write_Property, \ Multistate_Output_Write_Property, \
Multistate_Output_Property_Lists, NULL, NULL Multistate_Output_Property_Lists, NULL, NULL
#endif #endif
+4 -4
View File
@@ -61,11 +61,11 @@ struct router_port_t;
#define ROUTER_PORT_INFO_LEN 2 #define ROUTER_PORT_INFO_LEN 2
/** Port Info structure used by Routers for their routing table. */ /** Port Info structure used by Routers for their routing table. */
typedef struct router_port_t { typedef struct router_port_t {
uint16_t dnet; /**< The DNET number that identifies this port. */ uint16_t dnet; /**< The DNET number that identifies this port. */
uint8_t id; /**< Either 0 or some ill-defined, meaningless value. */ uint8_t id; /**< Either 0 or some ill-defined, meaningless value. */
uint8_t info[ROUTER_PORT_INFO_LEN]; /**< Info like 'modem dialing string' */ uint8_t info[ROUTER_PORT_INFO_LEN]; /**< Info like 'modem dialing string' */
uint8_t info_len; /**< Length of info[]. */ uint8_t info_len; /**< Length of info[]. */
struct router_port_t *next; /**< Point to next in linked list */ struct router_port_t *next; /**< Point to next in linked list */
} BACNET_ROUTER_PORT; } BACNET_ROUTER_PORT;
#ifdef __cplusplus #ifdef __cplusplus
+59 -63
View File
@@ -41,28 +41,28 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
struct BACnet_Read_Range_Data; struct BACnet_Read_Range_Data;
typedef struct BACnet_Read_Range_Data { typedef struct BACnet_Read_Range_Data {
BACNET_OBJECT_TYPE object_type; BACNET_OBJECT_TYPE object_type;
uint32_t object_instance; uint32_t object_instance;
BACNET_PROPERTY_ID object_property; BACNET_PROPERTY_ID object_property;
uint32_t array_index; uint32_t array_index;
uint8_t *application_data; uint8_t *application_data;
int application_data_len; int application_data_len;
BACNET_BIT_STRING ResultFlags; /**< FIRST_ITEM, LAST_ITEM, MORE_ITEMS. */ BACNET_BIT_STRING ResultFlags; /**< FIRST_ITEM, LAST_ITEM, MORE_ITEMS. */
int RequestType; /**< Index, sequence or time based request. */ int RequestType;/**< Index, sequence or time based request. */
int Overhead; /**< How much space the baggage takes in the response. */ int Overhead; /**< How much space the baggage takes in the response. */
uint32_t ItemCount; uint32_t ItemCount;
uint32_t FirstSequence; uint32_t FirstSequence;
union { /**< Pick the appropriate data type. */ union { /**< Pick the appropriate data type. */
uint32_t RefIndex; uint32_t RefIndex;
uint32_t RefSeqNum; uint32_t RefSeqNum;
BACNET_DATE_TIME RefTime; BACNET_DATE_TIME RefTime;
} Range; } Range;
int32_t Count; /**< SIGNED value as +ve vs -ve is important. */ int32_t Count; /**< SIGNED value as +ve vs -ve is important. */
BACNET_ERROR_CLASS error_class; BACNET_ERROR_CLASS error_class;
BACNET_ERROR_CODE error_code; BACNET_ERROR_CODE error_code;
} BACNET_READ_RANGE_DATA; } BACNET_READ_RANGE_DATA;
/** Defines to indicate which type of read range request it is. /** Defines to indicate which type of read range request it is.
Not really a bit map but we do it like this to allow quick Not really a bit map but we do it like this to allow quick
@@ -75,11 +75,11 @@ typedef struct BACnet_Read_Range_Data {
#define RR_ARRAY_OF_LISTS 16 /**< For info functionality indicates array of lists if set */ #define RR_ARRAY_OF_LISTS 16 /**< For info functionality indicates array of lists if set */
/** Bit String Enumerations */ /** Bit String Enumerations */
typedef enum { typedef enum {
RESULT_FLAG_FIRST_ITEM = 0, RESULT_FLAG_FIRST_ITEM = 0,
RESULT_FLAG_LAST_ITEM = 1, RESULT_FLAG_LAST_ITEM = 1,
RESULT_FLAG_MORE_ITEMS = 2 RESULT_FLAG_MORE_ITEMS = 2
} BACNET_RESULT_FLAGS; } BACNET_RESULT_FLAGS;
/** Defines for ReadRange packet overheads to allow us to determine how /** Defines for ReadRange packet overheads to allow us to determine how
* much space is left for actual payload: * much space is left for actual payload:
@@ -116,18 +116,18 @@ typedef enum {
information in it. The function is responsible for applying the request information in it. The function is responsible for applying the request
to the property in question and returning the response. */ to the property in question and returning the response. */
typedef int ( typedef int (
*rr_handler_function) ( *rr_handler_function) (
uint8_t * apdu, uint8_t * apdu,
BACNET_READ_RANGE_DATA * pRequest); BACNET_READ_RANGE_DATA * pRequest);
/** Structure to return the type of requests a given object property can /** Structure to return the type of requests a given object property can
* accept and the address of the function to handle the request */ * accept and the address of the function to handle the request */
typedef struct rrpropertyinfo { typedef struct rrpropertyinfo {
int RequestTypes; int RequestTypes;
rr_handler_function Handler; rr_handler_function Handler;
} RR_PROP_INFO; } RR_PROP_INFO;
/** Function template for ReadRange information retrieval function. /** Function template for ReadRange information retrieval function.
* A function template; @see device.c for assignment to object types. * A function template; @see device.c for assignment to object types.
@@ -136,46 +136,43 @@ typedef struct rrpropertyinfo {
* @param pInfo [out] Where to write the response to. * @param pInfo [out] Where to write the response to.
* @return True on success, False on error or failure. * @return True on success, False on error or failure.
*/ */
typedef bool( typedef bool(
*rr_info_function) ( *rr_info_function) (
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */ BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
RR_PROP_INFO * pInfo); /* Where to write the response to */ RR_PROP_INFO * pInfo); /* Where to write the response to */
int rr_encode_apdu( int rr_encode_apdu(
uint8_t * apdu, uint8_t * apdu,
uint8_t invoke_id, uint8_t invoke_id,
BACNET_READ_RANGE_DATA * rrdata); BACNET_READ_RANGE_DATA * rrdata);
int rr_decode_service_request( int rr_decode_service_request(
uint8_t * apdu, uint8_t * apdu,
unsigned apdu_len, unsigned apdu_len,
BACNET_READ_RANGE_DATA * rrdata); BACNET_READ_RANGE_DATA * rrdata);
int rr_ack_encode_apdu( int rr_ack_encode_apdu(
uint8_t * apdu, uint8_t * apdu,
uint8_t invoke_id, uint8_t invoke_id,
BACNET_READ_RANGE_DATA * rrdata); BACNET_READ_RANGE_DATA * rrdata);
int rr_ack_decode_service_request( int rr_ack_decode_service_request(
uint8_t * apdu, uint8_t * apdu,
int apdu_len, /* total length of the apdu */ int apdu_len, /* total length of the apdu */
BACNET_READ_RANGE_DATA * rrdata); BACNET_READ_RANGE_DATA * rrdata);
uint8_t Send_ReadRange_Request( uint8_t Send_ReadRange_Request(
uint32_t device_id, /* destination device */ uint32_t device_id, /* destination device */
BACNET_READ_RANGE_DATA * read_access_data); BACNET_READ_RANGE_DATA * read_access_data);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
/** @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>
* The ReadRange service is used by a client BACnet-user to read a specific * The ReadRange service is used by a client BACnet-user to read a specific
@@ -183,5 +180,4 @@ uint8_t Send_ReadRange_Request(
* specified object property. * specified object property.
* The service may be used with any list or array of lists property. * The service may be used with any list or array of lists property.
*/ */
#endif #endif
+1 -1
View File
@@ -135,7 +135,7 @@ extern "C" {
* 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>
* The ReadProperty service is used by a client BACnet-user to request the * The ReadProperty service is used by a client BACnet-user to request the
-2
View File
@@ -196,12 +196,10 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#define TRENDLOG_OBJ_FUNCTIONS \ #define TRENDLOG_OBJ_FUNCTIONS \
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count, \ OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count, \
Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance, \ Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance, \
Trend_Log_Name, Trend_Log_Read_Property, \ Trend_Log_Name, Trend_Log_Read_Property, \
Trend_Log_Write_Property, Trend_Log_Property_Lists, \ Trend_Log_Write_Property, Trend_Log_Property_Lists, \
TrendLogGetRRInfo, NULL TrendLogGetRRInfo, NULL
#endif #endif
+2 -2
View File
@@ -360,8 +360,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real; level = (uint8_t) value.type.Real;
object_index = object_index =
Analog_Value_Instance_To_Index Analog_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Present_Value[object_index] = level; Present_Value[object_index] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
+2 -2
View File
@@ -270,8 +270,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated; level = value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level; Present_Value[object_index] = level;
+2 -2
View File
@@ -829,8 +829,8 @@ bool Device_Write_Property_Local(
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) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+2 -3
View File
@@ -870,10 +870,9 @@ static bool MSTP_Master_Node_FSM(
(Next_Station == This_Station)) { (Next_Station == This_Station)) {
/* NextStationUnknown - added in Addendum 135-2008v-1 */ /* NextStationUnknown - added in Addendum 135-2008v-1 */
/* then the next station to which the token /* then the next station to which the token
should be sent is unknown - so PollForMaster */ should be sent is unknown - so PollForMaster */
Poll_Station = next_this_station; Poll_Station = next_this_station;
MSTP_Send_Frame( MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
This_Station, NULL, 0); This_Station, NULL, 0);
RetryCount = 0; RetryCount = 0;
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) || if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) { (value.type.Enumerated == BINARY_INACTIVE)) {
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated; (BACNET_BINARY_PV) value.type.Enumerated;
+2 -2
View File
@@ -380,8 +380,8 @@ bool Device_Write_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) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+2 -3
View File
@@ -787,10 +787,9 @@ static bool MSTP_Master_Node_FSM(
(Next_Station == This_Station)) { (Next_Station == This_Station)) {
/* NextStationUnknown - added in Addendum 135-2008v-1 */ /* NextStationUnknown - added in Addendum 135-2008v-1 */
/* then the next station to which the token /* then the next station to which the token
should be sent is unknown - so PollForMaster */ should be sent is unknown - so PollForMaster */
Poll_Station = next_this_station; Poll_Station = next_this_station;
MSTP_Send_Frame( MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
This_Station, NULL, 0); This_Station, NULL, 0);
RetryCount = 0; RetryCount = 0;
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
+2 -2
View File
@@ -211,8 +211,8 @@ bool Binary_Value_Write_Property(
if ((value.type.Enumerated == BINARY_ACTIVE) || if ((value.type.Enumerated == BINARY_ACTIVE) ||
(value.type.Enumerated == BINARY_INACTIVE)) { (value.type.Enumerated == BINARY_INACTIVE)) {
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = Present_Value[object_index] =
(BACNET_BINARY_PV) value.type.Enumerated; (BACNET_BINARY_PV) value.type.Enumerated;
+19 -19
View File
@@ -61,30 +61,30 @@ ISR(ADC_vect)
uint16_t value = 0; uint16_t value = 0;
/* determine which conversion finished */ /* determine which conversion finished */
index = BITMASK_CHECK(ADMUX,((1<<MUX2)|(1<<MUX1)|(1<<MUX0))); index = BITMASK_CHECK(ADMUX, ((1 << MUX2) | (1 << MUX1) | (1 << MUX0)));
/* read the results */ /* read the results */
value = ADCL; value = ADCL;
value |= (ADCH << 8); value |= (ADCH << 8);
Sample_Result[index] = value; Sample_Result[index] = value;
__enable_interrupt(); __enable_interrupt();
/* clear the mux */ /* clear the mux */
BITMASK_CLEAR(ADMUX, ((1<<MUX2)|(1<<MUX1)|(1<<MUX0))); BITMASK_CLEAR(ADMUX, ((1 << MUX2) | (1 << MUX1) | (1 << MUX0)));
/* find the next channel */ /* find the next channel */
while (Enabled_Channels) { while (Enabled_Channels) {
index = (index+1)%ADC_CHANNELS_MAX; index = (index + 1) % ADC_CHANNELS_MAX;
if (BIT_CHECK(Enabled_Channels, index)) { if (BIT_CHECK(Enabled_Channels, index)) {
break; break;
} }
} }
/* configure the next channel */ /* configure the next channel */
BITMASK_SET(ADMUX, ((index)<<MUX0)); BITMASK_SET(ADMUX, ((index) << MUX0));
/* Start the next conversion */ /* Start the next conversion */
BIT_SET(ADCSRA, ADSC); BIT_SET(ADCSRA, ADSC);
} }
void adc_enable( void adc_enable(
uint8_t index) /* 0..7 = ADC0..ADC7, respectively */ uint8_t index)
{ { /* 0..7 = ADC0..ADC7, respectively */
if (Enabled_Channels) { if (Enabled_Channels) {
/* ADC interupt is already started */ /* ADC interupt is already started */
BIT_SET(Enabled_Channels, index); BIT_SET(Enabled_Channels, index);
@@ -93,9 +93,9 @@ void adc_enable(
/* not running yet */ /* not running yet */
BIT_SET(Enabled_Channels, index); BIT_SET(Enabled_Channels, index);
/* clear the mux */ /* clear the mux */
BITMASK_CLEAR(ADMUX, ((1<<MUX2)|(1<<MUX1)|(1<<MUX0))); BITMASK_CLEAR(ADMUX, ((1 << MUX2) | (1 << MUX1) | (1 << MUX0)));
/* configure the channel */ /* configure the channel */
BITMASK_SET(ADMUX, ((index)<<MUX0)); BITMASK_SET(ADMUX, ((index) << MUX0));
/* Start the next conversion */ /* Start the next conversion */
BIT_SET(ADCSRA, ADSC); BIT_SET(ADCSRA, ADSC);
} }
@@ -103,8 +103,8 @@ void adc_enable(
} }
uint8_t adc_result_8bit( uint8_t adc_result_8bit(
uint8_t index) /* 0..7 = ADC0..ADC7, respectively */ uint8_t index)
{ { /* 0..7 = ADC0..ADC7, respectively */
uint8_t result = 0; uint8_t result = 0;
uint8_t sreg; uint8_t sreg;
@@ -112,7 +112,7 @@ uint8_t adc_result_8bit(
adc_enable(index); adc_enable(index);
sreg = SREG; sreg = SREG;
__disable_interrupt(); __disable_interrupt();
result = (uint8_t)(Sample_Result[index]>>2); result = (uint8_t) (Sample_Result[index] >> 2);
SREG = sreg; SREG = sreg;
} }
@@ -120,8 +120,8 @@ uint8_t adc_result_8bit(
} }
uint16_t adc_result_10bit( uint16_t adc_result_10bit(
uint8_t index) /* 0..7 = ADC0..ADC7, respectively */ uint8_t index)
{ { /* 0..7 = ADC0..ADC7, respectively */
uint16_t result = 0; uint16_t result = 0;
uint8_t sreg; uint8_t sreg;
@@ -142,7 +142,7 @@ void adc_init(
/* Initial channel selection */ /* Initial channel selection */
/* ADLAR = Left Adjust Result /* ADLAR = Left Adjust Result
REFSx = hardware setup: cap on AREF REFSx = hardware setup: cap on AREF
*/ */
ADMUX = (0 << ADLAR) | (0 << REFS1) | (1 << REFS0); ADMUX = (0 << ADLAR) | (0 << REFS1) | (1 << REFS0);
/* ADEN = Enable /* ADEN = Enable
ADSC = Start conversion ADSC = Start conversion
@@ -150,8 +150,8 @@ void adc_init(
ADIE = Interrupt Enable ADIE = Interrupt Enable
ADATE = Auto Trigger Enable ADATE = Auto Trigger Enable
*/ */
ADCSRA = (1 << ADEN) | (1 << ADIE) | ADCSRA =
(1 << ADIF) | (0 << ADATE) | ADPS_10BIT; (1 << ADEN) | (1 << ADIE) | (1 << ADIF) | (0 << ADATE) | ADPS_10BIT;
/* trigger selection bits /* trigger selection bits
0 0 0 Free Running mode 0 0 0 Free Running mode
0 0 1 Analog Comparator 0 0 1 Analog Comparator
+2 -2
View File
@@ -33,9 +33,9 @@ extern "C" {
void adc_enable( void adc_enable(
uint8_t index); /* 0..7 = ADC0..ADC7, respectively */ uint8_t index); /* 0..7 = ADC0..ADC7, respectively */
uint8_t adc_result_8bit( uint8_t adc_result_8bit(
uint8_t index); /* 0..7 = ADC0..ADC7, respectively */ uint8_t index); /* 0..7 = ADC0..ADC7, respectively */
uint16_t adc_result_10bit( uint16_t adc_result_10bit(
uint8_t index); /* 0..7 = ADC0..ADC7, respectively */ uint8_t index); /* 0..7 = ADC0..ADC7, respectively */
void adc_init( void adc_init(
void); void);
+3 -3
View File
@@ -199,7 +199,7 @@ BACNET_POLARITY Binary_Output_Polarity(
BACNET_POLARITY polarity = POLARITY_NORMAL; BACNET_POLARITY polarity = POLARITY_NORMAL;
if (instance < MAX_BINARY_OUTPUTS) { if (instance < MAX_BINARY_OUTPUTS) {
polarity = (BACNET_POLARITY)Polarity[instance]; polarity = (BACNET_POLARITY) Polarity[instance];
} }
return polarity; return polarity;
@@ -437,8 +437,8 @@ bool Binary_Output_Write_Property(
priority = wp_data->priority; priority = wp_data->priority;
if (priority && (priority <= BACNET_MAX_PRIORITY)) { if (priority && (priority <= BACNET_MAX_PRIORITY)) {
priority--; priority--;
Binary_Output_Present_Value_Set Binary_Output_Present_Value_Set(wp_data->
(wp_data->object_instance, level, priority); object_instance, level, priority);
} else if (priority == 6) { } else if (priority == 6) {
status = false; status = false;
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
+4 -4
View File
@@ -813,8 +813,8 @@ bool Device_Write_Property_Local(
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) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
@@ -874,8 +874,8 @@ bool Device_Write_Property_Local(
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH,
&small_length, 1); &small_length, 1);
pCharString = pCharString =
characterstring_value(&value. characterstring_value(&value.type.
type.Character_String); Character_String);
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0, eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
(uint8_t *) pCharString, length); (uint8_t *) pCharString, length);
status = true; status = true;
+2 -3
View File
@@ -892,10 +892,9 @@ static bool MSTP_Master_Node_FSM(
(Next_Station == This_Station)) { (Next_Station == This_Station)) {
/* NextStationUnknown - added in Addendum 135-2008v-1 */ /* NextStationUnknown - added in Addendum 135-2008v-1 */
/* then the next station to which the token /* then the next station to which the token
should be sent is unknown - so PollForMaster */ should be sent is unknown - so PollForMaster */
Poll_Station = next_this_station; Poll_Station = next_this_station;
MSTP_Send_Frame( MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
This_Station, NULL, 0); This_Station, NULL, 0);
RetryCount = 0; RetryCount = 0;
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
+1 -1
View File
@@ -98,7 +98,7 @@ void rs485_turnaround_delay(
/* delay after reception before trasmitting - per MS/TP spec */ /* delay after reception before trasmitting - per MS/TP spec */
/* Transmit 4 dummy bytes with RS485 driver off. /* Transmit 4 dummy bytes with RS485 driver off.
This equals the 40 bit times (1 start, 8 data, 1 stop). */ This equals the 40 bit times (1 start, 8 data, 1 stop). */
rs485_rts_enable(false); rs485_rts_enable(false);
while (nbytes) { while (nbytes) {
/* Send the data byte */ /* Send the data byte */
+10 -6
View File
@@ -58,7 +58,8 @@ void test_init(
* Returns: none * Returns: none
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
static inline void test_pin_on(void) static inline void test_pin_on(
void)
{ {
BIT_SET(PORTB, PB0); BIT_SET(PORTB, PB0);
} }
@@ -68,7 +69,8 @@ static inline void test_pin_on(void)
* Returns: none * Returns: none
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
static inline void test_pin_off(void) static inline void test_pin_off(
void)
{ {
BIT_CLEAR(PORTB, PB0); BIT_CLEAR(PORTB, PB0);
} }
@@ -78,7 +80,8 @@ static inline void test_pin_off(void)
* Returns: true if on, false if off. * Returns: true if on, false if off.
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
static inline bool test_pin_state(void) static inline bool test_pin_state(
void)
{ {
return (BIT_CHECK(PINB, PB0)); return (BIT_CHECK(PINB, PB0));
} }
@@ -88,7 +91,8 @@ static inline bool test_pin_state(void)
* Returns: none * Returns: none
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
static inline void test_pin_toggle(void) static inline void test_pin_toggle(
void)
{ {
if (test_pin_state()) { if (test_pin_state()) {
test_pin_off(); test_pin_off();
@@ -157,11 +161,11 @@ void test_task(
break; break;
case 'b': case 'b':
sprintf(Send_Buffer, "\r\n%lubps", sprintf(Send_Buffer, "\r\n%lubps",
(unsigned long)rs485_baud_rate()); (unsigned long) rs485_baud_rate());
break; break;
case 'm': case 'm':
sprintf(Send_Buffer, "\r\nMax:%u", sprintf(Send_Buffer, "\r\nMax:%u",
(unsigned)dlmstp_max_master()); (unsigned) dlmstp_max_master());
break; break;
default: default:
break; break;
+4 -2
View File
@@ -308,7 +308,8 @@ void timer_interval_restart(
* Returns: number of milliseconds elapsed * Returns: number of milliseconds elapsed
* Notes: only up to 255ms elapsed * Notes: only up to 255ms elapsed
**************************************************************************/ **************************************************************************/
uint8_t timer_milliseconds_delta(uint8_t start) uint8_t timer_milliseconds_delta(
uint8_t start)
{ {
return (timer_milliseconds_byte() - start); return (timer_milliseconds_byte() - start);
} }
@@ -318,7 +319,8 @@ uint8_t timer_milliseconds_delta(uint8_t start)
* Returns: mark timer starting tick * Returns: mark timer starting tick
* Notes: only up to 255ms elapsed * Notes: only up to 255ms elapsed
**************************************************************************/ **************************************************************************/
uint8_t timer_milliseconds_mark(void) uint8_t timer_milliseconds_mark(
void)
{ {
return timer_milliseconds_byte(); return timer_milliseconds_byte();
} }
+4 -2
View File
@@ -104,8 +104,10 @@ extern "C" {
struct itimer *t); struct itimer *t);
/* special for 8-bit microcontrollers - limited to 255ms */ /* special for 8-bit microcontrollers - limited to 255ms */
uint8_t timer_milliseconds_delta(uint8_t start); uint8_t timer_milliseconds_delta(
uint8_t timer_milliseconds_mark(void); uint8_t start);
uint8_t timer_milliseconds_mark(
void);
#ifdef __cplusplus #ifdef __cplusplus
} }
+3 -2
View File
@@ -66,7 +66,8 @@ ISR(TIMER2_OVF_vect);
* Returns: nothing * Returns: nothing
* Notes: none * Notes: none
*************************************************************************/ *************************************************************************/
static inline void timer_interrupt_handler(void) static inline void timer_interrupt_handler(
void)
{ {
/* Set the counter for the next interrupt */ /* Set the counter for the next interrupt */
TCNT2 = TIMER2_COUNT; TCNT2 = TIMER2_COUNT;
@@ -92,7 +93,7 @@ ISR(TIMER2_OVF_vect)
uint32_t timer_milliseconds( uint32_t timer_milliseconds(
void) void)
{ {
uint32_t timer_value; /* return value */ uint32_t timer_value; /* return value */
/* Disable the overflow interrupt. /* Disable the overflow interrupt.
Prevents value corruption that would happen if interrupted */ Prevents value corruption that would happen if interrupted */
+2 -3
View File
@@ -888,10 +888,9 @@ static bool MSTP_Master_Node_FSM(
(Next_Station == This_Station)) { (Next_Station == This_Station)) {
/* NextStationUnknown - added in Addendum 135-2008v-1 */ /* NextStationUnknown - added in Addendum 135-2008v-1 */
/* then the next station to which the token /* then the next station to which the token
should be sent is unknown - so PollForMaster */ should be sent is unknown - so PollForMaster */
Poll_Station = next_this_station; Poll_Station = next_this_station;
MSTP_Send_Frame( MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
This_Station, NULL, 0); This_Station, NULL, 0);
RetryCount = 0; RetryCount = 0;
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
+2 -2
View File
@@ -325,8 +325,8 @@ bool Analog_Value_Write_Property(
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) { (value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real; level = (uint8_t) value.type.Real;
object_index = object_index =
Analog_Value_Instance_To_Index Analog_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
Present_Value[object_index] = level; Present_Value[object_index] = level;
/* Note: you could set the physical output here if we /* Note: you could set the physical output here if we
+2 -2
View File
@@ -237,8 +237,8 @@ bool Binary_Value_Write_Property(
(value.type.Enumerated <= MAX_BINARY_PV)) { (value.type.Enumerated <= MAX_BINARY_PV)) {
level = value.type.Enumerated; level = value.type.Enumerated;
object_index = object_index =
Binary_Value_Instance_To_Index Binary_Value_Instance_To_Index(wp_data->
(wp_data->object_instance); object_instance);
priority--; priority--;
/* NOTE: this Binary value has no priority array */ /* NOTE: this Binary value has no priority array */
Present_Value[object_index] = level; Present_Value[object_index] = level;
+2 -2
View File
@@ -510,8 +510,8 @@ bool Device_Write_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) &&
(Device_Set_Object_Instance_Number(value.type. (Device_Set_Object_Instance_Number(value.type.Object_Id.
Object_Id.instance))) { instance))) {
/* we could send an I-Am broadcast to let the world know */ /* we could send an I-Am broadcast to let the world know */
status = true; status = true;
} else { } else {
+2 -3
View File
@@ -803,10 +803,9 @@ bool MSTP_Master_Node_FSM(
(Next_Station == This_Station)) { (Next_Station == This_Station)) {
/* NextStationUnknown - added in Addendum 135-2008v-1 */ /* NextStationUnknown - added in Addendum 135-2008v-1 */
/* then the next station to which the token /* then the next station to which the token
should be sent is unknown - so PollForMaster */ should be sent is unknown - so PollForMaster */
Poll_Station = next_this_station; Poll_Station = next_this_station;
MSTP_Send_Frame( MSTP_Send_Frame(FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
FRAME_TYPE_POLL_FOR_MASTER, Poll_Station,
This_Station, NULL, 0); This_Station, NULL, 0);
RetryCount = 0; RetryCount = 0;
Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER; Master_State = MSTP_MASTER_STATE_POLL_FOR_MASTER;
+11 -20
View File
@@ -259,25 +259,16 @@ bool bip_init(
bip_set_addr(my_addr.s_addr); bip_set_addr(my_addr.s_addr);
set_broadcast_address(my_addr.s_addr); set_broadcast_address(my_addr.s_addr);
bip_set_port(htons((0xBAC0)); bip_set_port(htons((0xBAC0));
/* assumes that the driver has already been initialized */
/* assumes that the driver has already been initialized */ sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP);
sock_fd = socket(AF_INET, SOCK_DGRAM, IPROTO_UDP); bip_set_socket(sock_fd); if (sock_fd < 0)
bip_set_socket(sock_fd);
if (sock_fd < 0)
return false; return false;
/* bind the socket to the local port number and IP address */
sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = bip_get_port(); memset(&(sin.sin_zero), '\0', 8);
rv =
bind(sock_fd, (const struct sockaddr *) &sin, sizeof(struct sockaddr));
if (rv < 0) {
close(sock_fd); bip_set_socket(-1); return false;}
/* bind the socket to the local port number and IP address */ return true;}
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = bip_get_port();
memset(&(sin.sin_zero), '\0', 8);
rv = bind(sock_fd, (const struct sockaddr *) &sin,
sizeof(struct sockaddr));
if (rv < 0) {
close(sock_fd);
bip_set_socket(-1);
return false;
}
return true;
}
+1 -1
View File
@@ -942,7 +942,7 @@ bool MSTP_Master_Node_FSM(
(mstp_port->Next_Station == mstp_port->This_Station)) { (mstp_port->Next_Station == mstp_port->This_Station)) {
/* NextStationUnknown - added in Addendum 135-2008v-1 */ /* NextStationUnknown - added in Addendum 135-2008v-1 */
/* then the next station to which the token /* then the next station to which the token
should be sent is unknown - so PollForMaster */ should be sent is unknown - so PollForMaster */
mstp_port->Poll_Station = next_this_station; mstp_port->Poll_Station = next_this_station;
MSTP_Create_And_Send_Frame(mstp_port, MSTP_Create_And_Send_Frame(mstp_port,
FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station, FRAME_TYPE_POLL_FOR_MASTER, mstp_port->Poll_Station,
+2 -4
View File
@@ -149,8 +149,7 @@ static struct Address_Cache_Entry *address_remove_oldest(
pMatch = Address_Cache; pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch-> if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) { BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
ulTime = pMatch->TimeToLive; ulTime = pMatch->TimeToLive;
@@ -169,8 +168,7 @@ static struct Address_Cache_Entry *address_remove_oldest(
/* Second pass - try in use and un bound as last resort */ /* Second pass - try in use and un bound as last resort */
pMatch = Address_Cache; pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch-> if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) == BAC_ADDR_STATIC)) ==
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) { ((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */ if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
+18 -17
View File
@@ -288,8 +288,9 @@ int bacapp_decode_application_data(
if (tag_len) { if (tag_len) {
len += tag_len; len += tag_len;
value->tag = tag_number; value->tag = tag_number;
decode_len = bacapp_decode_data(&apdu[len], tag_number, decode_len =
len_value_type, value); bacapp_decode_data(&apdu[len], tag_number, len_value_type,
value);
if (value->tag != MAX_BACNET_APPLICATION_TAG) { if (value->tag != MAX_BACNET_APPLICATION_TAG) {
len += decode_len; len += decode_len;
} else { } else {
@@ -394,7 +395,7 @@ int bacapp_decode_data_len(
case BACNET_APPLICATION_TAG_DATE: case BACNET_APPLICATION_TAG_DATE:
case BACNET_APPLICATION_TAG_TIME: case BACNET_APPLICATION_TAG_TIME:
case BACNET_APPLICATION_TAG_OBJECT_ID: case BACNET_APPLICATION_TAG_OBJECT_ID:
len = (int)len_value_type; len = (int) len_value_type;
break; break;
default: default:
break; break;
@@ -422,8 +423,8 @@ int bacapp_decode_application_data_len(
&len_value_type); &len_value_type);
if (tag_len) { if (tag_len) {
len += tag_len; len += tag_len;
decode_len = bacapp_decode_data_len(&apdu[len], tag_number, decode_len =
len_value_type); bacapp_decode_data_len(&apdu[len], tag_number, len_value_type);
len += decode_len; len += decode_len;
} }
} }
@@ -996,8 +997,8 @@ bool bacapp_print_value(
case PROP_OBJECT_TYPE: case PROP_OBJECT_TYPE:
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) { if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_object_type_name(value->type. bactext_object_type_name(value->
Enumerated)); type.Enumerated));
} else if (value->type.Enumerated < 128) { } else if (value->type.Enumerated < 128) {
fprintf(stream, "reserved %lu", fprintf(stream, "reserved %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
@@ -1013,8 +1014,8 @@ bool bacapp_print_value(
case PROP_UNITS: case PROP_UNITS:
if (value->type.Enumerated < 256) { if (value->type.Enumerated < 256) {
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_engineering_unit_name(value-> bactext_engineering_unit_name(value->type.
type.Enumerated)); Enumerated));
} else { } else {
fprintf(stream, "proprietary %lu", fprintf(stream, "proprietary %lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
@@ -1022,14 +1023,14 @@ bool bacapp_print_value(
break; break;
case PROP_POLARITY: case PROP_POLARITY:
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_binary_polarity_name(value-> bactext_binary_polarity_name(value->type.
type.Enumerated)); Enumerated));
break; break;
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) { if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_binary_present_value_name(value->type. bactext_binary_present_value_name(value->
Enumerated)); type.Enumerated));
} else { } else {
fprintf(stream, "%lu", fprintf(stream, "%lu",
(unsigned long) value->type.Enumerated); (unsigned long) value->type.Enumerated);
@@ -1041,8 +1042,8 @@ bool bacapp_print_value(
break; break;
case PROP_SYSTEM_STATUS: case PROP_SYSTEM_STATUS:
fprintf(stream, "%s", fprintf(stream, "%s",
bactext_device_status_name(value-> bactext_device_status_name(value->type.
type.Enumerated)); Enumerated));
break; break;
case PROP_SEGMENTATION_SUPPORTED: case PROP_SEGMENTATION_SUPPORTED:
fprintf(stream, "%s", fprintf(stream, "%s",
@@ -1413,8 +1414,8 @@ void testBACnetApplicationData_Safe(
break; break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING: case BACNET_APPLICATION_TAG_CHARACTER_STRING:
characterstring_init_ansi(&input_value[i].type. characterstring_init_ansi(&input_value[i].
Character_String, "Hello There!"); type.Character_String, "Hello There!");
break; break;
case BACNET_APPLICATION_TAG_BIT_STRING: case BACNET_APPLICATION_TAG_BIT_STRING:
+1 -1
View File
@@ -468,7 +468,7 @@ X'20' - X'7E'.*/
bool characterstring_printable( bool characterstring_printable(
BACNET_CHARACTER_STRING * char_string) BACNET_CHARACTER_STRING * char_string)
{ {
bool status = false; /* return value */ bool status = false; /* return value */
size_t i; /* counter */ size_t i; /* counter */
if (char_string) { if (char_string) {

Some files were not shown because too many files have changed in this diff Show More