Indented using indent script.
This commit is contained in:
@@ -74,16 +74,16 @@
|
|||||||
* @ingroup BACEPICS
|
* @ingroup BACEPICS
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/** Initial state to establish a binding with the target device. */
|
/** Initial state to establish a binding with the target device. */
|
||||||
INITIAL_BINDING,
|
INITIAL_BINDING,
|
||||||
/** Getting ALL properties and values at once with RPM. */
|
/** Getting ALL properties and values at once with RPM. */
|
||||||
GET_ALL_REQUEST, GET_ALL_RESPONSE,
|
GET_ALL_REQUEST, GET_ALL_RESPONSE,
|
||||||
/** Getting ALL properties with array index = 0, just to get the list. */
|
/** Getting ALL properties with array index = 0, just to get the list. */
|
||||||
GET_LIST_OF_ALL_REQUEST, GET_LIST_OF_ALL_RESPONSE,
|
GET_LIST_OF_ALL_REQUEST, GET_LIST_OF_ALL_RESPONSE,
|
||||||
/** Processing the properties individually with ReadProperty. */
|
/** Processing the properties individually with ReadProperty. */
|
||||||
GET_PROPERTY_REQUEST, GET_PROPERTY_RESPONSE,
|
GET_PROPERTY_REQUEST, GET_PROPERTY_RESPONSE,
|
||||||
/** Done with this Object; move onto the next. */
|
/** Done with this Object; move onto the next. */
|
||||||
NEXT_OBJECT
|
NEXT_OBJECT
|
||||||
} EPICS_STATES;
|
} EPICS_STATES;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+540
-595
File diff suppressed because it is too large
Load Diff
@@ -132,11 +132,10 @@ void dlenv_init(
|
|||||||
if (!datalink_init(getenv("BACNET_IFACE"))) {
|
if (!datalink_init(getenv("BACNET_IFACE"))) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
pEnv = getenv("BACNET_INVOKE_ID");
|
pEnv = getenv("BACNET_INVOKE_ID");
|
||||||
if (pEnv) {
|
if (pEnv) {
|
||||||
tsm_invokeID_set((uint8_t)strtol(pEnv, NULL, 0));
|
tsm_invokeID_set((uint8_t) strtol(pEnv, NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BACDL_BIP) && BBMD_ENABLED
|
#if defined(BACDL_BIP) && BBMD_ENABLED
|
||||||
pEnv = getenv("BACNET_BBMD_PORT");
|
pEnv = getenv("BACNET_BBMD_PORT");
|
||||||
if (pEnv) {
|
if (pEnv) {
|
||||||
|
|||||||
@@ -109,8 +109,9 @@ void handler_alarm_ack(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Alarm Ack Operation: Received acknowledge for object id %lu from %s for process id %lu for object %lu\n",
|
"Alarm Ack Operation: Received acknowledge for object id %lu from %s for process id %lu for object %lu\n",
|
||||||
(unsigned long)data.eventObjectIdentifier.instance, data.ackSource.value,
|
(unsigned long) data.eventObjectIdentifier.instance,
|
||||||
(unsigned long)data.ackProcessIdentifier, (unsigned long)data.eventObjectIdentifier.instance);
|
data.ackSource.value, (unsigned long) data.ackProcessIdentifier,
|
||||||
|
(unsigned long) data.eventObjectIdentifier.instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len =
|
len =
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void handler_atomic_read_file_ack(
|
|||||||
pFile) != 1) {
|
pFile) != 1) {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "Failed to write to %s (%lu)!\n",
|
fprintf(stderr, "Failed to write to %s (%lu)!\n",
|
||||||
pFilename, (unsigned long)instance);
|
pFilename, (unsigned long) instance);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|||||||
@@ -344,9 +344,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;
|
||||||
@@ -422,7 +421,7 @@ void handler_cov_task(
|
|||||||
COV_Subscriptions[index].lifetime -= elapsed_seconds;
|
COV_Subscriptions[index].lifetime -= elapsed_seconds;
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
|
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
|
||||||
index, (unsigned long)COV_Subscriptions[index].lifetime);
|
index, (unsigned long) COV_Subscriptions[index].lifetime);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
COV_Subscriptions[index].lifetime = 0;
|
COV_Subscriptions[index].lifetime = 0;
|
||||||
@@ -463,8 +462,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 {
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ void handler_i_am_add(
|
|||||||
#endif
|
#endif
|
||||||
if (len != -1) {
|
if (len != -1) {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, " from %lu, MAC = %d.%d.%d.%d.%d.%d\n", (unsigned long)device_id,
|
fprintf(stderr, " from %lu, MAC = %d.%d.%d.%d.%d.%d\n",
|
||||||
src->mac[0], src->mac[1], src->mac[2], src->mac[3], src->mac[4],
|
(unsigned long) device_id, src->mac[0], src->mac[1], src->mac[2],
|
||||||
src->mac[5]);
|
src->mac[3], src->mac[4], src->mac[5]);
|
||||||
#endif
|
#endif
|
||||||
address_add(device_id, max_apdu, src);
|
address_add(device_id, max_apdu, src);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ void handler_i_have(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "I-Have: %s %lu from %s %lu!\r\n",
|
fprintf(stderr, "I-Have: %s %lu from %s %lu!\r\n",
|
||||||
bactext_object_type_name(data.object_id.type),
|
bactext_object_type_name(data.object_id.type),
|
||||||
(unsigned long)data.object_id.instance,
|
(unsigned long) data.object_id.instance,
|
||||||
bactext_object_type_name(data.device_id.type),
|
bactext_object_type_name(data.device_id.type),
|
||||||
(unsigned long)data.device_id.instance);
|
(unsigned long) data.device_id.instance);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ void handler_lso(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Life Safety Operation: Received operation %d from process id %lu for object %lu\n",
|
"Life Safety Operation: Received operation %d from process id %lu for object %lu\n",
|
||||||
data.operation, (unsigned long)data.processId, (unsigned long)data.targetObject.instance);
|
data.operation, (unsigned long) data.processId,
|
||||||
|
(unsigned long) data.targetObject.instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len =
|
len =
|
||||||
|
|||||||
@@ -64,14 +64,14 @@ void npdu_handler(
|
|||||||
(uint16_t) (pdu_len - apdu_offset));
|
(uint16_t) (pdu_len - apdu_offset));
|
||||||
} else {
|
} else {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
printf("NPDU: DNET=%u. Discarded!\n", (unsigned)dest.net);
|
printf("NPDU: DNET=%u. Discarded!\n", (unsigned) dest.net);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
printf("NPDU: BACnet Protocol Version=%u. Discarded!\n",
|
printf("NPDU: BACnet Protocol Version=%u. Discarded!\n",
|
||||||
(unsigned)pdu[0]);
|
(unsigned) pdu[0]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,44 +86,45 @@ void ProcessPT(
|
|||||||
if (cBlockNumber < MY_MAX_BLOCK) {
|
if (cBlockNumber < MY_MAX_BLOCK) {
|
||||||
if (data->serviceNumber == MY_SVC_READ) {
|
if (data->serviceNumber == MY_SVC_READ) {
|
||||||
/* Read Response is an unsigned int with
|
/* Read Response is an unsigned int with
|
||||||
0 for success or a non 0 error code
|
0 for success or a non 0 error code
|
||||||
For a successful read the 0 success
|
For a successful read the 0 success
|
||||||
code is followed by the block number
|
code is followed by the block number
|
||||||
and then the block contents which
|
and then the block contents which
|
||||||
consist of 2 unsigned ints (in 0 to 255
|
consist of 2 unsigned ints (in 0 to 255
|
||||||
range as they are really chars) a single
|
range as they are really chars) a single
|
||||||
precision real and a string which
|
precision real and a string which
|
||||||
will be up to 32 chars + a nul */
|
will be up to 32 chars + a nul */
|
||||||
|
|
||||||
iLen = 0;
|
iLen = 0;
|
||||||
|
|
||||||
/* Signal success */
|
/* Signal success */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK);
|
iLen += encode_application_unsigned(&IOBufferPT[iLen], MY_ERR_OK);
|
||||||
/* Followed by the block number */
|
/* Followed by the block number */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen],
|
iLen +=
|
||||||
cBlockNumber);
|
encode_application_unsigned(&IOBufferPT[iLen], cBlockNumber);
|
||||||
/* And Then the block contents */
|
/* And Then the block contents */
|
||||||
iLen += encode_application_unsigned(&IOBufferPT[iLen],
|
|
||||||
MyData[(int8_t)cBlockNumber].cMyByte1);
|
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_unsigned(&IOBufferPT[iLen],
|
encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
MyData[(int8_t)cBlockNumber].cMyByte2);
|
MyData[(int8_t) cBlockNumber].cMyByte1);
|
||||||
|
iLen +=
|
||||||
|
encode_application_unsigned(&IOBufferPT[iLen],
|
||||||
|
MyData[(int8_t) cBlockNumber].cMyByte2);
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_real(&IOBufferPT[iLen],
|
encode_application_real(&IOBufferPT[iLen],
|
||||||
MyData[(int8_t)cBlockNumber].fMyReal);
|
MyData[(int8_t) cBlockNumber].fMyReal);
|
||||||
characterstring_init_ansi(&bsTemp,
|
characterstring_init_ansi(&bsTemp,
|
||||||
(char *)MyData[(int8_t)cBlockNumber].sMyString);
|
(char *) MyData[(int8_t) cBlockNumber].sMyString);
|
||||||
iLen +=
|
iLen +=
|
||||||
encode_application_character_string(&IOBufferPT[iLen],
|
encode_application_character_string(&IOBufferPT[iLen],
|
||||||
&bsTemp);
|
&bsTemp);
|
||||||
} else {
|
} else {
|
||||||
/* Write operation */
|
/* Write operation */
|
||||||
/* Write block consists of the block number
|
/* Write block consists of the block number
|
||||||
followed by the block contents as
|
followed by the block contents as
|
||||||
described above for the read operation.
|
described above for the read operation.
|
||||||
The returned result is an unsigned
|
The returned result is an unsigned
|
||||||
response which is 0 for success and
|
response which is 0 for success and
|
||||||
a non 0 error code otherwise. */
|
a non 0 error code otherwise. */
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -136,7 +137,7 @@ void ProcessPT(
|
|||||||
iLen +=
|
iLen +=
|
||||||
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
||||||
&ulTemp);
|
&ulTemp);
|
||||||
MyData[(int8_t)cBlockNumber].cMyByte1 = (char) ulTemp;
|
MyData[(int8_t) cBlockNumber].cMyByte1 = (char) ulTemp;
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -149,7 +150,7 @@ void ProcessPT(
|
|||||||
iLen +=
|
iLen +=
|
||||||
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
decode_unsigned(&data->serviceParameters[iLen], len_value_type,
|
||||||
&ulTemp);
|
&ulTemp);
|
||||||
MyData[(int8_t)cBlockNumber].cMyByte2 = (char) ulTemp;
|
MyData[(int8_t) cBlockNumber].cMyByte2 = (char) ulTemp;
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -161,7 +162,7 @@ void ProcessPT(
|
|||||||
}
|
}
|
||||||
iLen +=
|
iLen +=
|
||||||
decode_real(&data->serviceParameters[iLen],
|
decode_real(&data->serviceParameters[iLen],
|
||||||
&MyData[(int8_t)cBlockNumber].fMyReal);
|
&MyData[(int8_t) cBlockNumber].fMyReal);
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
decode_tag_number_and_value(&data->serviceParameters[iLen],
|
||||||
@@ -174,10 +175,10 @@ void ProcessPT(
|
|||||||
decode_character_string(&data->serviceParameters[iLen],
|
decode_character_string(&data->serviceParameters[iLen],
|
||||||
len_value_type, &bsTemp);
|
len_value_type, &bsTemp);
|
||||||
/* Only copy as much as we can accept */
|
/* Only copy as much as we can accept */
|
||||||
strncpy((char *)MyData[(int8_t)cBlockNumber].sMyString,
|
strncpy((char *) MyData[(int8_t) cBlockNumber].sMyString,
|
||||||
characterstring_value(&bsTemp), MY_MAX_STR);
|
characterstring_value(&bsTemp), MY_MAX_STR);
|
||||||
/* Make sure it is nul terminated */
|
/* Make sure it is nul terminated */
|
||||||
MyData[(int8_t)cBlockNumber].sMyString[MY_MAX_STR] = '\0';
|
MyData[(int8_t) cBlockNumber].sMyString[MY_MAX_STR] = '\0';
|
||||||
/* Signal success */
|
/* Signal success */
|
||||||
iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_OK);
|
iLen = encode_application_unsigned(&IOBufferPT[0], MY_ERR_OK);
|
||||||
}
|
}
|
||||||
@@ -260,11 +261,11 @@ void handler_conf_private_trans(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Simple example with service number of 0 for
|
/* Simple example with service number of 0 for
|
||||||
read block and 1 for write block
|
read block and 1 for write block
|
||||||
We also only support our own vendor ID.
|
We also only support our own vendor ID.
|
||||||
In theory we could support others
|
In theory we could support others
|
||||||
for compatability purposes but these
|
for compatability purposes but these
|
||||||
interfaces are rarely documented... */
|
interfaces are rarely documented... */
|
||||||
if ((data.vendorID == BACNET_VENDOR_ID) &&
|
if ((data.vendorID == BACNET_VENDOR_ID) &&
|
||||||
(data.serviceNumber <= MY_SVC_WRITE)) {
|
(data.serviceNumber <= MY_SVC_WRITE)) {
|
||||||
/* We only try to understand our own IDs and service numbers */
|
/* We only try to understand our own IDs and service numbers */
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ void DecodeBlock(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
||||||
strncpy((char *)Response.sMyString, characterstring_value(&bsName), MY_MAX_STR);
|
strncpy((char *) Response.sMyString, characterstring_value(&bsName),
|
||||||
|
MY_MAX_STR);
|
||||||
Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
|
Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
|
||||||
|
|
||||||
printf("Private Transfer Read Block Response\n");
|
printf("Private Transfer Read Block Response\n");
|
||||||
@@ -168,13 +169,14 @@ void ProcessPTA(
|
|||||||
cBlockNumber = (char) ulTemp;
|
cBlockNumber = (char) ulTemp;
|
||||||
DecodeBlock(cBlockNumber, &data->serviceParameters[iLen]);
|
DecodeBlock(cBlockNumber, &data->serviceParameters[iLen]);
|
||||||
} else { /* Read error */
|
} else { /* Read error */
|
||||||
printf("Private Transfer read operation returned error code: %lu\n",
|
printf
|
||||||
(unsigned long)uiErrorCode);
|
("Private Transfer read operation returned error code: %lu\n",
|
||||||
|
(unsigned long) uiErrorCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else { /* Write I/O block - should just be an OK type message */
|
} else { /* Write I/O block - should just be an OK type message */
|
||||||
printf("Private Transfer write operation returned error code: %lu\n",
|
printf("Private Transfer write operation returned error code: %lu\n",
|
||||||
(unsigned long)uiErrorCode);
|
(unsigned long) uiErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ void handler_reinitialize_device(
|
|||||||
goto RD_ABORT;
|
goto RD_ABORT;
|
||||||
}
|
}
|
||||||
/* decode the service request only */
|
/* decode the service request only */
|
||||||
len = rd_decode_service_request(service_request, service_len,
|
len =
|
||||||
&rd_data.state,
|
rd_decode_service_request(service_request, service_len, &rd_data.state,
|
||||||
&rd_data.password);
|
&rd_data.password);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
@@ -143,8 +143,7 @@ void handler_reinitialize_device(
|
|||||||
service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
service_data->invoke_id, SERVICE_CONFIRMED_REINITIALIZE_DEVICE,
|
||||||
rd_data.error_class, rd_data.error_code);
|
rd_data.error_class, rd_data.error_code);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr,
|
fprintf(stderr, "ReinitializeDevice: Sending Error.\n");
|
||||||
"ReinitializeDevice: Sending Error.\n");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,26 +113,26 @@ void handler_read_property(
|
|||||||
}
|
}
|
||||||
/* assume that there is an error */
|
/* assume that there is an error */
|
||||||
error = true;
|
error = true;
|
||||||
apdu_len = rp_ack_encode_apdu_init(
|
apdu_len =
|
||||||
&Handler_Transmit_Buffer[npdu_len],
|
rp_ack_encode_apdu_init(&Handler_Transmit_Buffer[npdu_len],
|
||||||
service_data->invoke_id,
|
service_data->invoke_id, &rpdata);
|
||||||
&rpdata);
|
|
||||||
/* configure our storage */
|
/* configure our storage */
|
||||||
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len+apdu_len];
|
rpdata.application_data = &Handler_Transmit_Buffer[npdu_len + apdu_len];
|
||||||
rpdata.application_data_len =
|
rpdata.application_data_len =
|
||||||
sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len);
|
sizeof(Handler_Transmit_Buffer) - (npdu_len + apdu_len);
|
||||||
len = Device_Read_Property(&rpdata);
|
len = Device_Read_Property(&rpdata);
|
||||||
if (len >= 0) {
|
if (len >= 0) {
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
len = rp_ack_encode_apdu_object_property_end(
|
len =
|
||||||
&Handler_Transmit_Buffer[npdu_len+apdu_len]);
|
rp_ack_encode_apdu_object_property_end(&Handler_Transmit_Buffer
|
||||||
|
[npdu_len + apdu_len]);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
if (apdu_len > service_data->max_resp) {
|
if (apdu_len > service_data->max_resp) {
|
||||||
/* too big for the sender - send an abort */
|
/* too big for the sender - send an abort */
|
||||||
apdu_len =
|
apdu_len =
|
||||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||||
service_data->invoke_id, ABORT_REASON_SEGMENTATION_NOT_SUPPORTED,
|
service_data->invoke_id,
|
||||||
true);
|
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "RP: Message too large. Sending Abort!\n");
|
fprintf(stderr, "RP: Message too large. Sending Abort!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ static void PrintReadPropertyData(
|
|||||||
if (data->array_index == BACNET_ARRAY_ALL)
|
if (data->array_index == BACNET_ARRAY_ALL)
|
||||||
fprintf(stderr, "%s #%lu %s\n",
|
fprintf(stderr, "%s #%lu %s\n",
|
||||||
bactext_object_type_name(data->object_type),
|
bactext_object_type_name(data->object_type),
|
||||||
(unsigned long)data->object_instance,
|
(unsigned long) data->object_instance,
|
||||||
bactext_property_name(data->object_property));
|
bactext_property_name(data->object_property));
|
||||||
else
|
else
|
||||||
fprintf(stderr, "%s #%lu %s[%d]\n",
|
fprintf(stderr, "%s #%lu %s[%d]\n",
|
||||||
bactext_object_type_name(data->object_type),
|
bactext_object_type_name(data->object_type),
|
||||||
(unsigned long)data->object_instance,
|
(unsigned long) data->object_instance,
|
||||||
bactext_property_name(data->object_property),
|
bactext_property_name(data->object_property),
|
||||||
data->array_index);
|
data->array_index);
|
||||||
#endif
|
#endif
|
||||||
@@ -160,23 +160,22 @@ int rp_ack_fully_decode_service_request(
|
|||||||
{
|
{
|
||||||
int decoded_len = 0; /* return value */
|
int decoded_len = 0; /* return value */
|
||||||
BACNET_READ_PROPERTY_DATA rp1data;
|
BACNET_READ_PROPERTY_DATA rp1data;
|
||||||
BACNET_PROPERTY_REFERENCE *rp1_property; /* single property */
|
BACNET_PROPERTY_REFERENCE *rp1_property; /* single property */
|
||||||
BACNET_APPLICATION_DATA_VALUE *value, *old_value;
|
BACNET_APPLICATION_DATA_VALUE *value, *old_value;
|
||||||
uint8_t * vdata;
|
uint8_t *vdata;
|
||||||
int vlen, len;
|
int vlen, len;
|
||||||
|
|
||||||
decoded_len = rp_ack_decode_service_request(apdu, apdu_len, &rp1data);
|
decoded_len = rp_ack_decode_service_request(apdu, apdu_len, &rp1data);
|
||||||
if ( decoded_len > 0 )
|
if (decoded_len > 0) {
|
||||||
{
|
/* Then we have to transfer to the BACNET_READ_ACCESS_DATA structure
|
||||||
/* Then we have to transfer to the BACNET_READ_ACCESS_DATA structure
|
* and decode the value(s) portion
|
||||||
* and decode the value(s) portion
|
*/
|
||||||
*/
|
read_access_data->object_type = rp1data.object_type;
|
||||||
read_access_data->object_type = rp1data.object_type;
|
read_access_data->object_instance = rp1data.object_instance;
|
||||||
read_access_data->object_instance = rp1data.object_instance;
|
|
||||||
rp1_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
rp1_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
||||||
read_access_data->listOfProperties = rp1_property;
|
read_access_data->listOfProperties = rp1_property;
|
||||||
if ( rp1_property == NULL )
|
if (rp1_property == NULL)
|
||||||
return -1; /* can't proceed if calloc failed. */
|
return -1; /* can't proceed if calloc failed. */
|
||||||
rp1_property->propertyIdentifier = rp1data.object_property;
|
rp1_property->propertyIdentifier = rp1data.object_property;
|
||||||
rp1_property->propertyArrayIndex = rp1data.array_index;
|
rp1_property->propertyArrayIndex = rp1data.array_index;
|
||||||
/* Is there no Error case possible here, as there is when decoding RPM? */
|
/* Is there no Error case possible here, as there is when decoding RPM? */
|
||||||
@@ -184,7 +183,7 @@ int rp_ack_fully_decode_service_request(
|
|||||||
/* rp_ack_decode_service_request() processing already removed the
|
/* rp_ack_decode_service_request() processing already removed the
|
||||||
* Opening and Closing '3' Tags.
|
* Opening and Closing '3' Tags.
|
||||||
* note: if this is an array, there will be
|
* note: if this is an array, there will be
|
||||||
more than one element to decode */
|
more than one element to decode */
|
||||||
vdata = rp1data.application_data;
|
vdata = rp1data.application_data;
|
||||||
vlen = rp1data.application_data_len;
|
vlen = rp1data.application_data_len;
|
||||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||||
@@ -196,9 +195,7 @@ int rp_ack_fully_decode_service_request(
|
|||||||
bacapp_decode_context_data(vdata, vlen, value,
|
bacapp_decode_context_data(vdata, vlen, value,
|
||||||
rp1_property->propertyIdentifier);
|
rp1_property->propertyIdentifier);
|
||||||
} else {
|
} else {
|
||||||
len =
|
len = bacapp_decode_application_data(vdata, vlen, value);
|
||||||
bacapp_decode_application_data(vdata, vlen,
|
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
decoded_len += len;
|
decoded_len += len;
|
||||||
vlen -= len;
|
vlen -= len;
|
||||||
@@ -212,17 +209,15 @@ int rp_ack_fully_decode_service_request(
|
|||||||
} else {
|
} else {
|
||||||
/* nothing decoded and no closing tag, so malformed */
|
/* nothing decoded and no closing tag, so malformed */
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
free( value );
|
free(value);
|
||||||
free( rp1_property );
|
free(rp1_property);
|
||||||
read_access_data->listOfProperties = NULL;
|
read_access_data->listOfProperties = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ( vlen > 0 ) /* If more values */
|
if (vlen > 0) { /* If more values */
|
||||||
{
|
old_value = value;
|
||||||
old_value = value;
|
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||||
value =
|
old_value->next = value;
|
||||||
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
|
||||||
old_value->next = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ static BACNET_PROPERTY_ID RPM_Object_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (BACNET_PROPERTY_ID)property;
|
return (BACNET_PROPERTY_ID) property;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned RPM_Object_Property_Count(
|
static unsigned RPM_Object_Property_Count(
|
||||||
@@ -133,9 +133,9 @@ static int RPM_Encode_Property(
|
|||||||
rpdata.application_data_len = sizeof(Temp_Buf);
|
rpdata.application_data_len = sizeof(Temp_Buf);
|
||||||
len = Device_Read_Property(&rpdata);
|
len = Device_Read_Property(&rpdata);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
if ( len == -2 ) {
|
if (len == -2) {
|
||||||
return 0; /* Ie, Abort */
|
return 0; /* Ie, Abort */
|
||||||
}
|
}
|
||||||
/* error was returned - encode that for the response */
|
/* error was returned - encode that for the response */
|
||||||
len =
|
len =
|
||||||
rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0],
|
rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0],
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ int rpm_ack_decode_service_request(
|
|||||||
BACNET_APPLICATION_DATA_VALUE *value;
|
BACNET_APPLICATION_DATA_VALUE *value;
|
||||||
BACNET_APPLICATION_DATA_VALUE *old_value;
|
BACNET_APPLICATION_DATA_VALUE *old_value;
|
||||||
|
|
||||||
assert( read_access_data != NULL );
|
assert(read_access_data != NULL);
|
||||||
rpm_object = read_access_data;
|
rpm_object = read_access_data;
|
||||||
old_rpm_object = rpm_object;
|
old_rpm_object = rpm_object;
|
||||||
while (rpm_object && apdu_len) {
|
while (rpm_object && apdu_len) {
|
||||||
@@ -211,7 +211,7 @@ static void PrintReadPropertyMultipleData(
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stdout, "%s #%lu\r\n",
|
fprintf(stdout, "%s #%lu\r\n",
|
||||||
bactext_object_type_name(rpm_data->object_type),
|
bactext_object_type_name(rpm_data->object_type),
|
||||||
(unsigned long)rpm_data->object_instance);
|
(unsigned long) rpm_data->object_instance);
|
||||||
fprintf(stdout, "{\r\n");
|
fprintf(stdout, "{\r\n");
|
||||||
#endif
|
#endif
|
||||||
listOfProperties = rpm_data->listOfProperties;
|
listOfProperties = rpm_data->listOfProperties;
|
||||||
@@ -219,11 +219,11 @@ static void PrintReadPropertyMultipleData(
|
|||||||
#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);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (listOfProperties->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
if (listOfProperties->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||||
@@ -261,10 +261,10 @@ static void PrintReadPropertyMultipleData(
|
|||||||
#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;
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ int Encode_RR_payload(
|
|||||||
BACNET_READ_RANGE_DATA * pRequest)
|
BACNET_READ_RANGE_DATA * pRequest)
|
||||||
{
|
{
|
||||||
int apdu_len = -1;
|
int apdu_len = -1;
|
||||||
rr_info_function info_fn_ptr = NULL;
|
rr_info_function info_fn_ptr = NULL;
|
||||||
RR_PROP_INFO PropInfo;
|
RR_PROP_INFO PropInfo;
|
||||||
|
|
||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
pRequest->error_class = ERROR_CLASS_SERVICES;
|
pRequest->error_class = ERROR_CLASS_SERVICES;
|
||||||
pRequest->error_code = ERROR_CODE_OTHER;
|
pRequest->error_code = ERROR_CODE_OTHER;
|
||||||
|
|
||||||
/* handle each object type */
|
/* handle each object type */
|
||||||
info_fn_ptr = Device_Objects_RR_Info(pRequest->object_type);
|
info_fn_ptr = Device_Objects_RR_Info(pRequest->object_type);
|
||||||
@@ -62,25 +62,25 @@ int Encode_RR_payload(
|
|||||||
if ((info_fn_ptr != NULL) && (info_fn_ptr(pRequest, &PropInfo) != false)) {
|
if ((info_fn_ptr != NULL) && (info_fn_ptr(pRequest, &PropInfo) != false)) {
|
||||||
/* We try and do some of the more generic error checking here to cut down on duplication of effort */
|
/* We try and do some of the more generic error checking here to cut down on duplication of effort */
|
||||||
|
|
||||||
if((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) {/* First index is 1 so can't accept 0 */
|
if ((pRequest->RequestType == RR_BY_POSITION) && (pRequest->Range.RefIndex == 0)) { /* First index is 1 so can't accept 0 */
|
||||||
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
||||||
} else if(((PropInfo.RequestTypes & RR_ARRAY_OF_LISTS) == 0) && (pRequest->array_index != 0) && (pRequest->array_index != BACNET_ARRAY_ALL)) {
|
} else if (((PropInfo.RequestTypes & RR_ARRAY_OF_LISTS) == 0) &&
|
||||||
|
(pRequest->array_index != 0) &&
|
||||||
|
(pRequest->array_index != BACNET_ARRAY_ALL)) {
|
||||||
/* Array access attempted on a non array property */
|
/* Array access attempted on a non array property */
|
||||||
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
}
|
} else if ((pRequest->RequestType != RR_READ_ALL) &&
|
||||||
else if((pRequest->RequestType != RR_READ_ALL) && ((PropInfo.RequestTypes & pRequest->RequestType) == 0)) {
|
((PropInfo.RequestTypes & pRequest->RequestType) == 0)) {
|
||||||
/* By Time or By Sequence not supported - By Position is always required */
|
/* By Time or By Sequence not supported - By Position is always required */
|
||||||
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
||||||
}
|
} else if ((pRequest->Count == 0) && (pRequest->RequestType != RR_READ_ALL)) { /* Count cannot be zero */
|
||||||
else if((pRequest->Count == 0) && (pRequest->RequestType != RR_READ_ALL)) { /* Count cannot be zero */
|
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
||||||
pRequest->error_code = ERROR_CODE_OTHER; /* I couldn't see anything more appropriate so... */
|
} else if (PropInfo.Handler != NULL) {
|
||||||
}
|
|
||||||
else if(PropInfo.Handler != NULL) {
|
|
||||||
apdu_len = PropInfo.Handler(apdu, pRequest);
|
apdu_len = PropInfo.Handler(apdu, pRequest);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Either we don't support RR for this property yet or it is not a list or array of lists */
|
/* Either we don't support RR for this property yet or it is not a list or array of lists */
|
||||||
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
@@ -119,7 +119,7 @@ void handler_read_range(
|
|||||||
#endif
|
#endif
|
||||||
goto RR_ABORT;
|
goto RR_ABORT;
|
||||||
}
|
}
|
||||||
memset(&data, 0, sizeof(data)); /* start with blank canvas */
|
memset(&data, 0, sizeof(data)); /* start with blank canvas */
|
||||||
len = rr_decode_service_request(service_request, service_len, &data);
|
len = rr_decode_service_request(service_request, service_len, &data);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
|
|||||||
@@ -103,7 +103,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(pProperty_value->propertyIdentifier));
|
bactext_property_name(pProperty_value->
|
||||||
|
propertyIdentifier));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "proprietary %u ",
|
fprintf(stderr, "proprietary %u ",
|
||||||
pProperty_value->propertyIdentifier);
|
pProperty_value->propertyIdentifier);
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ void handler_write_property(
|
|||||||
if (len > 0)
|
if (len > 0)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n",
|
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n",
|
||||||
(unsigned long)wp_data.object_type, (unsigned long)wp_data.object_instance,
|
(unsigned long) wp_data.object_type,
|
||||||
(unsigned long)wp_data.object_property, (unsigned long)wp_data.priority, (long)wp_data.array_index);
|
(unsigned long) wp_data.object_instance,
|
||||||
|
(unsigned long) wp_data.object_property,
|
||||||
|
(unsigned long) wp_data.priority, (long) wp_data.array_index);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "WP: Unable to decode Request!\n");
|
fprintf(stderr, "WP: Unable to decode Request!\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -149,13 +151,13 @@ void handler_write_property(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool WPValidateString(
|
bool WPValidateString(
|
||||||
BACNET_APPLICATION_DATA_VALUE *pValue,
|
BACNET_APPLICATION_DATA_VALUE * pValue,
|
||||||
int iMaxLen,
|
int iMaxLen,
|
||||||
bool bEmptyAllowed,
|
bool bEmptyAllowed,
|
||||||
BACNET_ERROR_CLASS * pErrorClass,
|
BACNET_ERROR_CLASS * pErrorClass,
|
||||||
BACNET_ERROR_CODE * pErrorCode)
|
BACNET_ERROR_CODE * pErrorCode)
|
||||||
{
|
{
|
||||||
bool bResult;
|
bool bResult;
|
||||||
|
|
||||||
/* Save on a bit of code duplication by pre selecting the most
|
/* Save on a bit of code duplication by pre selecting the most
|
||||||
* common outcomes from the tests (not necessarily the most likely
|
* common outcomes from the tests (not necessarily the most likely
|
||||||
@@ -164,21 +166,25 @@ bool WPValidateString(
|
|||||||
bResult = false;
|
bResult = false;
|
||||||
*pErrorClass = ERROR_CLASS_PROPERTY;
|
*pErrorClass = ERROR_CLASS_PROPERTY;
|
||||||
|
|
||||||
if(pValue->tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
if (pValue->tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||||
if(characterstring_encoding(&pValue->type.Character_String) == CHARACTER_ANSI_X34) {
|
if (characterstring_encoding(&pValue->type.Character_String) ==
|
||||||
if((bEmptyAllowed == false) && (characterstring_length(&pValue->type.Character_String) == 0)) {
|
CHARACTER_ANSI_X34) {
|
||||||
|
if ((bEmptyAllowed == false) &&
|
||||||
|
(characterstring_length(&pValue->type.Character_String) ==
|
||||||
|
0)) {
|
||||||
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
*pErrorCode = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
} else if(characterstring_length(&pValue->type.Character_String) >= iMaxLen) {
|
} else if (characterstring_length(&pValue->type.
|
||||||
|
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
|
||||||
bResult = true; /* It's all good! */
|
bResult = true; /* It's all good! */
|
||||||
} else
|
} else
|
||||||
*pErrorCode = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
*pErrorCode = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
||||||
} else
|
} else
|
||||||
*pErrorCode = ERROR_CODE_INVALID_DATA_TYPE;
|
*pErrorCode = ERROR_CODE_INVALID_DATA_TYPE;
|
||||||
|
|
||||||
return(bResult);
|
return (bResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Perform simple validation of type of Write Property argument based
|
/** Perform simple validation of type of Write Property argument based
|
||||||
@@ -187,23 +193,23 @@ bool WPValidateString(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool WPValidateArgType(
|
bool WPValidateArgType(
|
||||||
BACNET_APPLICATION_DATA_VALUE *pValue,
|
BACNET_APPLICATION_DATA_VALUE * pValue,
|
||||||
uint8_t ucExpectedTag,
|
uint8_t ucExpectedTag,
|
||||||
BACNET_ERROR_CLASS * pErrorClass,
|
BACNET_ERROR_CLASS * pErrorClass,
|
||||||
BACNET_ERROR_CODE * pErrorCode)
|
BACNET_ERROR_CODE * pErrorCode)
|
||||||
{
|
{
|
||||||
bool bResult;
|
bool bResult;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* start out assuming success and only set up error
|
* start out assuming success and only set up error
|
||||||
* response if validation fails.
|
* response if validation fails.
|
||||||
*/
|
*/
|
||||||
bResult = true;
|
bResult = true;
|
||||||
if(pValue->tag != ucExpectedTag) {
|
if (pValue->tag != ucExpectedTag) {
|
||||||
bResult = false;
|
bResult = false;
|
||||||
*pErrorClass = ERROR_CLASS_PROPERTY;
|
*pErrorClass = ERROR_CLASS_PROPERTY;
|
||||||
*pErrorCode = ERROR_CODE_INVALID_DATA_TYPE;
|
*pErrorCode = ERROR_CODE_INVALID_DATA_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(bResult);
|
return (bResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ OBJECT_DEVICE_T *objects_device_new(
|
|||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Objects: Unable to allocate device %lu buffer\n",
|
"Objects: Unable to allocate device %lu buffer\n",
|
||||||
(unsigned long)device_instance);
|
(unsigned long) device_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ OBJECT_DEVICE_T *objects_device_delete(
|
|||||||
pDevice = Keylist_Data_Delete_By_Index(Device_List, index);
|
pDevice = Keylist_Data_Delete_By_Index(Device_List, index);
|
||||||
if (pDevice) {
|
if (pDevice) {
|
||||||
fprintf(stderr, "Objects: removing device %lu",
|
fprintf(stderr, "Objects: removing device %lu",
|
||||||
(unsigned long)pDevice->Object_Identifier.instance);
|
(unsigned long) pDevice->Object_Identifier.instance);
|
||||||
if (pDevice->Object_List) {
|
if (pDevice->Object_List) {
|
||||||
do {
|
do {
|
||||||
pObject =
|
pObject =
|
||||||
|
|||||||
@@ -124,10 +124,9 @@ uint8_t Send_COV_Subscribe(
|
|||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
||||||
&npdu_data);
|
&npdu_data);
|
||||||
/* encode the APDU portion of the packet */
|
/* encode the APDU portion of the packet */
|
||||||
len = cov_subscribe_encode_adpu(
|
len =
|
||||||
&Handler_Transmit_Buffer[pdu_len],
|
cov_subscribe_encode_adpu(&Handler_Transmit_Buffer[pdu_len],
|
||||||
invoke_id,
|
invoke_id, cov_data);
|
||||||
cov_data);
|
|
||||||
pdu_len += len;
|
pdu_len += len;
|
||||||
/* will it fit in the sender?
|
/* will it fit in the sender?
|
||||||
note: if there is a bottleneck router in between
|
note: if there is a bottleneck router in between
|
||||||
@@ -158,4 +157,3 @@ uint8_t Send_COV_Subscribe(
|
|||||||
|
|
||||||
return invoke_id;
|
return invoke_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ int iam_encode_pdu(
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
int pdu_len = 0;
|
int pdu_len = 0;
|
||||||
|
|
||||||
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(&buffer[0], dest, NULL, npdu_data);
|
pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data);
|
||||||
@@ -75,7 +75,7 @@ int iam_encode_pdu(
|
|||||||
* @param buffer [in] The buffer to use for building and sending the message.
|
* @param buffer [in] The buffer to use for building and sending the message.
|
||||||
*/
|
*/
|
||||||
void Send_I_Am(
|
void Send_I_Am(
|
||||||
uint8_t * buffer )
|
uint8_t * buffer)
|
||||||
{
|
{
|
||||||
int pdu_len = 0;
|
int pdu_len = 0;
|
||||||
BACNET_ADDRESS dest;
|
BACNET_ADDRESS dest;
|
||||||
@@ -126,15 +126,13 @@ int iam_unicast_encode_pdu(
|
|||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
|
|
||||||
/* The destination will be the same as the src, so copy it over. */
|
/* The destination will be the same as the src, so copy it over. */
|
||||||
memcpy( dest, src, sizeof( BACNET_ADDRESS ) );
|
memcpy(dest, src, sizeof(BACNET_ADDRESS));
|
||||||
dest->net = 0;
|
dest->net = 0;
|
||||||
|
|
||||||
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);
|
||||||
npdu_len =
|
npdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data);
|
||||||
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 =
|
apdu_len =
|
||||||
iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(),
|
iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(),
|
||||||
@@ -157,7 +155,7 @@ int iam_unicast_encode_pdu(
|
|||||||
*/
|
*/
|
||||||
void Send_I_Am_Unicast(
|
void Send_I_Am_Unicast(
|
||||||
uint8_t * buffer,
|
uint8_t * buffer,
|
||||||
BACNET_ADDRESS * src )
|
BACNET_ADDRESS * src)
|
||||||
{
|
{
|
||||||
int pdu_len = 0;
|
int pdu_len = 0;
|
||||||
BACNET_ADDRESS dest;
|
BACNET_ADDRESS dest;
|
||||||
@@ -186,4 +184,3 @@ void Send_I_Am_Unicast(
|
|||||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -144,8 +144,7 @@ static void packet_statistics(
|
|||||||
if (dst > MSTP_Statistics[src].max_master) {
|
if (dst > MSTP_Statistics[src].max_master) {
|
||||||
MSTP_Statistics[src].max_master = dst;
|
MSTP_Statistics[src].max_master = dst;
|
||||||
}
|
}
|
||||||
if ((old_frame == FRAME_TYPE_POLL_FOR_MASTER) &&
|
if ((old_frame == FRAME_TYPE_POLL_FOR_MASTER) && (old_src == src)) {
|
||||||
(old_src == src)) {
|
|
||||||
/* Tusage_timeout */
|
/* Tusage_timeout */
|
||||||
delta = timeval_diff_ms(&old_tv, tv);
|
delta = timeval_diff_ms(&old_tv, tv);
|
||||||
if (delta > MSTP_Statistics[src].tusage_timeout) {
|
if (delta > MSTP_Statistics[src].tusage_timeout) {
|
||||||
@@ -212,9 +211,8 @@ static void packet_statistics_save(
|
|||||||
fprintf(stdout, "\r\n");
|
fprintf(stdout, "\r\n");
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
/* check for masters or slaves */
|
/* check for masters or slaves */
|
||||||
if ((MSTP_Statistics[i].token_count) ||
|
if ((MSTP_Statistics[i].token_count) || (MSTP_Statistics[i].der_reply)
|
||||||
(MSTP_Statistics[i].der_reply) ||
|
|| (MSTP_Statistics[i].pfm_count)) {
|
||||||
(MSTP_Statistics[i].pfm_count)) {
|
|
||||||
fprintf(stdout, "%u\t%u", i,
|
fprintf(stdout, "%u\t%u", i,
|
||||||
(unsigned) MSTP_Statistics[i].max_master);
|
(unsigned) MSTP_Statistics[i].max_master);
|
||||||
fprintf(stdout, "\t%lu\t%lu\t%lu\t%lu",
|
fprintf(stdout, "\t%lu\t%lu\t%lu\t%lu",
|
||||||
@@ -379,6 +377,7 @@ size_t data_write(
|
|||||||
}
|
}
|
||||||
return fwrite(ptr, size, nitems, pFile);
|
return fwrite(ptr, size, nitems, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t data_write_header(
|
size_t data_write_header(
|
||||||
const void *ptr,
|
const void *ptr,
|
||||||
size_t size,
|
size_t size,
|
||||||
@@ -413,7 +412,7 @@ static void filename_create(
|
|||||||
static void write_global_header(
|
static void write_global_header(
|
||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
static bool pipe_enable = true; /* don't write more than one header */
|
static bool pipe_enable = true; /* don't write more than one header */
|
||||||
uint32_t magic_number = 0xa1b2c3d4; /* magic number */
|
uint32_t magic_number = 0xa1b2c3d4; /* magic number */
|
||||||
uint16_t version_major = 2; /* major version number */
|
uint16_t version_major = 2; /* major version number */
|
||||||
uint16_t version_minor = 4; /* minor version number */
|
uint16_t version_minor = 4; /* minor version number */
|
||||||
@@ -425,9 +424,12 @@ static void write_global_header(
|
|||||||
/* create a new file. */
|
/* create a new file. */
|
||||||
pFile = fopen(filename, "wb");
|
pFile = fopen(filename, "wb");
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
(void) data_write_header(&magic_number, sizeof(magic_number), 1, pipe_enable);
|
(void) data_write_header(&magic_number, sizeof(magic_number), 1,
|
||||||
(void) data_write_header(&version_major, sizeof(version_major), 1, pipe_enable);
|
pipe_enable);
|
||||||
(void) data_write_header(&version_minor, sizeof(version_minor), 1, pipe_enable);
|
(void) data_write_header(&version_major, sizeof(version_major), 1,
|
||||||
|
pipe_enable);
|
||||||
|
(void) data_write_header(&version_minor, sizeof(version_minor), 1,
|
||||||
|
pipe_enable);
|
||||||
(void) data_write_header(&thiszone, sizeof(thiszone), 1, pipe_enable);
|
(void) data_write_header(&thiszone, sizeof(thiszone), 1, pipe_enable);
|
||||||
(void) data_write_header(&sigfigs, sizeof(sigfigs), 1, pipe_enable);
|
(void) data_write_header(&sigfigs, sizeof(sigfigs), 1, pipe_enable);
|
||||||
(void) data_write_header(&snaplen, sizeof(snaplen), 1, pipe_enable);
|
(void) data_write_header(&snaplen, sizeof(snaplen), 1, pipe_enable);
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ char *Analog_Input_Name(
|
|||||||
|
|
||||||
index = Analog_Input_Instance_To_Index(object_instance);
|
index = Analog_Input_Instance_To_Index(object_instance);
|
||||||
if (index < MAX_ANALOG_INPUTS) {
|
if (index < MAX_ANALOG_INPUTS) {
|
||||||
sprintf(text_string, "ANALOG INPUT %lu", (unsigned long)index);
|
sprintf(text_string, "ANALOG INPUT %lu", (unsigned long) index);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,15 +170,14 @@ char *Analog_Input_Name(
|
|||||||
/* return apdu length, or -1 on error */
|
/* return apdu length, or -1 on error */
|
||||||
/* assumption - object has already exists */
|
/* assumption - object has already exists */
|
||||||
int Analog_Input_Read_Property(
|
int Analog_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
BACNET_CHARACTER_STRING char_string;
|
BACNET_CHARACTER_STRING char_string;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -242,8 +241,7 @@ int Analog_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -284,8 +282,7 @@ void testAnalogInput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ char *Analog_Output_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_ANALOG_OUTPUTS) {
|
if (object_instance < MAX_ANALOG_OUTPUTS) {
|
||||||
sprintf(text_string, "ANALOG OUTPUT %lu", (unsigned long)object_instance);
|
sprintf(text_string, "ANALOG OUTPUT %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +269,7 @@ char *Analog_Output_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Analog_Output_Read_Property(
|
int Analog_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -280,8 +281,7 @@ int Analog_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -320,7 +320,8 @@ int Analog_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Analog_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Output_Out_Of_Service[object_index];
|
state = Analog_Output_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -361,12 +362,13 @@ int Analog_Output_Read_Property(
|
|||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
Analog_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Analog_Output_Level[object_index][rpdata->array_index - 1] ==
|
if (Analog_Output_Level[object_index][rpdata->array_index -
|
||||||
AO_LEVEL_NULL)
|
1] == AO_LEVEL_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Analog_Output_Level[object_index][rpdata->array_index - 1];
|
Analog_Output_Level[object_index][rpdata->
|
||||||
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -388,8 +390,7 @@ int Analog_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -435,29 +436,28 @@ bool Analog_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = AO_LEVEL_NULL;
|
level = AO_LEVEL_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
Analog_Output_Instance_To_Index(wp_data->
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
||||||
@@ -502,8 +502,7 @@ void testAnalogOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,8 @@ char *Analog_Value_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_ANALOG_VALUES) {
|
if (object_instance < MAX_ANALOG_VALUES) {
|
||||||
sprintf(text_string, "ANALOG VALUE %lu", (unsigned long)object_instance);
|
sprintf(text_string, "ANALOG VALUE %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +217,7 @@ char *Analog_Value_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Analog_Value_Read_Property(
|
int Analog_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -228,8 +229,7 @@ int Analog_Value_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,8 @@ int Analog_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Value_Out_Of_Service[object_index];
|
state = Analog_Value_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -283,7 +284,8 @@ int Analog_Value_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. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->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 (Analog_Value_Level[object_index][i] ==
|
if (Analog_Value_Level[object_index][i] ==
|
||||||
@@ -306,14 +308,16 @@ int Analog_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Analog_Value_Level[object_index][rpdata->array_index - 1] ==
|
if (Analog_Value_Level[object_index][rpdata->array_index -
|
||||||
ANALOG_LEVEL_NULL)
|
1] == ANALOG_LEVEL_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Analog_Value_Level[object_index][rpdata->array_index - 1];
|
Analog_Value_Level[object_index][rpdata->
|
||||||
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -335,8 +339,7 @@ int Analog_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -383,14 +386,14 @@ bool Analog_Value_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = ANALOG_LEVEL_NULL;
|
level = ANALOG_LEVEL_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
Analog_Value_Instance_To_Index(wp_data->
|
||||||
|
object_instance);
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
@@ -410,10 +413,9 @@ bool Analog_Value_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
||||||
@@ -457,8 +459,7 @@ void testAnalog_Value(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ static unsigned bacfile_file_size(
|
|||||||
|
|
||||||
/* return the number of bytes used, or -1 on error */
|
/* return the number of bytes used, or -1 on error */
|
||||||
int bacfile_read_property(
|
int bacfile_read_property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
char text_string[32] = { "" };
|
char text_string[32] = { "" };
|
||||||
@@ -194,8 +194,7 @@ int bacfile_read_property(
|
|||||||
BACNET_TIME btime;
|
BACNET_TIME btime;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -207,7 +206,8 @@ int bacfile_read_property(
|
|||||||
rpdata->object_instance);
|
rpdata->object_instance);
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
sprintf(text_string, "FILE %lu", (unsigned long)rpdata->object_instance);
|
sprintf(text_string, "FILE %lu",
|
||||||
|
(unsigned long) rpdata->object_instance);
|
||||||
characterstring_init_ansi(&char_string, text_string);
|
characterstring_init_ansi(&char_string, text_string);
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
@@ -302,10 +302,9 @@ bool bacfile_write_property(
|
|||||||
property shall be logical TRUE only if no changes have been
|
property shall be logical TRUE only if no changes have been
|
||||||
made to the file data by internal processes or through File
|
made to the file data by internal processes or through File
|
||||||
Access Services since the last time the object was archived. */
|
Access Services since the last time the object was archived. */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Boolean) {
|
if (value.type.Boolean) {
|
||||||
/* FIXME: do something to wp_data->object_instance */
|
/* FIXME: do something to wp_data->object_instance */
|
||||||
@@ -318,10 +317,9 @@ bool bacfile_write_property(
|
|||||||
/* If the file size can be changed by writing to the file,
|
/* If the file size can be changed by writing to the file,
|
||||||
and File_Access_Method is STREAM_ACCESS, then this property
|
and File_Access_Method is STREAM_ACCESS, then this property
|
||||||
shall be writable. */
|
shall be writable. */
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* FIXME: do something with value.type.Unsigned
|
/* FIXME: do something with value.type.Unsigned
|
||||||
to wp_data->object_instance */
|
to wp_data->object_instance */
|
||||||
|
|||||||
@@ -287,7 +287,8 @@ char *Binary_Input_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_INPUTS) {
|
if (object_instance < MAX_BINARY_INPUTS) {
|
||||||
sprintf(text_string, "BINARY INPUT %lu", (unsigned long)object_instance);
|
sprintf(text_string, "BINARY INPUT %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +298,7 @@ char *Binary_Input_Name(
|
|||||||
/* return apdu length, or -1 on error */
|
/* return apdu length, or -1 on error */
|
||||||
/* assumption - object already exists, and has been bounds checked */
|
/* assumption - object already exists, and has been bounds checked */
|
||||||
int Binary_Input_Read_Property(
|
int Binary_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
@@ -305,8 +306,7 @@ int Binary_Input_Read_Property(
|
|||||||
BACNET_POLARITY polarity = POLARITY_NORMAL;
|
BACNET_POLARITY polarity = POLARITY_NORMAL;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -370,8 +370,7 @@ int Binary_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -396,10 +395,9 @@ bool Binary_Input_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
if (value.type.Enumerated <= MAX_BINARY_PV) {
|
||||||
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
Binary_Input_Present_Value_Set(wp_data->object_instance,
|
||||||
@@ -412,10 +410,9 @@ bool Binary_Input_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Binary_Input_Out_Of_Service_Set(wp_data->object_instance,
|
Binary_Input_Out_Of_Service_Set(wp_data->object_instance,
|
||||||
value.type.Boolean);
|
value.type.Boolean);
|
||||||
@@ -457,8 +454,7 @@ void testBinaryInput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ char *Binary_Output_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_OUTPUTS) {
|
if (object_instance < MAX_BINARY_OUTPUTS) {
|
||||||
sprintf(text_string, "BINARY OUTPUT %lu", (unsigned long)object_instance);
|
sprintf(text_string, "BINARY OUTPUT %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ char *Binary_Output_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Binary_Output_Read_Property(
|
int Binary_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -205,8 +206,7 @@ int Binary_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,8 @@ int Binary_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], OBJECT_BINARY_OUTPUT);
|
encode_application_enumerated(&apdu[0], OBJECT_BINARY_OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Output_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -249,7 +250,8 @@ int Binary_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Binary_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Binary_Output_Out_Of_Service[object_index];
|
state = Binary_Output_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -290,12 +292,13 @@ int Binary_Output_Read_Property(
|
|||||||
object_index =
|
object_index =
|
||||||
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Binary_Output_Level[object_index][rpdata->array_index - 1] ==
|
if (Binary_Output_Level[object_index][rpdata->array_index -
|
||||||
BINARY_NULL)
|
1] == BINARY_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[apdu_len]);
|
apdu_len = encode_application_null(&apdu[apdu_len]);
|
||||||
else {
|
else {
|
||||||
present_value =
|
present_value =
|
||||||
Binary_Output_Level[object_index][rpdata->array_index - 1];
|
Binary_Output_Level[object_index][rpdata->
|
||||||
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_enumerated(&apdu[apdu_len],
|
encode_application_enumerated(&apdu[apdu_len],
|
||||||
present_value);
|
present_value);
|
||||||
@@ -329,8 +332,7 @@ int Binary_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -369,8 +371,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
|
||||||
@@ -390,14 +392,14 @@ bool Binary_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = BINARY_NULL;
|
level = BINARY_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
Binary_Output_Instance_To_Index(wp_data->
|
||||||
|
object_instance);
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
@@ -417,10 +419,9 @@ bool Binary_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
Binary_Output_Instance_To_Index(wp_data->object_instance);
|
||||||
@@ -465,8 +466,7 @@ void testBinaryOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ char *Binary_Value_Name(
|
|||||||
static char text_string[32] = ""; /* okay for single thread */
|
static char text_string[32] = ""; /* okay for single thread */
|
||||||
|
|
||||||
if (object_instance < MAX_BINARY_VALUES) {
|
if (object_instance < MAX_BINARY_VALUES) {
|
||||||
sprintf(text_string, "BINARY VALUE %lu", (unsigned long)object_instance);
|
sprintf(text_string, "BINARY VALUE %lu",
|
||||||
|
(unsigned long) object_instance);
|
||||||
return text_string;
|
return text_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ char *Binary_Value_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Binary_Value_Read_Property(
|
int Binary_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -201,8 +202,7 @@ int Binary_Value_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,8 @@ int Binary_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Value_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Value_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -245,7 +246,8 @@ int Binary_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Binary_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Binary_Value_Out_Of_Service[object_index];
|
state = Binary_Value_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -257,7 +259,8 @@ int Binary_Value_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. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
object_index = Binary_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(rpdata->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 (Binary_Value_Level[object_index][i] == BINARY_NULL)
|
if (Binary_Value_Level[object_index][i] == BINARY_NULL)
|
||||||
@@ -279,14 +282,16 @@ int Binary_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index = Binary_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Binary_Value_Level[object_index][rpdata->array_index] ==
|
if (Binary_Value_Level[object_index][rpdata->
|
||||||
BINARY_NULL)
|
array_index] == BINARY_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[apdu_len]);
|
apdu_len = encode_application_null(&apdu[apdu_len]);
|
||||||
else {
|
else {
|
||||||
present_value =
|
present_value =
|
||||||
Binary_Value_Level[object_index][rpdata->array_index];
|
Binary_Value_Level[object_index][rpdata->
|
||||||
|
array_index];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_enumerated(&apdu[apdu_len],
|
encode_application_enumerated(&apdu[apdu_len],
|
||||||
present_value);
|
present_value);
|
||||||
@@ -310,8 +315,7 @@ int Binary_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -350,8 +354,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
|
||||||
@@ -371,14 +375,14 @@ bool Binary_Value_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = BINARY_NULL;
|
level = BINARY_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Binary_Value_Instance_To_Index(wp_data->object_instance);
|
Binary_Value_Instance_To_Index(wp_data->
|
||||||
|
object_instance);
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||||
priority--;
|
priority--;
|
||||||
@@ -398,12 +402,12 @@ bool Binary_Value_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index = Binary_Value_Instance_To_Index(wp_data->object_instance);
|
object_index =
|
||||||
|
Binary_Value_Instance_To_Index(wp_data->object_instance);
|
||||||
Binary_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
Binary_Value_Out_Of_Service[object_index] = value.type.Boolean;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -444,8 +448,7 @@ void testBinary_Value(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
+221
-316
@@ -29,7 +29,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h> /* for memmove */
|
#include <string.h> /* for memmove */
|
||||||
#include <time.h> /* for timezone, localtime */
|
#include <time.h> /* for timezone, localtime */
|
||||||
#include "bacdef.h"
|
#include "bacdef.h"
|
||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
#include "bacenum.h"
|
#include "bacenum.h"
|
||||||
@@ -70,7 +70,7 @@ long int timezone;
|
|||||||
|
|
||||||
/* forward prototypes */
|
/* forward prototypes */
|
||||||
static int Device_Read_Property_Local(
|
static int Device_Read_Property_Local(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
static bool Device_Write_Property_Local(
|
static bool Device_Write_Property_Local(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
@@ -95,154 +95,76 @@ static struct object_functions {
|
|||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
rr_info_function Object_RR_Info;
|
rr_info_function Object_RR_Info;
|
||||||
object_iterate_function Object_Iterator;
|
object_iterate_function Object_Iterator;
|
||||||
} Object_Table[] =
|
} Object_Table[] = {
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
OBJECT_DEVICE, NULL, Device_Count, Device_Index_To_Instance,
|
||||||
NULL,
|
Device_Valid_Object_Instance_Number, Device_Name,
|
||||||
Device_Count,
|
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||||
Device_Index_To_Instance,
|
Device_Property_Lists, DeviceGetRRInfo, NULL}, {
|
||||||
Device_Valid_Object_Instance_Number,
|
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||||
Device_Name,
|
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||||
Device_Read_Property_Local,
|
Analog_Input_Name, Analog_Input_Read_Property, NULL,
|
||||||
Device_Write_Property_Local,
|
Analog_Input_Property_Lists, NULL, NULL}, {
|
||||||
Device_Property_Lists,
|
OBJECT_ANALOG_OUTPUT, Analog_Output_Init, Analog_Output_Count,
|
||||||
DeviceGetRRInfo,
|
Analog_Output_Index_To_Instance, Analog_Output_Valid_Instance,
|
||||||
NULL},
|
Analog_Output_Name, Analog_Output_Read_Property,
|
||||||
{OBJECT_ANALOG_INPUT,
|
Analog_Output_Write_Property, Analog_Output_Property_Lists,
|
||||||
Analog_Input_Init,
|
NULL, NULL}, {
|
||||||
Analog_Input_Count,
|
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||||
Analog_Input_Index_To_Instance,
|
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||||
Analog_Input_Valid_Instance,
|
Analog_Value_Name, Analog_Value_Read_Property,
|
||||||
Analog_Input_Name,
|
Analog_Value_Write_Property, Analog_Value_Property_Lists, NULL,
|
||||||
Analog_Input_Read_Property,
|
NULL}, {
|
||||||
NULL,
|
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||||
Analog_Input_Property_Lists,
|
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||||
NULL,
|
Binary_Input_Name, Binary_Input_Read_Property, NULL,
|
||||||
NULL},
|
Binary_Input_Property_Lists, NULL, NULL}, {
|
||||||
{OBJECT_ANALOG_OUTPUT,
|
OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count,
|
||||||
Analog_Output_Init,
|
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||||
Analog_Output_Count,
|
Binary_Output_Name, Binary_Output_Read_Property,
|
||||||
Analog_Output_Index_To_Instance,
|
Binary_Output_Write_Property, Binary_Output_Property_Lists,
|
||||||
Analog_Output_Valid_Instance,
|
NULL, NULL}, {
|
||||||
Analog_Output_Name,
|
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
|
||||||
Analog_Output_Read_Property,
|
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
|
||||||
Analog_Output_Write_Property,
|
Binary_Value_Name, Binary_Value_Read_Property,
|
||||||
Analog_Output_Property_Lists,
|
Binary_Value_Write_Property, Binary_Value_Property_Lists, NULL,
|
||||||
NULL,
|
NULL}, {
|
||||||
NULL},
|
OBJECT_LIFE_SAFETY_POINT, Life_Safety_Point_Init,
|
||||||
{OBJECT_ANALOG_VALUE,
|
Life_Safety_Point_Count, Life_Safety_Point_Index_To_Instance,
|
||||||
Analog_Value_Init,
|
Life_Safety_Point_Valid_Instance, Life_Safety_Point_Name,
|
||||||
Analog_Value_Count,
|
Life_Safety_Point_Read_Property,
|
||||||
Analog_Value_Index_To_Instance,
|
Life_Safety_Point_Write_Property,
|
||||||
Analog_Value_Valid_Instance,
|
Life_Safety_Point_Property_Lists, NULL, NULL}, {
|
||||||
Analog_Value_Name,
|
OBJECT_LOAD_CONTROL, Load_Control_Init, Load_Control_Count,
|
||||||
Analog_Value_Read_Property,
|
Load_Control_Index_To_Instance, Load_Control_Valid_Instance,
|
||||||
Analog_Value_Write_Property,
|
Load_Control_Name, Load_Control_Read_Property,
|
||||||
Analog_Value_Property_Lists,
|
Load_Control_Write_Property, Load_Control_Property_Lists, NULL,
|
||||||
NULL,
|
NULL}, {
|
||||||
NULL},
|
OBJECT_MULTI_STATE_OUTPUT, Multistate_Output_Init,
|
||||||
{OBJECT_BINARY_INPUT,
|
Multistate_Output_Count, Multistate_Output_Index_To_Instance,
|
||||||
Binary_Input_Init,
|
Multistate_Output_Valid_Instance, Multistate_Output_Name,
|
||||||
Binary_Input_Count,
|
Multistate_Output_Read_Property,
|
||||||
Binary_Input_Index_To_Instance,
|
Multistate_Output_Write_Property,
|
||||||
Binary_Input_Valid_Instance,
|
Multistate_Output_Property_Lists, NULL, NULL}, {
|
||||||
Binary_Input_Name,
|
OBJECT_MULTI_STATE_INPUT, Multistate_Input_Init,
|
||||||
Binary_Input_Read_Property,
|
Multistate_Input_Count, Multistate_Input_Index_To_Instance,
|
||||||
NULL,
|
Multistate_Input_Valid_Instance, Multistate_Input_Name,
|
||||||
Binary_Input_Property_Lists,
|
Multistate_Input_Read_Property,
|
||||||
NULL,
|
Multistate_Input_Write_Property,
|
||||||
NULL},
|
Multistate_Input_Property_Lists, NULL, NULL}, {
|
||||||
{OBJECT_BINARY_OUTPUT,
|
OBJECT_TRENDLOG, Trend_Log_Init, Trend_Log_Count,
|
||||||
Binary_Output_Init,
|
Trend_Log_Index_To_Instance, Trend_Log_Valid_Instance,
|
||||||
Binary_Output_Count,
|
Trend_Log_Name, Trend_Log_Read_Property,
|
||||||
Binary_Output_Index_To_Instance,
|
Trend_Log_Write_Property, Trend_Log_Property_Lists,
|
||||||
Binary_Output_Valid_Instance,
|
TrendLogGetRRInfo, NULL},
|
||||||
Binary_Output_Name,
|
|
||||||
Binary_Output_Read_Property,
|
|
||||||
Binary_Output_Write_Property,
|
|
||||||
Binary_Output_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_BINARY_VALUE,
|
|
||||||
Binary_Value_Init,
|
|
||||||
Binary_Value_Count,
|
|
||||||
Binary_Value_Index_To_Instance,
|
|
||||||
Binary_Value_Valid_Instance,
|
|
||||||
Binary_Value_Name,
|
|
||||||
Binary_Value_Read_Property,
|
|
||||||
Binary_Value_Write_Property,
|
|
||||||
Binary_Value_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_LIFE_SAFETY_POINT,
|
|
||||||
Life_Safety_Point_Init,
|
|
||||||
Life_Safety_Point_Count,
|
|
||||||
Life_Safety_Point_Index_To_Instance,
|
|
||||||
Life_Safety_Point_Valid_Instance,
|
|
||||||
Life_Safety_Point_Name,
|
|
||||||
Life_Safety_Point_Read_Property,
|
|
||||||
Life_Safety_Point_Write_Property,
|
|
||||||
Life_Safety_Point_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_LOAD_CONTROL,
|
|
||||||
Load_Control_Init,
|
|
||||||
Load_Control_Count,
|
|
||||||
Load_Control_Index_To_Instance,
|
|
||||||
Load_Control_Valid_Instance,
|
|
||||||
Load_Control_Name,
|
|
||||||
Load_Control_Read_Property,
|
|
||||||
Load_Control_Write_Property,
|
|
||||||
Load_Control_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_MULTI_STATE_OUTPUT,
|
|
||||||
Multistate_Output_Init,
|
|
||||||
Multistate_Output_Count,
|
|
||||||
Multistate_Output_Index_To_Instance,
|
|
||||||
Multistate_Output_Valid_Instance,
|
|
||||||
Multistate_Output_Name,
|
|
||||||
Multistate_Output_Read_Property,
|
|
||||||
Multistate_Output_Write_Property,
|
|
||||||
Multistate_Output_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_MULTI_STATE_INPUT,
|
|
||||||
Multistate_Input_Init,
|
|
||||||
Multistate_Input_Count,
|
|
||||||
Multistate_Input_Index_To_Instance,
|
|
||||||
Multistate_Input_Valid_Instance,
|
|
||||||
Multistate_Input_Name,
|
|
||||||
Multistate_Input_Read_Property,
|
|
||||||
Multistate_Input_Write_Property,
|
|
||||||
Multistate_Input_Property_Lists,
|
|
||||||
NULL,
|
|
||||||
NULL},
|
|
||||||
{OBJECT_TRENDLOG,
|
|
||||||
Trend_Log_Init,
|
|
||||||
Trend_Log_Count,
|
|
||||||
Trend_Log_Index_To_Instance,
|
|
||||||
Trend_Log_Valid_Instance,
|
|
||||||
Trend_Log_Name,
|
|
||||||
Trend_Log_Read_Property,
|
|
||||||
Trend_Log_Write_Property,
|
|
||||||
Trend_Log_Property_Lists,
|
|
||||||
TrendLogGetRRInfo,
|
|
||||||
NULL},
|
|
||||||
#if defined(BACFILE)
|
#if defined(BACFILE)
|
||||||
{OBJECT_FILE,
|
{
|
||||||
bacfile_init,
|
OBJECT_FILE, bacfile_init, bacfile_count, bacfile_index_to_instance,
|
||||||
bacfile_count,
|
bacfile_valid_instance, bacfile_name, bacfile_read_property,
|
||||||
bacfile_index_to_instance,
|
bacfile_write_property, BACfile_Property_Lists, NULL},
|
||||||
bacfile_valid_instance,
|
|
||||||
bacfile_name,
|
|
||||||
bacfile_read_property,
|
|
||||||
bacfile_write_property,
|
|
||||||
BACfile_Property_Lists,
|
|
||||||
NULL},
|
|
||||||
#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}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Glue function to let the Device object, when called by a handler,
|
/** Glue function to let the Device object, when called by a handler,
|
||||||
@@ -252,7 +174,7 @@ static struct object_functions {
|
|||||||
* @return Pointer to the group of object helper functions that implement this
|
* @return Pointer to the group of object helper functions that implement this
|
||||||
* type of Object.
|
* type of Object.
|
||||||
*/
|
*/
|
||||||
static struct object_functions * Device_Objects_Find_Functions(
|
static struct object_functions *Device_Objects_Find_Functions(
|
||||||
BACNET_OBJECT_TYPE Object_Type)
|
BACNET_OBJECT_TYPE Object_Type)
|
||||||
{
|
{
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
@@ -261,13 +183,13 @@ static struct object_functions * Device_Objects_Find_Functions(
|
|||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
/* handle each object type */
|
/* handle each object type */
|
||||||
if (pObject->Object_Type == Object_Type) {
|
if (pObject->Object_Type == Object_Type) {
|
||||||
return(pObject);
|
return (pObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
pObject++;
|
pObject++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try to find a rr_info_function helper function for the requested object type.
|
/** Try to find a rr_info_function helper function for the requested object type.
|
||||||
@@ -281,12 +203,11 @@ static struct object_functions * Device_Objects_Find_Functions(
|
|||||||
*/
|
*/
|
||||||
rr_info_function Device_Objects_RR_Info(
|
rr_info_function Device_Objects_RR_Info(
|
||||||
BACNET_OBJECT_TYPE object_type)
|
BACNET_OBJECT_TYPE object_type)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
|
|
||||||
pObject = Device_Objects_Find_Functions(object_type);
|
pObject = Device_Objects_Find_Functions(object_type);
|
||||||
return(pObject != NULL ? pObject->Object_RR_Info : NULL);
|
return (pObject != NULL ? pObject->Object_RR_Info : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned property_list_count(
|
static unsigned property_list_count(
|
||||||
@@ -332,21 +253,22 @@ void Device_Objects_Property_List(
|
|||||||
|
|
||||||
pObject = Device_Objects_Find_Functions(object_type);
|
pObject = Device_Objects_Find_Functions(object_type);
|
||||||
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
||||||
pObject->Object_RPM_List(
|
pObject->Object_RPM_List(&pPropertyList->Required.pList,
|
||||||
&pPropertyList->Required.pList,
|
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||||
&pPropertyList->Optional.pList,
|
|
||||||
&pPropertyList->Proprietary.pList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch the counts if available otherwise zero them */
|
/* Fetch the counts if available otherwise zero them */
|
||||||
pPropertyList->Required.count = pPropertyList->Required.pList == NULL
|
pPropertyList->Required.count =
|
||||||
? 0 : property_list_count(pPropertyList->Required.pList);
|
pPropertyList->Required.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Required.pList);
|
||||||
|
|
||||||
pPropertyList->Optional.count = pPropertyList->Optional.pList == NULL
|
pPropertyList->Optional.count =
|
||||||
? 0 : property_list_count(pPropertyList->Optional.pList);
|
pPropertyList->Optional.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Optional.pList);
|
||||||
|
|
||||||
pPropertyList->Proprietary.count = pPropertyList->Proprietary.pList == NULL
|
pPropertyList->Proprietary.count =
|
||||||
? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
pPropertyList->Proprietary.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -365,7 +287,7 @@ void Device_Objects_Property_List(
|
|||||||
* @return True if succeeds (password is correct), else False.
|
* @return True if succeeds (password is correct), else False.
|
||||||
*/
|
*/
|
||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
@@ -493,8 +415,8 @@ static char Description[MAX_DEV_DESC_LEN + 1] = "server";
|
|||||||
/* static uint8_t Max_Segments_Accepted = 0; */
|
/* static uint8_t Max_Segments_Accepted = 0; */
|
||||||
/* VT_Classes_Supported */
|
/* VT_Classes_Supported */
|
||||||
/* Active_VT_Sessions */
|
/* Active_VT_Sessions */
|
||||||
static BACNET_TIME Local_Time; /* rely on OS, if there is one */
|
static BACNET_TIME Local_Time; /* rely on OS, if there is one */
|
||||||
static BACNET_DATE Local_Date; /* rely on OS, if there is one */
|
static BACNET_DATE Local_Date; /* rely on OS, if there is one */
|
||||||
/* NOTE: BACnet UTC Offset is inverse of common practice.
|
/* NOTE: BACnet UTC Offset is inverse of common practice.
|
||||||
If your UTC offset is -5hours of GMT,
|
If your UTC offset is -5hours of GMT,
|
||||||
then BACnet UTC offset is +5hours.
|
then BACnet UTC offset is +5hours.
|
||||||
@@ -517,7 +439,8 @@ static uint32_t Database_Revision = 0;
|
|||||||
/* Slave_Address_Binding */
|
/* Slave_Address_Binding */
|
||||||
/* Profile_Name */
|
/* Profile_Name */
|
||||||
|
|
||||||
unsigned Device_Count(void)
|
unsigned Device_Count(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -551,8 +474,7 @@ bool Device_Set_Object_Instance_Number(
|
|||||||
/* Make the change and update the database revision */
|
/* Make the change and update the database revision */
|
||||||
Object_Instance_Number = object_id;
|
Object_Instance_Number = object_id;
|
||||||
Device_Inc_Database_Revision();
|
Device_Inc_Database_Revision();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
status = false;
|
status = false;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@@ -612,12 +534,12 @@ int Device_Set_System_Status(
|
|||||||
BACNET_DEVICE_STATUS status,
|
BACNET_DEVICE_STATUS status,
|
||||||
bool local)
|
bool local)
|
||||||
{
|
{
|
||||||
int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
|
int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
|
||||||
|
|
||||||
/* We limit the options available depending on whether the source is
|
/* We limit the options available depending on whether the source is
|
||||||
* internal or external. */
|
* internal or external. */
|
||||||
if(local) {
|
if (local) {
|
||||||
switch(status) {
|
switch (status) {
|
||||||
case STATUS_OPERATIONAL:
|
case STATUS_OPERATIONAL:
|
||||||
case STATUS_OPERATIONAL_READ_ONLY:
|
case STATUS_OPERATIONAL_READ_ONLY:
|
||||||
case STATUS_DOWNLOAD_REQUIRED:
|
case STATUS_DOWNLOAD_REQUIRED:
|
||||||
@@ -626,7 +548,7 @@ int Device_Set_System_Status(
|
|||||||
System_Status = status;
|
System_Status = status;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Don't support backup at present so don't allow setting */
|
/* Don't support backup at present so don't allow setting */
|
||||||
case STATUS_BACKUP_IN_PROGRESS:
|
case STATUS_BACKUP_IN_PROGRESS:
|
||||||
result = -2;
|
result = -2;
|
||||||
break;
|
break;
|
||||||
@@ -636,30 +558,30 @@ int Device_Set_System_Status(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch(status) {
|
switch (status) {
|
||||||
/* Allow these for the moment as a way to easily alter
|
/* Allow these for the moment as a way to easily alter
|
||||||
* overall device operation. The lack of password protection
|
* overall device operation. The lack of password protection
|
||||||
* or other authentication makes allowing writes to this
|
* or other authentication makes allowing writes to this
|
||||||
* property a risky facility to provide.
|
* property a risky facility to provide.
|
||||||
*/
|
*/
|
||||||
case STATUS_OPERATIONAL:
|
case STATUS_OPERATIONAL:
|
||||||
case STATUS_OPERATIONAL_READ_ONLY:
|
case STATUS_OPERATIONAL_READ_ONLY:
|
||||||
case STATUS_NON_OPERATIONAL:
|
case STATUS_NON_OPERATIONAL:
|
||||||
System_Status = status;
|
System_Status = status;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Don't allow outsider set this - it should probably
|
/* Don't allow outsider set this - it should probably
|
||||||
* be set if the device config is incomplete or
|
* be set if the device config is incomplete or
|
||||||
* corrupted or perhaps after some sort of operator
|
* corrupted or perhaps after some sort of operator
|
||||||
* wipe operation.
|
* wipe operation.
|
||||||
*/
|
*/
|
||||||
case STATUS_DOWNLOAD_REQUIRED:
|
case STATUS_DOWNLOAD_REQUIRED:
|
||||||
/* Don't allow outsider set this - it should be set
|
/* Don't allow outsider set this - it should be set
|
||||||
* internally at the start of a multi packet download
|
* internally at the start of a multi packet download
|
||||||
* perhaps indirectly via PT or WF to a config file.
|
* perhaps indirectly via PT or WF to a config file.
|
||||||
*/
|
*/
|
||||||
case STATUS_DOWNLOAD_IN_PROGRESS:
|
case STATUS_DOWNLOAD_IN_PROGRESS:
|
||||||
/* Don't support backup at present so don't allow setting */
|
/* Don't support backup at present so don't allow setting */
|
||||||
case STATUS_BACKUP_IN_PROGRESS:
|
case STATUS_BACKUP_IN_PROGRESS:
|
||||||
result = -2;
|
result = -2;
|
||||||
break;
|
break;
|
||||||
@@ -670,7 +592,7 @@ int Device_Set_System_Status(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Device_Vendor_Name(
|
const char *Device_Vendor_Name(
|
||||||
@@ -880,28 +802,29 @@ bool Device_Object_List_Identifier(
|
|||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Count) {
|
if (pObject->Object_Count) {
|
||||||
object_index -= count;
|
object_index -= count;
|
||||||
count = pObject->Object_Count();
|
count = pObject->Object_Count();
|
||||||
if (object_index < count) {
|
if (object_index < count) {
|
||||||
/* Use the iterator function if available otherwise
|
/* Use the iterator function if available otherwise
|
||||||
* look for the index to instance to get the ID */
|
* look for the index to instance to get the ID */
|
||||||
if(pObject->Object_Iterator) {
|
if (pObject->Object_Iterator) {
|
||||||
/* First find the first object */
|
/* First find the first object */
|
||||||
temp_index = pObject->Object_Iterator(~0);
|
temp_index = pObject->Object_Iterator(~0);
|
||||||
/* Then step through the objects to find the nth */
|
/* Then step through the objects to find the nth */
|
||||||
while(object_index != 0) {
|
while (object_index != 0) {
|
||||||
temp_index = pObject->Object_Iterator(temp_index);
|
temp_index = pObject->Object_Iterator(temp_index);
|
||||||
object_index--;
|
object_index--;
|
||||||
}
|
}
|
||||||
/* set the object_index up before falling through to next bit */
|
/* set the object_index up before falling through to next bit */
|
||||||
object_index = temp_index;
|
object_index = temp_index;
|
||||||
}
|
}
|
||||||
if(pObject->Object_Index_To_Instance) {
|
if (pObject->Object_Index_To_Instance) {
|
||||||
*object_type = pObject->Object_Type;
|
*object_type = pObject->Object_Type;
|
||||||
*instance = pObject->Object_Index_To_Instance(object_index);
|
*instance =
|
||||||
|
pObject->Object_Index_To_Instance(object_index);
|
||||||
status = true;
|
status = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pObject++;
|
pObject++;
|
||||||
}
|
}
|
||||||
@@ -969,14 +892,15 @@ char *Device_Valid_Object_Id(
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Update_Current_Time(void)
|
static void Update_Current_Time(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
struct tm *tblock = NULL;
|
struct tm *tblock = NULL;
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
time_t tTemp;
|
time_t tTemp;
|
||||||
#else
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
struct tm
|
struct tm
|
||||||
|
|
||||||
@@ -990,43 +914,33 @@ int tm_wday Day of week [0,6] (Sunday =0).
|
|||||||
int tm_yday Day of year [0,365].
|
int tm_yday Day of year [0,365].
|
||||||
int tm_isdst Daylight Savings flag.
|
int tm_isdst Daylight Savings flag.
|
||||||
*/
|
*/
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
time(&tTemp);
|
time(&tTemp);
|
||||||
tblock = localtime(&tTemp);
|
tblock = localtime(&tTemp);
|
||||||
#else
|
#else
|
||||||
if (gettimeofday(&tv, NULL) == 0) {
|
if (gettimeofday(&tv, NULL) == 0) {
|
||||||
tblock = localtime(&tv.tv_sec);
|
tblock = localtime(&tv.tv_sec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tblock) {
|
if (tblock) {
|
||||||
datetime_set_date(
|
datetime_set_date(&Local_Date, (uint16_t) tblock->tm_year + 1900,
|
||||||
&Local_Date,
|
(uint8_t) tblock->tm_mon + 1, (uint8_t) tblock->tm_mday);
|
||||||
(uint16_t) tblock->tm_year+1900,
|
#if !defined(_MSC_VER)
|
||||||
(uint8_t) tblock->tm_mon+1,
|
datetime_set_time(&Local_Time, (uint8_t) tblock->tm_hour,
|
||||||
(uint8_t) tblock->tm_mday);
|
(uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec,
|
||||||
#if !defined(_MSC_VER)
|
(uint8_t) (tv.tv_usec / 10000));
|
||||||
datetime_set_time(
|
#else
|
||||||
&Local_Time,
|
datetime_set_time(&Local_Time, (uint8_t) tblock->tm_hour,
|
||||||
(uint8_t) tblock->tm_hour,
|
(uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec, 0);
|
||||||
(uint8_t) tblock->tm_min,
|
#endif
|
||||||
(uint8_t) tblock->tm_sec,
|
|
||||||
(uint8_t)(tv.tv_usec / 10000));
|
|
||||||
#else
|
|
||||||
datetime_set_time(
|
|
||||||
&Local_Time,
|
|
||||||
(uint8_t) tblock->tm_hour,
|
|
||||||
(uint8_t) tblock->tm_min,
|
|
||||||
(uint8_t) tblock->tm_sec,
|
|
||||||
0);
|
|
||||||
#endif
|
|
||||||
if (tblock->tm_isdst) {
|
if (tblock->tm_isdst) {
|
||||||
Daylight_Savings_Status = true;
|
Daylight_Savings_Status = true;
|
||||||
} else {
|
} else {
|
||||||
Daylight_Savings_Status = false;
|
Daylight_Savings_Status = false;
|
||||||
}
|
}
|
||||||
/* note: timezone is declared in <time.h> stdlib. */
|
/* note: timezone is declared in <time.h> stdlib. */
|
||||||
UTC_Offset = timezone/60;
|
UTC_Offset = timezone / 60;
|
||||||
} else {
|
} else {
|
||||||
datetime_date_wildcard_set(&Local_Date);
|
datetime_date_wildcard_set(&Local_Date);
|
||||||
datetime_time_wildcard_set(&Local_Time);
|
datetime_time_wildcard_set(&Local_Time);
|
||||||
@@ -1037,7 +951,7 @@ int tm_isdst Daylight Savings flag.
|
|||||||
/* return the length of the apdu encoded or -1 for error or
|
/* return the length of the apdu encoded or -1 for error or
|
||||||
-2 for abort message */
|
-2 for abort message */
|
||||||
static int Device_Read_Property_Local(
|
static int Device_Read_Property_Local(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
int len = 0; /* apdu len intermediate value */
|
int len = 0; /* apdu len intermediate value */
|
||||||
@@ -1051,8 +965,7 @@ static int Device_Read_Property_Local(
|
|||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1162,8 +1075,7 @@ static int Device_Read_Property_Local(
|
|||||||
|
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Count) &&
|
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
|
||||||
(pObject->Object_Count() > 0)) {
|
|
||||||
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
||||||
}
|
}
|
||||||
pObject++;
|
pObject++;
|
||||||
@@ -1181,9 +1093,8 @@ static int Device_Read_Property_Local(
|
|||||||
/* your maximum APDU size. */
|
/* your maximum APDU size. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
for (i = 1; i <= count; i++) {
|
for (i = 1; i <= count; i++) {
|
||||||
found = Device_Object_List_Identifier(
|
found =
|
||||||
i,
|
Device_Object_List_Identifier(i, &object_type,
|
||||||
&object_type,
|
|
||||||
&instance);
|
&instance);
|
||||||
if (found) {
|
if (found) {
|
||||||
len =
|
len =
|
||||||
@@ -1206,10 +1117,9 @@ static int Device_Read_Property_Local(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
found = Device_Object_List_Identifier(
|
found =
|
||||||
rpdata->array_index,
|
Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&object_type,
|
&object_type, &instance);
|
||||||
&instance);
|
|
||||||
if (found) {
|
if (found) {
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
@@ -1265,8 +1175,7 @@ static int Device_Read_Property_Local(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
|
||||||
(rpdata->object_property != PROP_OBJECT_LIST) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -1285,7 +1194,7 @@ static int Device_Read_Property_Local(
|
|||||||
* @return The length of the APDU on success, else -1
|
* @return The length of the APDU on success, else -1
|
||||||
*/
|
*/
|
||||||
int Device_Read_Property(
|
int Device_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = -1;
|
int apdu_len = -1;
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
@@ -1329,13 +1238,13 @@ static bool Device_Write_Property_Local(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_OBJECT_IDENTIFIER:
|
case PROP_OBJECT_IDENTIFIER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_OBJECT_ID,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_OBJECT_ID,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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.Object_Id.instance))) {
|
(Device_Set_Object_Instance_Number(value.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;
|
||||||
@@ -1345,41 +1254,37 @@ static bool Device_Write_Property_Local(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_NUMBER_OF_APDU_RETRIES:
|
case PROP_NUMBER_OF_APDU_RETRIES:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* FIXME: bounds check? */
|
/* FIXME: bounds check? */
|
||||||
apdu_retries_set((uint8_t) value.type.Unsigned_Int);
|
apdu_retries_set((uint8_t) value.type.Unsigned_Int);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_APDU_TIMEOUT:
|
case PROP_APDU_TIMEOUT:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* FIXME: bounds check? */
|
/* FIXME: bounds check? */
|
||||||
apdu_timeout_set((uint16_t) value.type.Unsigned_Int);
|
apdu_timeout_set((uint16_t) value.type.Unsigned_Int);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_VENDOR_IDENTIFIER:
|
case PROP_VENDOR_IDENTIFIER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
temp = Device_Set_System_Status((BACNET_DEVICE_STATUS)
|
temp = Device_Set_System_Status((BACNET_DEVICE_STATUS)
|
||||||
value.type.Enumerated, false);
|
value.type.Enumerated, false);
|
||||||
@@ -1389,62 +1294,63 @@ static bool Device_Write_Property_Local(
|
|||||||
if (temp == -1) {
|
if (temp == -1) {
|
||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_code = ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_OPTIONAL_FUNCTIONALITY_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_NAME_LEN,
|
WPValidateString(&value, MAX_DEV_NAME_LEN, false,
|
||||||
false,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_class,
|
if (status) {
|
||||||
&wp_data->error_code);
|
Device_Set_Object_Name(characterstring_value(&value.type.
|
||||||
if (status) {
|
Character_String),
|
||||||
Device_Set_Object_Name(characterstring_value(&value.type.Character_String), characterstring_length(&value.type.Character_String));
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_LOC_LEN,
|
WPValidateString(&value, MAX_DEV_LOC_LEN, true,
|
||||||
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.type.Character_String), characterstring_length(&value.type.Character_String));
|
Device_Set_Location(characterstring_value(&value.type.
|
||||||
|
Character_String),
|
||||||
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DESCRIPTION:
|
case PROP_DESCRIPTION:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_DESC_LEN,
|
WPValidateString(&value, MAX_DEV_DESC_LEN, true,
|
||||||
true,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_class,
|
if (status) {
|
||||||
&wp_data->error_code);
|
Device_Set_Description(characterstring_value(&value.type.
|
||||||
if (status) {
|
Character_String),
|
||||||
Device_Set_Description(characterstring_value(&value.type.Character_String), characterstring_length(&value.type.Character_String));
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_MODEL_NAME:
|
case PROP_MODEL_NAME:
|
||||||
status = WPValidateString(&value,
|
status =
|
||||||
MAX_DEV_MOD_LEN,
|
WPValidateString(&value, MAX_DEV_MOD_LEN, true,
|
||||||
true,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_class,
|
if (status) {
|
||||||
&wp_data->error_code);
|
Device_Set_Model_Name(characterstring_value(&value.type.
|
||||||
if (status) {
|
Character_String),
|
||||||
Device_Set_Model_Name(characterstring_value(&value.type.Character_String), characterstring_length(&value.type.Character_String));
|
characterstring_length(&value.type.Character_String));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if defined(BACDL_MSTP)
|
#if defined(BACDL_MSTP)
|
||||||
case PROP_MAX_INFO_FRAMES:
|
case PROP_MAX_INFO_FRAMES:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
@@ -1453,10 +1359,9 @@ static bool Device_Write_Property_Local(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_MASTER:
|
case PROP_MAX_MASTER:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if ((value.type.Unsigned_Int > 0) &&
|
if ((value.type.Unsigned_Int > 0) &&
|
||||||
(value.type.Unsigned_Int <= 127)) {
|
(value.type.Unsigned_Int <= 127)) {
|
||||||
@@ -1490,7 +1395,7 @@ static bool Device_Write_Property_Local(
|
|||||||
bool Device_Write_Property(
|
bool Device_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||||
{
|
{
|
||||||
bool status = false; /* Ever the pessamist! */
|
bool status = false; /* Ever the pessamist! */
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
|
|
||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
@@ -1498,7 +1403,7 @@ bool Device_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||||
pObject = Device_Objects_Find_Functions(wp_data->object_type);
|
pObject = Device_Objects_Find_Functions(wp_data->object_type);
|
||||||
if (pObject != NULL) {
|
if (pObject != NULL) {
|
||||||
if (pObject->Object_Valid_Instance &&
|
if (pObject->Object_Valid_Instance &&
|
||||||
pObject->Object_Valid_Instance(wp_data->object_instance)) {
|
pObject->Object_Valid_Instance(wp_data->object_instance)) {
|
||||||
if (pObject->Object_Write_Property) {
|
if (pObject->Object_Write_Property) {
|
||||||
status = pObject->Object_Write_Property(wp_data);
|
status = pObject->Object_Write_Property(wp_data);
|
||||||
@@ -1515,7 +1420,7 @@ bool Device_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE;
|
wp_data->error_code = ERROR_CODE_UNSUPPORTED_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1537,12 +1442,12 @@ void Device_Init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceGetRRInfo(
|
bool DeviceGetRRInfo(
|
||||||
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
RR_PROP_INFO *pInfo) /* Where to put the response */
|
RR_PROP_INFO * pInfo)
|
||||||
{
|
{ /* Where to put the response */
|
||||||
bool status = false; /* return value */
|
bool status = false; /* return value */
|
||||||
|
|
||||||
switch(pRequest->object_property) {
|
switch (pRequest->object_property) {
|
||||||
case PROP_VT_CLASSES_SUPPORTED:
|
case PROP_VT_CLASSES_SUPPORTED:
|
||||||
case PROP_ACTIVE_VT_SESSIONS:
|
case PROP_ACTIVE_VT_SESSIONS:
|
||||||
case PROP_LIST_OF_SESSION_KEYS:
|
case PROP_LIST_OF_SESSION_KEYS:
|
||||||
@@ -1553,7 +1458,7 @@ bool DeviceGetRRInfo(
|
|||||||
case PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS:
|
case PROP_UTC_TIME_SYNCHRONIZATION_RECIPIENTS:
|
||||||
pInfo->RequestTypes = RR_BY_POSITION;
|
pInfo->RequestTypes = RR_BY_POSITION;
|
||||||
pRequest->error_class = ERROR_CLASS_PROPERTY;
|
pRequest->error_class = ERROR_CLASS_PROPERTY;
|
||||||
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DEVICE_ADDRESS_BINDING:
|
case PROP_DEVICE_ADDRESS_BINDING:
|
||||||
@@ -1565,11 +1470,11 @@ bool DeviceGetRRInfo(
|
|||||||
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
|
case PROP_ACTIVE_COV_SUBSCRIPTIONS:
|
||||||
pInfo->RequestTypes = RR_BY_POSITION;
|
pInfo->RequestTypes = RR_BY_POSITION;
|
||||||
pRequest->error_class = ERROR_CLASS_PROPERTY;
|
pRequest->error_class = ERROR_CLASS_PROPERTY;
|
||||||
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
pRequest->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pRequest->error_class = ERROR_CLASS_SERVICES;
|
pRequest->error_class = ERROR_CLASS_SERVICES;
|
||||||
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
pRequest->error_code = ERROR_CODE_PROPERTY_IS_NOT_A_LIST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ void Load_Control_Init(
|
|||||||
Shed_Duration[i] = 0;
|
Shed_Duration[i] = 0;
|
||||||
Duty_Window[i] = 0;
|
Duty_Window[i] = 0;
|
||||||
Load_Control_Enable[i] = true;
|
Load_Control_Enable[i] = true;
|
||||||
Full_Duty_Baseline[i] = 1.500; /* kilowatts */
|
Full_Duty_Baseline[i] = 1.500; /* kilowatts */
|
||||||
Expected_Shed_Level[i].type = BACNET_SHED_TYPE_LEVEL;
|
Expected_Shed_Level[i].type = BACNET_SHED_TYPE_LEVEL;
|
||||||
Expected_Shed_Level[i].value.level = 0;
|
Expected_Shed_Level[i].value.level = 0;
|
||||||
Actual_Shed_Level[i].type = BACNET_SHED_TYPE_LEVEL;
|
Actual_Shed_Level[i].type = BACNET_SHED_TYPE_LEVEL;
|
||||||
@@ -680,7 +680,7 @@ void Load_Control_State_Machine_Handler(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Load_Control_Read_Property(
|
int Load_Control_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -692,8 +692,7 @@ int Load_Control_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -933,7 +932,7 @@ bool Load_Control_Write_Property(
|
|||||||
unsigned int object_index = 0;
|
unsigned int object_index = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
BACNET_APPLICATION_DATA_VALUE value;
|
BACNET_APPLICATION_DATA_VALUE value;
|
||||||
BACNET_DATE TempDate; /* build here in case of error in time half of datetime */
|
BACNET_DATE TempDate; /* build here in case of error in time half of datetime */
|
||||||
|
|
||||||
/* decode the some of the request */
|
/* decode the some of the request */
|
||||||
len =
|
len =
|
||||||
@@ -980,23 +979,22 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_START_TIME:
|
case PROP_START_TIME:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_DATE,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_DATE,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* don't continue if we don't have a valid date */
|
/* don't continue if we don't have a valid date */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Hold the date until we are sure the time is also there */
|
/* Hold the date until we are sure the time is also there */
|
||||||
TempDate = value.type.Date;
|
TempDate = value.type.Date;
|
||||||
len = bacapp_decode_application_data(wp_data->application_data + len,
|
len =
|
||||||
|
bacapp_decode_application_data(wp_data->application_data + len,
|
||||||
wp_data->application_data_len - len, &value);
|
wp_data->application_data_len - len, &value);
|
||||||
if (len) {
|
if (len) {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_TIME,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_TIME,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* Write time and date and set written flag */
|
/* Write time and date and set written flag */
|
||||||
Start_Time[object_index].date = TempDate;
|
Start_Time[object_index].date = TempDate;
|
||||||
@@ -1011,10 +1009,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SHED_DURATION:
|
case PROP_SHED_DURATION:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
Shed_Duration[object_index] = value.type.Unsigned_Int;
|
||||||
Load_Control_Request_Written[object_index] = true;
|
Load_Control_Request_Written[object_index] = true;
|
||||||
@@ -1022,10 +1019,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DUTY_WINDOW:
|
case PROP_DUTY_WINDOW:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Duty_Window[object_index] = value.type.Unsigned_Int;
|
Duty_Window[object_index] = value.type.Unsigned_Int;
|
||||||
Load_Control_Request_Written[object_index] = true;
|
Load_Control_Request_Written[object_index] = true;
|
||||||
@@ -1033,10 +1029,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SHED_LEVELS:
|
case PROP_SHED_LEVELS:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
/* re-write the size of the array? */
|
/* re-write the size of the array? */
|
||||||
if (wp_data->array_index == 0) {
|
if (wp_data->array_index == 0) {
|
||||||
@@ -1059,10 +1054,9 @@ bool Load_Control_Write_Property(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ENABLE:
|
case PROP_ENABLE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Load_Control_Enable[object_index] = value.type.Boolean;
|
Load_Control_Enable[object_index] = value.type.Boolean;
|
||||||
}
|
}
|
||||||
@@ -1485,8 +1479,7 @@ void testLoadControl(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ int Lighting_Output_Decode_Lighting_Command(
|
|||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
len =
|
len =
|
||||||
decode_enumerated(&apdu[apdu_len], len_value_type,
|
decode_enumerated(&apdu[apdu_len], len_value_type,
|
||||||
(uint32_t *)&data->operation);
|
(uint32_t *) & data->operation);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
/* Tag 1: level - OPTIONAL */
|
/* Tag 1: level - OPTIONAL */
|
||||||
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
if (decode_is_context_tag(&apdu[apdu_len], 1)) {
|
||||||
@@ -162,7 +162,7 @@ int Lighting_Output_Decode_Lighting_Command(
|
|||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
len = decode_real(&apdu[apdu_len], &real_value);
|
len = decode_real(&apdu[apdu_len], &real_value);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
data->level = (uint8_t)real_value;
|
data->level = (uint8_t) real_value;
|
||||||
/* FIXME: are we going to flag errors in decoding values here? */
|
/* FIXME: are we going to flag errors in decoding values here? */
|
||||||
}
|
}
|
||||||
/* FIXME: finish me! */
|
/* FIXME: finish me! */
|
||||||
@@ -359,7 +359,7 @@ char *Lighting_Output_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Lighting_Output_Read_Property(
|
int Lighting_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -371,8 +371,7 @@ int Lighting_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -398,11 +397,13 @@ int Lighting_Output_Read_Property(
|
|||||||
OBJECT_LIGHTING_OUTPUT);
|
OBJECT_LIGHTING_OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
real_value = Lighting_Output_Present_Value(rpdata->object_instance);
|
real_value =
|
||||||
|
Lighting_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_real(&apdu[0], real_value);
|
apdu_len = encode_application_real(&apdu[0], real_value);
|
||||||
break;
|
break;
|
||||||
case PROP_PROGRESS_VALUE:
|
case PROP_PROGRESS_VALUE:
|
||||||
real_value = Lighting_Output_Progress_Value(rpdata->object_instance);
|
real_value =
|
||||||
|
Lighting_Output_Progress_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_real(&apdu[0], real_value);
|
apdu_len = encode_application_real(&apdu[0], real_value);
|
||||||
break;
|
break;
|
||||||
case PROP_LIGHTING_COMMAND:
|
case PROP_LIGHTING_COMMAND:
|
||||||
@@ -423,7 +424,8 @@ int Lighting_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Lighting_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Lighting_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Lighting_Output_Out_Of_Service[object_index];
|
state = Lighting_Output_Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -465,13 +467,13 @@ 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 - 1] ==
|
if (Lighting_Output_Level[object_index][rpdata->
|
||||||
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 =
|
real_value =
|
||||||
Lighting_Output_Level[object_index][rpdata->array_index -
|
Lighting_Output_Level[object_index][rpdata->
|
||||||
1];
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -494,8 +496,7 @@ int Lighting_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -541,18 +542,17 @@ bool Lighting_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
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
|
||||||
@@ -574,14 +574,13 @@ bool Lighting_Output_Write_Property(
|
|||||||
&Lighting_Command[wp_data->object_instance]);
|
&Lighting_Command[wp_data->object_instance]);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
}
|
}
|
||||||
@@ -623,8 +622,7 @@ void testLightingOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ char *Life_Safety_Point_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Life_Safety_Point_Read_Property(
|
int Life_Safety_Point_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -203,8 +203,7 @@ int Life_Safety_Point_Read_Property(
|
|||||||
BACNET_RELIABILITY reliability = RELIABILITY_NO_FAULT_DETECTED;
|
BACNET_RELIABILITY reliability = RELIABILITY_NO_FAULT_DETECTED;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -228,7 +227,8 @@ int Life_Safety_Point_Read_Property(
|
|||||||
OBJECT_LIFE_SAFETY_POINT);
|
OBJECT_LIFE_SAFETY_POINT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Life_Safety_Point_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Life_Safety_Point_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -286,8 +286,7 @@ int Life_Safety_Point_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -313,15 +312,14 @@ bool Life_Safety_Point_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
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 {
|
||||||
@@ -332,14 +330,13 @@ bool Life_Safety_Point_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
}
|
}
|
||||||
@@ -381,8 +378,7 @@ void testLifeSafetyPoint(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ bool Multistate_Input_State_Text_Set(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Multistate_Input_Read_Property(
|
int Multistate_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -330,8 +330,7 @@ int Multistate_Input_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -362,7 +361,8 @@ int Multistate_Input_Read_Property(
|
|||||||
OBJECT_MULTI_STATE_INPUT);
|
OBJECT_MULTI_STATE_INPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Multistate_Input_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Multistate_Input_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -380,7 +380,8 @@ int Multistate_Input_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Multistate_Input_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Multistate_Input_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Out_Of_Service[object_index];
|
state = Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
@@ -399,10 +400,12 @@ 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(rpdata->object_instance);
|
Multistate_Input_Instance_To_Index(rpdata->
|
||||||
|
object_instance);
|
||||||
for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) {
|
for (i = 0; i < MULTISTATE_NUMBER_OF_STATES; i++) {
|
||||||
characterstring_init_ansi(&char_string,
|
characterstring_init_ansi(&char_string,
|
||||||
Multistate_Input_State_Text(rpdata->object_instance, i));
|
Multistate_Input_State_Text(rpdata->object_instance,
|
||||||
|
i));
|
||||||
/* FIXME: this might go beyond MAX_APDU length! */
|
/* FIXME: this might go beyond MAX_APDU length! */
|
||||||
len =
|
len =
|
||||||
encode_application_character_string(&apdu[apdu_len],
|
encode_application_character_string(&apdu[apdu_len],
|
||||||
@@ -419,11 +422,12 @@ int Multistate_Input_Read_Property(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index =
|
object_index =
|
||||||
Multistate_Input_Instance_To_Index(rpdata->object_instance);
|
Multistate_Input_Instance_To_Index(rpdata->
|
||||||
|
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,
|
||||||
rpdata->array_index-1));
|
rpdata->array_index - 1));
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0],
|
encode_application_character_string(&apdu[0],
|
||||||
&char_string);
|
&char_string);
|
||||||
@@ -441,8 +445,7 @@ int Multistate_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_STATE_TEXT) &&
|
||||||
(rpdata->object_property != PROP_STATE_TEXT) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -469,15 +472,14 @@ bool Multistate_Input_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_UNSIGNED_INT,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (Out_Of_Service[object_index]) {
|
if (Out_Of_Service[object_index]) {
|
||||||
status = Multistate_Input_Present_Value_Set(
|
status =
|
||||||
wp_data->object_instance,
|
Multistate_Input_Present_Value_Set(wp_data->
|
||||||
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;
|
||||||
@@ -490,14 +492,13 @@ bool Multistate_Input_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
@@ -538,8 +539,7 @@ void testMultistateInput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ char *Multistate_Output_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Multistate_Output_Read_Property(
|
int Multistate_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -207,8 +207,7 @@ int Multistate_Output_Read_Property(
|
|||||||
bool state = false;
|
bool state = false;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -234,7 +233,8 @@ int Multistate_Output_Read_Property(
|
|||||||
OBJECT_MULTI_STATE_OUTPUT);
|
OBJECT_MULTI_STATE_OUTPUT);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Multistate_Output_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Multistate_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
apdu_len = encode_application_unsigned(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -266,7 +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(rpdata->object_instance);
|
Multistate_Output_Instance_To_Index(rpdata->
|
||||||
|
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] ==
|
||||||
@@ -291,15 +292,16 @@ int Multistate_Output_Read_Property(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index =
|
object_index =
|
||||||
Multistate_Output_Instance_To_Index(rpdata->object_instance);
|
Multistate_Output_Instance_To_Index(rpdata->
|
||||||
|
object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Multistate_Output_Level[object_index][rpdata->array_index -
|
if (Multistate_Output_Level[object_index][rpdata->
|
||||||
1] == MULTISTATE_NULL)
|
array_index - 1] == MULTISTATE_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
present_value =
|
present_value =
|
||||||
Multistate_Output_Level[object_index][rpdata->array_index -
|
Multistate_Output_Level[object_index][rpdata->
|
||||||
1];
|
array_index - 1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_unsigned(&apdu[0],
|
encode_application_unsigned(&apdu[0],
|
||||||
present_value);
|
present_value);
|
||||||
@@ -329,8 +331,7 @@ int Multistate_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -369,8 +370,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;
|
||||||
@@ -391,15 +392,14 @@ bool Multistate_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
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--;
|
||||||
@@ -420,14 +420,13 @@ bool Multistate_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&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;
|
||||||
}
|
}
|
||||||
@@ -469,8 +468,7 @@ void testMultistateOutput(
|
|||||||
ct_test(pTest, len != 0);
|
ct_test(pTest, len != 0);
|
||||||
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
len = decode_tag_number_and_value(&apdu[0], &tag_number, &len_value);
|
||||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||||
len =
|
len = decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
||||||
decode_object_id(&apdu[len], &decoded_type, &decoded_instance);
|
|
||||||
ct_test(pTest, decoded_type == rpdata.object_type);
|
ct_test(pTest, decoded_type == rpdata.object_type);
|
||||||
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
ct_test(pTest, decoded_instance == rpdata.object_instance);
|
||||||
|
|
||||||
|
|||||||
+541
-420
File diff suppressed because it is too large
Load Diff
+150
-123
@@ -281,13 +281,15 @@ int main(
|
|||||||
/* at least one second has passed */
|
/* at least one second has passed */
|
||||||
if (current_seconds != last_seconds) {
|
if (current_seconds != last_seconds) {
|
||||||
putchar('.'); /* Just to show that time is passing... */
|
putchar('.'); /* Just to show that time is passing... */
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds -
|
||||||
|
last_seconds) * 1000));
|
||||||
address_cache_timer(current_seconds - last_seconds);
|
address_cache_timer(current_seconds - last_seconds);
|
||||||
trend_log_timer(current_seconds - last_seconds);
|
trend_log_timer(current_seconds - last_seconds);
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
/* Change the analog input PVs for testing purposes */
|
/* Change the analog input PVs for testing purposes */
|
||||||
for(iCount = 0; iCount < Analog_Input_Count(); iCount++) {
|
for (iCount = 0; iCount < Analog_Input_Count(); iCount++) {
|
||||||
Analog_Input_Present_Value_Set(iCount, iSecondsRun * (iCount + 1));
|
Analog_Input_Present_Value_Set(iCount,
|
||||||
|
iSecondsRun * (iCount + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
iSecondsRun++;
|
iSecondsRun++;
|
||||||
@@ -326,7 +328,8 @@ int main(
|
|||||||
}
|
}
|
||||||
/* at least one second has passed */
|
/* at least one second has passed */
|
||||||
if (current_seconds != last_seconds) {
|
if (current_seconds != last_seconds) {
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds -
|
||||||
|
last_seconds) * 1000));
|
||||||
address_cache_timer(current_seconds - last_seconds);
|
address_cache_timer(current_seconds - last_seconds);
|
||||||
trend_log_timer(current_seconds - last_seconds);
|
trend_log_timer(current_seconds - last_seconds);
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
@@ -341,138 +344,162 @@ int main(
|
|||||||
if (found) {
|
if (found) {
|
||||||
if (invoke_id == 0) { /* Safe to send a new request */
|
if (invoke_id == 0) { /* Safe to send a new request */
|
||||||
switch (iCount) {
|
switch (iCount) {
|
||||||
case 0: /* Pass - should read up to 1st 10 */
|
case 0: /* Pass - should read up to 1st 10 */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 1: /* Pass - should read entries 2 and 3 */
|
case 1: /* Pass - should read entries 2 and 3 */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefSeqNum = 3;
|
Request.Range.RefSeqNum = 3;
|
||||||
Request.Count = -2;
|
Request.Count = -2;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 2: /* Fail - By Time not supported */
|
case 2: /* Fail - By Time not supported */
|
||||||
Request.RequestType = RR_BY_TIME;
|
Request.RequestType = RR_BY_TIME;
|
||||||
Request.Range.RefTime.date.year = 2009;
|
Request.Range.RefTime.date.year = 2009;
|
||||||
Request.Range.RefTime.date.month = 9;
|
Request.Range.RefTime.date.month = 9;
|
||||||
Request.Range.RefTime.date.day = 23;
|
Request.Range.RefTime.date.day = 23;
|
||||||
Request.Range.RefTime.date.wday = 0xFF;
|
Request.Range.RefTime.date.wday = 0xFF;
|
||||||
Request.Range.RefTime.time.hour = 22;
|
Request.Range.RefTime.time.hour = 22;
|
||||||
Request.Range.RefTime.time.min = 23;
|
Request.Range.RefTime.time.min = 23;
|
||||||
Request.Range.RefTime.time.sec = 24;
|
Request.Range.RefTime.time.sec = 24;
|
||||||
Request.Range.RefTime.time.hundredths = 0;
|
Request.Range.RefTime.time.hundredths = 0;
|
||||||
|
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 3: /* Fail - array not supported */
|
case 3: /* Fail - array not supported */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 1;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 4: /* Fail - By Sequence not supported */
|
case 4: /* Fail - By Sequence not supported */
|
||||||
Request.RequestType = RR_BY_SEQUENCE;
|
Request.RequestType = RR_BY_SEQUENCE;
|
||||||
Request.Range.RefSeqNum = 1;
|
Request.Range.RefSeqNum = 1;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 5: /* Fail Bytime not supported and array not supported */
|
case 5: /* Fail Bytime not supported and array not supported */
|
||||||
Request.RequestType = RR_BY_TIME;
|
Request.RequestType = RR_BY_TIME;
|
||||||
Request.Range.RefTime.date.year = 2009;
|
Request.Range.RefTime.date.year = 2009;
|
||||||
Request.Range.RefTime.date.month = 9;
|
Request.Range.RefTime.date.month = 9;
|
||||||
Request.Range.RefTime.date.day = 23;
|
Request.Range.RefTime.date.day = 23;
|
||||||
Request.Range.RefTime.date.wday = 0xFF; /* Day of week unspecified */
|
Request.Range.RefTime.date.wday = 0xFF; /* Day of week unspecified */
|
||||||
Request.Range.RefTime.time.hour = 22;
|
Request.Range.RefTime.time.hour = 22;
|
||||||
Request.Range.RefTime.time.min = 23;
|
Request.Range.RefTime.time.min = 23;
|
||||||
Request.Range.RefTime.time.sec = 24;
|
Request.Range.RefTime.time.sec = 24;
|
||||||
Request.Range.RefTime.time.hundredths = 0;
|
Request.Range.RefTime.time.hundredths = 0;
|
||||||
|
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 1;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 6: /* Pass - should try to return all entries */
|
case 6: /* Pass - should try to return all entries */
|
||||||
Request.RequestType = RR_READ_ALL;
|
Request.RequestType = RR_READ_ALL;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 7: /* Fail - array not supported */
|
case 7: /* Fail - array not supported */
|
||||||
Request.RequestType = RR_READ_ALL;
|
Request.RequestType = RR_READ_ALL;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 1;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 8: /* Pass - should read 1st 1 */
|
case 8: /* Pass - should read 1st 1 */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 1;
|
Request.Count = 1;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 9: /* Pass - should read 1st 2 */
|
case 9: /* Pass - should read 1st 2 */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefIndex = 1;
|
Request.Range.RefIndex = 1;
|
||||||
Request.Count = 2;
|
Request.Count = 2;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 10: /* Pass - should read 2nd and 3rd */
|
case 10: /* Pass - should read 2nd and 3rd */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefIndex = 2;
|
Request.Range.RefIndex = 2;
|
||||||
Request.Count = 2;
|
Request.Count = 2;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 11: /* Pass - should read 2nd up to 11th */
|
case 11: /* Pass - should read 2nd up to 11th */
|
||||||
Request.RequestType = RR_BY_POSITION;
|
Request.RequestType = RR_BY_POSITION;
|
||||||
Request.Range.RefIndex = 2;
|
Request.Range.RefIndex = 2;
|
||||||
Request.Count = 10;
|
Request.Count = 10;
|
||||||
Request.object_type = OBJECT_DEVICE;
|
Request.object_type = OBJECT_DEVICE;
|
||||||
Request.object_instance = Target_Device_Object_Instance;
|
Request.object_instance =
|
||||||
Request.object_property = PROP_DEVICE_ADDRESS_BINDING;
|
Target_Device_Object_Instance;
|
||||||
Request.array_index = 0;
|
Request.object_property =
|
||||||
break;
|
PROP_DEVICE_ADDRESS_BINDING;
|
||||||
}
|
Request.array_index = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
invoke_id =
|
invoke_id =
|
||||||
Send_ReadRange_Request(Target_Device_Object_Instance,
|
Send_ReadRange_Request(Target_Device_Object_Instance,
|
||||||
|
|||||||
@@ -184,4 +184,4 @@ int main(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @} */ /* End group ServerDemo */
|
/* @} *//* End group ServerDemo */
|
||||||
|
|||||||
@@ -160,8 +160,7 @@ int main(
|
|||||||
}
|
}
|
||||||
if (cov_data.monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
|
if (cov_data.monitoredObjectIdentifier.type >= MAX_BACNET_OBJECT_TYPE) {
|
||||||
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
|
fprintf(stderr, "object-type=%u - it must be less than %u\r\n",
|
||||||
cov_data.monitoredObjectIdentifier.type,
|
cov_data.monitoredObjectIdentifier.type, MAX_BACNET_OBJECT_TYPE);
|
||||||
MAX_BACNET_OBJECT_TYPE);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
if (cov_data.monitoredObjectIdentifier.instance > BACNET_MAX_INSTANCE) {
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ extern "C" {
|
|||||||
unsigned apdu_len);
|
unsigned apdu_len);
|
||||||
|
|
||||||
int rr_address_list_encode(
|
int rr_address_list_encode(
|
||||||
uint8_t *apdu,
|
uint8_t * apdu,
|
||||||
BACNET_READ_RANGE_DATA *pRequest);
|
BACNET_READ_RANGE_DATA * pRequest);
|
||||||
|
|
||||||
void address_set_device_TTL(
|
void address_set_device_TTL(
|
||||||
uint32_t device_id,
|
uint32_t device_id,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ extern "C" {
|
|||||||
uint32_t instance);
|
uint32_t instance);
|
||||||
|
|
||||||
int Analog_Input_Read_Property(
|
int Analog_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
bool Analog_Input_Write_Property(
|
bool Analog_Input_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ extern "C" {
|
|||||||
void);
|
void);
|
||||||
|
|
||||||
int Analog_Output_Read_Property(
|
int Analog_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
bool Analog_Output_Write_Property(
|
bool Analog_Output_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
bool apdu_service_supported_to_index(
|
bool apdu_service_supported_to_index(
|
||||||
BACNET_SERVICES_SUPPORTED service_supported,
|
BACNET_SERVICES_SUPPORTED service_supported,
|
||||||
size_t *index,
|
size_t * index,
|
||||||
bool *bIsConfirmed );
|
bool * bIsConfirmed);
|
||||||
|
|
||||||
|
|
||||||
void apdu_set_error_handler(
|
void apdu_set_error_handler(
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ extern "C" {
|
|||||||
uint32_t object_instance);
|
uint32_t object_instance);
|
||||||
|
|
||||||
int Analog_Value_Read_Property(
|
int Analog_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Analog_Value_Write_Property(
|
bool Analog_Value_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ typedef struct {
|
|||||||
* to an object inside this Device.
|
* to an object inside this Device.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BACNET_OBJECT_ID deviceIndentifier; /**< Optional, for external device. */
|
BACNET_OBJECT_ID deviceIndentifier; /**< Optional, for external device. */
|
||||||
BACNET_OBJECT_ID objectIdentifier;
|
BACNET_OBJECT_ID objectIdentifier;
|
||||||
} BACNET_DEVICE_OBJECT_REFERENCE;
|
} BACNET_DEVICE_OBJECT_REFERENCE;
|
||||||
|
|
||||||
|
|||||||
@@ -636,10 +636,10 @@ typedef enum {
|
|||||||
UNITS_SQUARE_METERS_PER_NEWTON = 185,
|
UNITS_SQUARE_METERS_PER_NEWTON = 185,
|
||||||
UNITS_WATTS_PER_METER_PER_DEGREE_KELVIN = 189,
|
UNITS_WATTS_PER_METER_PER_DEGREE_KELVIN = 189,
|
||||||
UNITS_WATTS_PER_SQUARE_METER_DEGREE_KELVIN = 141,
|
UNITS_WATTS_PER_SQUARE_METER_DEGREE_KELVIN = 141,
|
||||||
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */
|
/* Enumerated values 0-255 are reserved for definition by ASHRAE. */
|
||||||
/* Enumerated values 256-65535 may be used by others subject to */
|
/* Enumerated values 256-65535 may be used by others subject to */
|
||||||
/* the procedures and constraints described in Clause 23. */
|
/* the procedures and constraints described in Clause 23. */
|
||||||
/* The last enumeration used in this version is 189. */
|
/* The last enumeration used in this version is 189. */
|
||||||
MAX_UNITS = 190
|
MAX_UNITS = 190
|
||||||
} BACNET_ENGINEERING_UNITS;
|
} BACNET_ENGINEERING_UNITS;
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* handling for read property service */
|
/* handling for read property service */
|
||||||
int bacfile_read_property(
|
int bacfile_read_property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
/* handling for write property service */
|
/* handling for write property service */
|
||||||
bool bacfile_write_property(
|
bool bacfile_write_property(
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ extern "C" {
|
|||||||
BACNET_PROPERTY_VALUE * value_list);
|
BACNET_PROPERTY_VALUE * value_list);
|
||||||
|
|
||||||
int Binary_Input_Read_Property(
|
int Binary_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Binary_Input_Write_Property(
|
bool Binary_Input_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DLBIP BACnet/IP DataLink Network Layer
|
/** @defgroup DLBIP BACnet/IP DataLink Network Layer
|
||||||
* @ingroup DataLink
|
* @ingroup DataLink
|
||||||
* Implementation of the Network Layer using BACnet/IP as the transport, as
|
* Implementation of the Network Layer using BACnet/IP as the transport, as
|
||||||
@@ -131,5 +130,4 @@ extern "C" {
|
|||||||
* DataLink level by serving as the implementation of the function templates.
|
* DataLink level by serving as the implementation of the function templates.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ extern "C" {
|
|||||||
char *new_name);
|
char *new_name);
|
||||||
|
|
||||||
int Binary_Output_Read_Property(
|
int Binary_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Binary_Output_Write_Property(
|
bool Binary_Output_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ extern "C" {
|
|||||||
void);
|
void);
|
||||||
|
|
||||||
int Binary_Value_Read_Property(
|
int Binary_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Binary_Value_Write_Property(
|
bool Binary_Value_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DSCOV Data Sharing - Change of Value Service (DS-COV)
|
/** @defgroup DSCOV Data Sharing - Change of Value Service (DS-COV)
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 13.1 Change of Value Reporting <br>
|
* 13.1 Change of Value Reporting <br>
|
||||||
@@ -140,5 +139,4 @@ extern "C" {
|
|||||||
* devices or to operators or logging devices. Any object, proprietary or
|
* devices or to operators or logging devices. Any object, proprietary or
|
||||||
* standard, may support COV reporting at the implementor's option.
|
* standard, may support COV reporting at the implementor's option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
#define datalink_get_broadcast_address bip_get_broadcast_address
|
#define datalink_get_broadcast_address bip_get_broadcast_address
|
||||||
#define datalink_get_my_address bip_get_my_address
|
#define datalink_get_my_address bip_get_my_address
|
||||||
|
|
||||||
#else /* Ie, BACDL_ALL */
|
#else /* Ie, BACDL_ALL */
|
||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
|
|
||||||
#define MAX_HEADER (8)
|
#define MAX_HEADER (8)
|
||||||
@@ -118,7 +118,6 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @defgroup DataLink The BACnet Network (DataLink) Layer
|
/** @defgroup DataLink The BACnet Network (DataLink) Layer
|
||||||
* <b>6 THE NETWORK LAYER </b><br>
|
* <b>6 THE NETWORK LAYER </b><br>
|
||||||
* The purpose of the BACnet network layer is to provide the means by which
|
* The purpose of the BACnet network layer is to provide the means by which
|
||||||
@@ -140,13 +139,10 @@ 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
|
||||||
* at runtime.
|
* at runtime.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -97,14 +97,11 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup RDMS Remote Device Management Services BIBBs
|
/** @defgroup RDMS Remote Device Management Services BIBBs
|
||||||
* These device management BIBBs prescribe the BACnet capabilities required
|
* These device management BIBBs prescribe the BACnet capabilities required
|
||||||
* to interoperably perform the device management functions enumerated in
|
* to interoperably perform the device management functions enumerated in
|
||||||
* 22.2.1.5 for the BACnet devices defined therein.
|
* 22.2.1.5 for the BACnet devices defined therein.
|
||||||
*/
|
*//** @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
|
||||||
@@ -118,5 +115,4 @@ extern "C" {
|
|||||||
* DeviceCommunicationControl or, if supported, ReinitializeDevice service,
|
* DeviceCommunicationControl or, if supported, ReinitializeDevice service,
|
||||||
* not by time.
|
* not by time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ typedef bool(
|
|||||||
* == 1) to indicate no more objects found.
|
* == 1) to indicate no more objects found.
|
||||||
*/
|
*/
|
||||||
typedef unsigned (
|
typedef unsigned (
|
||||||
*object_iterate_function)(
|
*object_iterate_function) (
|
||||||
unsigned current_index);
|
unsigned current_index);
|
||||||
|
|
||||||
|
|
||||||
@@ -118,9 +118,10 @@ extern "C" {
|
|||||||
void);
|
void);
|
||||||
|
|
||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA *rd_data);
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
||||||
|
|
||||||
BACNET_REINITIALIZED_STATE Device_Reinitialized_State(void);
|
BACNET_REINITIALIZED_STATE Device_Reinitialized_State(
|
||||||
|
void);
|
||||||
|
|
||||||
rr_info_function Device_Objects_RR_Info(
|
rr_info_function Device_Objects_RR_Info(
|
||||||
BACNET_OBJECT_TYPE object_type);
|
BACNET_OBJECT_TYPE object_type);
|
||||||
@@ -146,7 +147,8 @@ extern "C" {
|
|||||||
int *object_type,
|
int *object_type,
|
||||||
uint32_t * instance);
|
uint32_t * instance);
|
||||||
|
|
||||||
unsigned Device_Count(void);
|
unsigned Device_Count(
|
||||||
|
void);
|
||||||
uint32_t Device_Index_To_Instance(
|
uint32_t Device_Index_To_Instance(
|
||||||
unsigned index);
|
unsigned index);
|
||||||
char *Device_Name(
|
char *Device_Name(
|
||||||
@@ -221,19 +223,18 @@ extern "C" {
|
|||||||
uint32_t object_instance);
|
uint32_t object_instance);
|
||||||
|
|
||||||
int Device_Read_Property(
|
int Device_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
bool Device_Write_Property(
|
bool Device_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
bool DeviceGetRRInfo(
|
bool DeviceGetRRInfo(
|
||||||
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
RR_PROP_INFO *pInfo); /* Where to put the information */
|
RR_PROP_INFO * pInfo); /* Where to put the information */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @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
|
||||||
@@ -243,15 +244,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
|
||||||
@@ -266,6 +263,4 @@ extern "C" {
|
|||||||
* eg Object_Read_Property() for the RP handler.
|
* eg Object_Read_Property() for the RP handler.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -209,14 +209,11 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup ALMEVNT Alarm and Event Management BIBBs
|
/** @defgroup ALMEVNT Alarm and Event Management BIBBs
|
||||||
* 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
|
||||||
@@ -233,9 +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
|
||||||
@@ -246,5 +241,4 @@ extern "C" {
|
|||||||
* This service may be used in conjunction with either the
|
* This service may be used in conjunction with either the
|
||||||
* ConfirmedEventNotification service or the UnconfirmedEventNotification service.
|
* ConfirmedEventNotification service or the UnconfirmedEventNotification service.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif /* BACNET_EVENT_H_ */
|
#endif /* BACNET_EVENT_H_ */
|
||||||
|
|||||||
@@ -98,14 +98,14 @@ extern "C" {
|
|||||||
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
BACNET_CONFIRMED_SERVICE_DATA * service_data);
|
||||||
|
|
||||||
bool WPValidateString(
|
bool WPValidateString(
|
||||||
BACNET_APPLICATION_DATA_VALUE *pValue,
|
BACNET_APPLICATION_DATA_VALUE * pValue,
|
||||||
int iMaxLen,
|
int iMaxLen,
|
||||||
bool bEmptyAllowed,
|
bool bEmptyAllowed,
|
||||||
BACNET_ERROR_CLASS * pErrorClass,
|
BACNET_ERROR_CLASS * pErrorClass,
|
||||||
BACNET_ERROR_CODE * pErrorCode);
|
BACNET_ERROR_CODE * pErrorCode);
|
||||||
|
|
||||||
bool WPValidateArgType(
|
bool WPValidateArgType(
|
||||||
BACNET_APPLICATION_DATA_VALUE *pValue,
|
BACNET_APPLICATION_DATA_VALUE * pValue,
|
||||||
uint8_t ucExpectedType,
|
uint8_t ucExpectedType,
|
||||||
BACNET_ERROR_CLASS * pErrorClass,
|
BACNET_ERROR_CLASS * pErrorClass,
|
||||||
BACNET_ERROR_CODE * pErrorCode);
|
BACNET_ERROR_CODE * pErrorCode);
|
||||||
@@ -256,10 +256,7 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup MISCHNDLR Miscellaneous Handler Utilities
|
/** @defgroup MISCHNDLR Miscellaneous Handler Utilities
|
||||||
* Various utilities and functions to support the Handlers.
|
* Various utilities and functions to support the Handlers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ extern "C" {
|
|||||||
void);
|
void);
|
||||||
|
|
||||||
int Load_Control_Read_Property(
|
int Load_Control_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Load_Control_Write_Property(
|
bool Load_Control_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* ReadProperty service support */
|
/* ReadProperty service support */
|
||||||
int Lighting_Output_Read_Property(
|
int Lighting_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
/* WriteProperty service support */
|
/* WriteProperty service support */
|
||||||
bool Lighting_Output_Write_Property(
|
bool Lighting_Output_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ extern "C" {
|
|||||||
void);
|
void);
|
||||||
|
|
||||||
int Life_Safety_Point_Read_Property(
|
int Life_Safety_Point_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Life_Safety_Point_Write_Property(
|
bool Life_Safety_Point_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ extern "C" {
|
|||||||
uint32_t instance);
|
uint32_t instance);
|
||||||
|
|
||||||
int Multistate_Input_Read_Property(
|
int Multistate_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Multistate_Input_Write_Property(
|
bool Multistate_Input_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ extern "C" {
|
|||||||
void);
|
void);
|
||||||
|
|
||||||
int Multistate_Output_Read_Property(
|
int Multistate_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Multistate_Output_Write_Property(
|
bool Multistate_Output_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ typedef struct BACnet_Reinitialize_Device_Data {
|
|||||||
BACNET_ERROR_CODE error_code;
|
BACNET_ERROR_CODE error_code;
|
||||||
} BACNET_REINITIALIZE_DEVICE_DATA;
|
} BACNET_REINITIALIZE_DEVICE_DATA;
|
||||||
|
|
||||||
typedef bool (
|
typedef bool(
|
||||||
*reinitialize_device_function) (
|
*reinitialize_device_function) (
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA *rd_data);
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -83,7 +83,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DMRD Device Management-ReinitializeDevice (DM-RD)
|
/** @defgroup DMRD Device Management-ReinitializeDevice (DM-RD)
|
||||||
* @ingroup RDMS
|
* @ingroup RDMS
|
||||||
* 16.4 ReinitializeDevice Service <br>
|
* 16.4 ReinitializeDevice Service <br>
|
||||||
@@ -98,5 +97,4 @@ extern "C" {
|
|||||||
* to executing the service.
|
* to executing the service.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ typedef enum {
|
|||||||
|
|
||||||
#define RR_OVERHEAD 16
|
#define RR_OVERHEAD 16
|
||||||
#define RR_1ST_SEQ_OVERHEAD 5
|
#define RR_1ST_SEQ_OVERHEAD 5
|
||||||
#define RR_INDEX_OVERHEAD 3 /* or 5 if paranoid */
|
#define RR_INDEX_OVERHEAD 3 /* or 5 if paranoid */
|
||||||
|
|
||||||
/** Define pointer to function type for handling ReadRange request.
|
/** Define pointer to function type for handling ReadRange request.
|
||||||
This function will take the following parameters:
|
This function will take the following parameters:
|
||||||
@@ -112,9 +112,10 @@ 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 (*rr_handler_function) (
|
typedef int (
|
||||||
uint8_t *apdu,
|
*rr_handler_function) (
|
||||||
BACNET_READ_RANGE_DATA *pRequest);
|
uint8_t * apdu,
|
||||||
|
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 */
|
||||||
@@ -122,7 +123,7 @@ typedef int (*rr_handler_function) (
|
|||||||
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.
|
||||||
@@ -131,9 +132,10 @@ 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 (*rr_info_function) (
|
typedef bool(
|
||||||
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
*rr_info_function) (
|
||||||
RR_PROP_INFO *pInfo); /* Where to write the response to */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
|
RR_PROP_INFO * pInfo); /* Where to write the response to */
|
||||||
|
|
||||||
int rr_encode_apdu(
|
int rr_encode_apdu(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
@@ -176,4 +178,3 @@ uint8_t Send_ReadRange_Request(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,11 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct ring_buffer_t {
|
struct ring_buffer_t {
|
||||||
uint8_t *data; /* block of memory or array of data */
|
uint8_t *data; /* block of memory or array of data */
|
||||||
unsigned element_size; /* how many bytes for each chunk */
|
unsigned element_size; /* how many bytes for each chunk */
|
||||||
unsigned element_count; /* number of chunks of data */
|
unsigned element_count; /* number of chunks of data */
|
||||||
unsigned head; /* where the writes go */
|
unsigned head; /* where the writes go */
|
||||||
unsigned tail; /* where the reads come from */
|
unsigned tail; /* where the reads come from */
|
||||||
};
|
};
|
||||||
typedef struct ring_buffer_t RING_BUFFER;
|
typedef struct ring_buffer_t RING_BUFFER;
|
||||||
|
|
||||||
@@ -55,9 +55,9 @@ typedef struct ring_buffer_t RING_BUFFER;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
unsigned Ringbuf_Count (
|
unsigned Ringbuf_Count(
|
||||||
RING_BUFFER const *b);
|
RING_BUFFER const *b);
|
||||||
bool Ringbuf_Full (
|
bool Ringbuf_Full(
|
||||||
RING_BUFFER const *b);
|
RING_BUFFER const *b);
|
||||||
bool Ringbuf_Empty(
|
bool Ringbuf_Empty(
|
||||||
RING_BUFFER const *b);
|
RING_BUFFER const *b);
|
||||||
@@ -67,13 +67,13 @@ extern "C" {
|
|||||||
RING_BUFFER * b);
|
RING_BUFFER * b);
|
||||||
bool Ringbuf_Put(
|
bool Ringbuf_Put(
|
||||||
RING_BUFFER * b, /* ring buffer structure */
|
RING_BUFFER * b, /* ring buffer structure */
|
||||||
uint8_t *data_element); /* one element to add to the ring */
|
uint8_t * data_element); /* one element to add to the ring */
|
||||||
uint8_t *Ringbuf_Alloc(
|
uint8_t *Ringbuf_Alloc(
|
||||||
RING_BUFFER *b);
|
RING_BUFFER * b);
|
||||||
/* Note: element_count must be a power of two */
|
/* Note: element_count must be a power of two */
|
||||||
void Ringbuf_Init(
|
void Ringbuf_Init(
|
||||||
RING_BUFFER * b, /* ring buffer structure */
|
RING_BUFFER * b, /* ring buffer structure */
|
||||||
uint8_t *data, /* data block or array of data */
|
uint8_t * data, /* data block or array of data */
|
||||||
unsigned element_size, /* size of one element in the data block */
|
unsigned element_size, /* size of one element in the data block */
|
||||||
unsigned element_count); /* number of elements in the data block */
|
unsigned element_count); /* number of elements in the data block */
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ struct BACnet_Read_Access_Data;
|
|||||||
*/
|
*/
|
||||||
typedef int (
|
typedef int (
|
||||||
*read_property_function) (
|
*read_property_function) (
|
||||||
BACNET_READ_PROPERTY_DATA *rp_data);
|
BACNET_READ_PROPERTY_DATA * rp_data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -106,7 +106,7 @@ extern "C" {
|
|||||||
int rp_ack_fully_decode_service_request(
|
int rp_ack_fully_decode_service_request(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int apdu_len,
|
int apdu_len,
|
||||||
struct BACnet_Read_Access_Data * read_access_data);
|
struct BACnet_Read_Access_Data *read_access_data);
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#include "ctest.h"
|
#include "ctest.h"
|
||||||
@@ -131,19 +131,15 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DataShare Data Sharing BIBBs
|
/** @defgroup DataShare Data Sharing BIBBs
|
||||||
* These BIBBs prescribe the BACnet capabilities required to interoperably
|
* These BIBBs prescribe the BACnet capabilities required to interoperably
|
||||||
* perform the data sharing functions enumerated in 22.2.1.1 for the BACnet
|
* perform the data sharing functions enumerated in 22.2.1.1 for the BACnet
|
||||||
* devices defined therein.
|
* devices defined therein.
|
||||||
*/
|
*//** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
|
||||||
|
|
||||||
/** @defgroup DSRP Data Sharing -Read Property Service (DS-RP)
|
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 15.5 ReadProperty Service <br>
|
* 15.5 ReadProperty Service <br>
|
||||||
* 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
|
||||||
* value of one property of one BACnet Object. This service allows read access
|
* value of one property of one BACnet Object. This service allows read access
|
||||||
* to any property of any object, whether a BACnet-defined object or not.
|
* to any property of any object, whether a BACnet-defined object or not.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ struct special_property_list_t {
|
|||||||
typedef void (
|
typedef void (
|
||||||
*rpm_object_property_lists_function) (
|
*rpm_object_property_lists_function) (
|
||||||
BACNET_OBJECT_TYPE object_type,
|
BACNET_OBJECT_TYPE object_type,
|
||||||
struct special_property_list_t *pPropertyList);
|
struct special_property_list_t * pPropertyList);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -201,7 +201,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DSRPM Data Sharing -Read Property Multiple Service (DS-RPM)
|
/** @defgroup DSRPM Data Sharing -Read Property Multiple Service (DS-RPM)
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 15.7 ReadPropertyMultiple Service <br>
|
* 15.7 ReadPropertyMultiple Service <br>
|
||||||
@@ -214,5 +213,4 @@ extern "C" {
|
|||||||
* A 'Read Access Specification' with the property identifier ALL can be used to
|
* A 'Read Access Specification' with the property identifier ALL can be used to
|
||||||
* learn the implemented properties of an object along with their values.
|
* learn the implemented properties of an object along with their values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h> /* for time_t */
|
#include <time.h> /* for time_t */
|
||||||
#include "bacdef.h"
|
#include "bacdef.h"
|
||||||
#include "cov.h"
|
#include "cov.h"
|
||||||
#include "rp.h"
|
#include "rp.h"
|
||||||
@@ -38,17 +38,17 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* Error code for Trend Log storage */
|
/* Error code for Trend Log storage */
|
||||||
typedef struct tl_error {
|
typedef struct tl_error {
|
||||||
uint16_t usClass;
|
uint16_t usClass;
|
||||||
uint16_t usCode;
|
uint16_t usCode;
|
||||||
} TL_ERROR;
|
} TL_ERROR;
|
||||||
|
|
||||||
/* Bit string of up to 32 bits for Trend Log storage */
|
/* Bit string of up to 32 bits for Trend Log storage */
|
||||||
|
|
||||||
typedef struct tl_bits {
|
typedef struct tl_bits {
|
||||||
uint8_t ucLen; /* bytes used in upper nibble/bits free in lower nibble */
|
uint8_t ucLen; /* bytes used in upper nibble/bits free in lower nibble */
|
||||||
uint8_t ucStore[4];
|
uint8_t ucStore[4];
|
||||||
} TL_BITS;
|
} TL_BITS;
|
||||||
|
|
||||||
/* Storage structure for Trend Log data
|
/* Storage structure for Trend Log data
|
||||||
*
|
*
|
||||||
@@ -60,49 +60,49 @@ typedef struct tl_bits {
|
|||||||
* logging capacity as possible every little byte counts!
|
* logging capacity as possible every little byte counts!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct tl_data_record {
|
typedef struct tl_data_record {
|
||||||
time_t tTimeStamp; /* When the event occurred */
|
time_t tTimeStamp; /* When the event occurred */
|
||||||
uint8_t ucRecType; /* What type of Event */
|
uint8_t ucRecType; /* What type of Event */
|
||||||
uint8_t ucStatus; /* Optional Status for read value in b0-b2, b7 = 1 if status is used */
|
uint8_t ucStatus; /* Optional Status for read value in b0-b2, b7 = 1 if status is used */
|
||||||
union {
|
union {
|
||||||
uint8_t ucLogStatus; /* Change of log state flags */
|
uint8_t ucLogStatus; /* Change of log state flags */
|
||||||
uint8_t ucBoolean; /* Stored boolean value */
|
uint8_t ucBoolean; /* Stored boolean value */
|
||||||
float fReal; /* Stored floating point value */
|
float fReal; /* Stored floating point value */
|
||||||
uint32_t ulEnum; /* Stored enumerated value - max 32 bits */
|
uint32_t ulEnum; /* Stored enumerated value - max 32 bits */
|
||||||
uint32_t ulUValue; /* Stored unsigned value - max 32 bits */
|
uint32_t ulUValue; /* Stored unsigned value - max 32 bits */
|
||||||
int32_t lSValue; /* Stored signed value - max 32 bits */
|
int32_t lSValue; /* Stored signed value - max 32 bits */
|
||||||
TL_BITS Bits; /* Stored bitstring - max 32 bits */
|
TL_BITS Bits; /* Stored bitstring - max 32 bits */
|
||||||
TL_ERROR Error; /* Two part error class/code combo */
|
TL_ERROR Error; /* Two part error class/code combo */
|
||||||
float fTime; /* Interval value for change of time - seconds */
|
float fTime; /* Interval value for change of time - seconds */
|
||||||
} Datum;
|
} Datum;
|
||||||
} TL_DATA_REC;
|
} TL_DATA_REC;
|
||||||
|
|
||||||
#define TL_T_START_WILD 1 /* Start time is wild carded */
|
#define TL_T_START_WILD 1 /* Start time is wild carded */
|
||||||
#define TL_T_STOP_WILD 2 /* Stop Time is wild carded */
|
#define TL_T_STOP_WILD 2 /* Stop Time is wild carded */
|
||||||
|
|
||||||
#define TL_MAX_ENTRIES 1000 /* Entries per datalog */
|
#define TL_MAX_ENTRIES 1000 /* Entries per datalog */
|
||||||
|
|
||||||
/* Structure containing config and status info for a Trend Log */
|
/* Structure containing config and status info for a Trend Log */
|
||||||
|
|
||||||
typedef struct tl_log_info {
|
typedef struct tl_log_info {
|
||||||
bool bEnable; /* Trend log is active when this is true */
|
bool bEnable; /* Trend log is active when this is true */
|
||||||
BACNET_DATE_TIME StartTime; /* BACnet format start time */
|
BACNET_DATE_TIME StartTime; /* BACnet format start time */
|
||||||
time_t tStartTime; /* Local time working copy of start time */
|
time_t tStartTime; /* Local time working copy of start time */
|
||||||
BACNET_DATE_TIME StopTime; /* BACnet format stop time */
|
BACNET_DATE_TIME StopTime; /* BACnet format stop time */
|
||||||
time_t tStopTime; /* Local time working copy of stop time */
|
time_t tStopTime; /* Local time working copy of stop time */
|
||||||
uint8_t ucTimeFlags; /* Shorthand info on times */
|
uint8_t ucTimeFlags; /* Shorthand info on times */
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE Source; /* Where the data comes from */
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE Source; /* Where the data comes from */
|
||||||
uint32_t ulLogInterval; /* Time between entries in seconds */
|
uint32_t ulLogInterval; /* Time between entries in seconds */
|
||||||
bool bStopWhenFull; /* Log halts when full if true */
|
bool bStopWhenFull; /* Log halts when full if true */
|
||||||
uint32_t ulRecordCount; /* Count of items currently in the buffer */
|
uint32_t ulRecordCount; /* Count of items currently in the buffer */
|
||||||
uint32_t ulTotalRecordCount; /* Count of all items that have ever been inserted into the buffer */
|
uint32_t ulTotalRecordCount; /* Count of all items that have ever been inserted into the buffer */
|
||||||
BACNET_LOGGING_TYPE LoggingType; /* Polled/cov/triggered */
|
BACNET_LOGGING_TYPE LoggingType; /* Polled/cov/triggered */
|
||||||
bool bAlignIntervals; /* If true align to the clock */
|
bool bAlignIntervals; /* If true align to the clock */
|
||||||
uint32_t ulIntervalOffset; /* Offset from start of period for taking reading in seconds */
|
uint32_t ulIntervalOffset; /* Offset from start of period for taking reading in seconds */
|
||||||
bool bTrigger; /* Set to 1 to cause a reading to be taken */
|
bool bTrigger; /* Set to 1 to cause a reading to be taken */
|
||||||
int iIndex; /* Current insertion point */
|
int iIndex; /* Current insertion point */
|
||||||
time_t tLastDataTime;
|
time_t tLastDataTime;
|
||||||
} TL_LOG_INFO;
|
} TL_LOG_INFO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data types associated with a BACnet Log Record. We use these for managing the
|
* Data types associated with a BACnet Log Record. We use these for managing the
|
||||||
@@ -120,7 +120,7 @@ typedef struct tl_log_info {
|
|||||||
#define TL_TYPE_NULL 7
|
#define TL_TYPE_NULL 7
|
||||||
#define TL_TYPE_ERROR 8
|
#define TL_TYPE_ERROR 8
|
||||||
#define TL_TYPE_DELTA 9
|
#define TL_TYPE_DELTA 9
|
||||||
#define TL_TYPE_ANY 10 /* We don't support this particular can of worms! */
|
#define TL_TYPE_ANY 10 /* We don't support this particular can of worms! */
|
||||||
|
|
||||||
|
|
||||||
void Trend_Log_Property_Lists(
|
void Trend_Log_Property_Lists(
|
||||||
@@ -143,7 +143,7 @@ typedef struct tl_log_info {
|
|||||||
uint32_t object_instance);
|
uint32_t object_instance);
|
||||||
|
|
||||||
int Trend_Log_Read_Property(
|
int Trend_Log_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
|
|
||||||
bool Trend_Log_Write_Property(
|
bool Trend_Log_Write_Property(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
@@ -159,39 +159,39 @@ typedef struct tl_log_info {
|
|||||||
int iLog);
|
int iLog);
|
||||||
|
|
||||||
time_t TL_BAC_Time_To_Local(
|
time_t TL_BAC_Time_To_Local(
|
||||||
BACNET_DATE_TIME *SourceTime);
|
BACNET_DATE_TIME * SourceTime);
|
||||||
|
|
||||||
void TL_Local_Time_To_BAC(
|
void TL_Local_Time_To_BAC(
|
||||||
BACNET_DATE_TIME *DestTime,
|
BACNET_DATE_TIME * DestTime,
|
||||||
time_t SourceTime);
|
time_t SourceTime);
|
||||||
|
|
||||||
int TL_encode_entry(
|
int TL_encode_entry(
|
||||||
uint8_t *apdu,
|
uint8_t * apdu,
|
||||||
int iLog,
|
int iLog,
|
||||||
int iEntry);
|
int iEntry);
|
||||||
|
|
||||||
int TL_encode_by_position(
|
int TL_encode_by_position(
|
||||||
uint8_t *apdu,
|
uint8_t * apdu,
|
||||||
BACNET_READ_RANGE_DATA *pRequest);
|
BACNET_READ_RANGE_DATA * pRequest);
|
||||||
|
|
||||||
int TL_encode_by_sequence(
|
int TL_encode_by_sequence(
|
||||||
uint8_t *apdu,
|
uint8_t * apdu,
|
||||||
BACNET_READ_RANGE_DATA *pRequest);
|
BACNET_READ_RANGE_DATA * pRequest);
|
||||||
|
|
||||||
int TL_encode_by_time(
|
int TL_encode_by_time(
|
||||||
uint8_t *apdu,
|
uint8_t * apdu,
|
||||||
BACNET_READ_RANGE_DATA *pRequest);
|
BACNET_READ_RANGE_DATA * pRequest);
|
||||||
|
|
||||||
bool TrendLogGetRRInfo(
|
bool TrendLogGetRRInfo(
|
||||||
BACNET_READ_RANGE_DATA *pRequest, /* Info on the request */
|
BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
|
||||||
RR_PROP_INFO *pInfo); /* Where to put the information */
|
RR_PROP_INFO * pInfo); /* Where to put the information */
|
||||||
|
|
||||||
int rr_trend_log_encode(
|
int rr_trend_log_encode(
|
||||||
uint8_t *apdu,
|
uint8_t * apdu,
|
||||||
BACNET_READ_RANGE_DATA *pRequest);
|
BACNET_READ_RANGE_DATA * pRequest);
|
||||||
|
|
||||||
void trend_log_timer(
|
void trend_log_timer(
|
||||||
uint16_t uSeconds);
|
uint16_t uSeconds);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ extern "C" {
|
|||||||
/* use these in tandem */
|
/* use these in tandem */
|
||||||
uint8_t tsm_next_free_invokeID(
|
uint8_t tsm_next_free_invokeID(
|
||||||
void);
|
void);
|
||||||
void tsm_invokeID_set(uint8_t invokeID);
|
void tsm_invokeID_set(
|
||||||
|
uint8_t invokeID);
|
||||||
/* returns the same invoke ID that was given */
|
/* returns the same invoke ID that was given */
|
||||||
void tsm_set_confirmed_unsegmented_transaction(
|
void tsm_set_confirmed_unsegmented_transaction(
|
||||||
uint8_t invokeID,
|
uint8_t invokeID,
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DMDOB Device Management-Dynamic Object Binding (DM-DOB)
|
/** @defgroup DMDOB Device Management-Dynamic Object Binding (DM-DOB)
|
||||||
* @ingroup RDMS
|
* @ingroup RDMS
|
||||||
* 16.9 Who-Has and I-Have Services <br>
|
* 16.9 Who-Has and I-Have Services <br>
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DMDDB Device Management-Dynamic Device Binding (DM-DDB)
|
/** @defgroup DMDDB Device Management-Dynamic Device Binding (DM-DDB)
|
||||||
* @ingroup RDMS
|
* @ingroup RDMS
|
||||||
* 16.10 Who-Is and I-Am Services <br>
|
* 16.10 Who-Is and I-Am Services <br>
|
||||||
@@ -87,5 +86,4 @@ extern "C" {
|
|||||||
* issuing the request is on the local network, or from the NPCI if the device
|
* issuing the request is on the local network, or from the NPCI if the device
|
||||||
* is on a remote network.
|
* is on a remote network.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ extern "C" {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/** @defgroup DSWP Data Sharing - Write Property Service (DS-WP)
|
/** @defgroup DSWP Data Sharing - Write Property Service (DS-WP)
|
||||||
* @ingroup DataShare
|
* @ingroup DataShare
|
||||||
* 15.9 WriteProperty Service <br>
|
* 15.9 WriteProperty Service <br>
|
||||||
@@ -114,5 +113,4 @@ extern "C" {
|
|||||||
* to modify a restricted property shall result in the return of an error of
|
* to modify a restricted property shall result in the return of an error of
|
||||||
* 'Error Class' PROPERTY and 'Error Code' WRITE_ACCESS_DENIED.
|
* 'Error Class' PROPERTY and 'Error Code' WRITE_ACCESS_DENIED.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -143,15 +143,14 @@ void Analog_Input_Present_Value_Set(
|
|||||||
/* return apdu length, or -1 on error */
|
/* return apdu length, or -1 on error */
|
||||||
/* assumption - object has already exists */
|
/* assumption - object has already exists */
|
||||||
int Analog_Input_Read_Property(
|
int Analog_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
BACNET_CHARACTER_STRING char_string;
|
BACNET_CHARACTER_STRING char_string;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -205,8 +204,7 @@ int Analog_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ char *Analog_Value_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Analog_Value_Read_Property(
|
int Analog_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
@@ -195,8 +195,7 @@ int Analog_Value_Read_Property(
|
|||||||
#endif
|
#endif
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -236,7 +235,8 @@ int Analog_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
#if 0
|
#if 0
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Value_Out_Of_Service[object_index];
|
state = Analog_Value_Out_Of_Service[object_index];
|
||||||
#endif
|
#endif
|
||||||
apdu_len = encode_application_boolean(&apdu[0], false);
|
apdu_len = encode_application_boolean(&apdu[0], false);
|
||||||
@@ -253,7 +253,8 @@ int Analog_Value_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. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->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 (Present_Value[object_index][i] == ANALOG_LEVEL_NULL)
|
if (Present_Value[object_index][i] == ANALOG_LEVEL_NULL)
|
||||||
@@ -282,7 +283,8 @@ int Analog_Value_Read_Property(
|
|||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Present_Value[object_index][rpdata->array_index - 1];
|
Present_Value[object_index][rpdata->array_index -
|
||||||
|
1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -353,8 +355,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
|
||||||
@@ -420,4 +422,3 @@ bool Analog_Value_Write_Property(
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ char *Binary_Input_Name(
|
|||||||
/* return apdu length, or -1 on error */
|
/* return apdu length, or -1 on error */
|
||||||
/* assumption - object already exists, and has been bounds checked */
|
/* assumption - object already exists, and has been bounds checked */
|
||||||
int Binary_Input_Read_Property(
|
int Binary_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
@@ -169,8 +169,7 @@ int Binary_Input_Read_Property(
|
|||||||
BACNET_BINARY_PV value = BINARY_INACTIVE;
|
BACNET_BINARY_PV value = BINARY_INACTIVE;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -224,8 +223,7 @@ int Binary_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -233,4 +231,3 @@ int Binary_Input_Read_Property(
|
|||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ char *Binary_Value_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Binary_Value_Read_Property(
|
int Binary_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
@@ -164,8 +164,7 @@ int Binary_Value_Read_Property(
|
|||||||
|
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -190,7 +189,8 @@ int Binary_Value_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
encode_application_enumerated(&apdu[0], OBJECT_BINARY_VALUE);
|
||||||
break;
|
break;
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Value_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Value_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -221,8 +221,7 @@ int Binary_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -266,8 +265,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;
|
||||||
@@ -312,4 +311,3 @@ bool Binary_Value_Write_Property(
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,12 +51,11 @@
|
|||||||
static uint32_t Object_Instance_Number = 12345;
|
static uint32_t Object_Instance_Number = 12345;
|
||||||
static char My_Object_Name[32] = "ARM7 Device";
|
static char My_Object_Name[32] = "ARM7 Device";
|
||||||
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
||||||
static BACNET_REINITIALIZED_STATE Reinitialize_State =
|
static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
|
||||||
BACNET_REINIT_IDLE;
|
|
||||||
|
|
||||||
/* forward prototypes */
|
/* forward prototypes */
|
||||||
int Device_Read_Property_Local(
|
int Device_Read_Property_Local(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
bool Device_Write_Property_Local(
|
bool Device_Write_Property_Local(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
@@ -70,55 +69,30 @@ static struct object_functions {
|
|||||||
read_property_function Object_Read_Property;
|
read_property_function Object_Read_Property;
|
||||||
write_property_function Object_Write_Property;
|
write_property_function Object_Write_Property;
|
||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
} Object_Table[] =
|
} Object_Table[] = {
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||||
NULL,/* don't init - recursive! */
|
Device_Count, Device_Index_To_Instance,
|
||||||
Device_Count,
|
Device_Valid_Object_Instance_Number, Device_Name,
|
||||||
Device_Index_To_Instance,
|
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||||
Device_Valid_Object_Instance_Number,
|
Device_Property_Lists}, {
|
||||||
Device_Name,
|
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||||
Device_Read_Property_Local,
|
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||||
Device_Write_Property_Local,
|
Analog_Input_Name, Analog_Input_Read_Property, NULL,
|
||||||
Device_Property_Lists},
|
Analog_Input_Property_Lists}, {
|
||||||
{OBJECT_ANALOG_INPUT,
|
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||||
Analog_Input_Init,
|
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||||
Analog_Input_Count,
|
Analog_Value_Name, Analog_Value_Read_Property,
|
||||||
Analog_Input_Index_To_Instance,
|
Analog_Value_Write_Property, Analog_Value_Property_Lists}, {
|
||||||
Analog_Input_Valid_Instance,
|
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||||
Analog_Input_Name,
|
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||||
Analog_Input_Read_Property,
|
Binary_Input_Name, Binary_Input_Read_Property, NULL,
|
||||||
NULL,
|
Binary_Input_Property_Lists}, {
|
||||||
Analog_Input_Property_Lists},
|
OBJECT_BINARY_VALUE, Binary_Value_Init, Binary_Value_Count,
|
||||||
{OBJECT_ANALOG_VALUE,
|
Binary_Value_Index_To_Instance, Binary_Value_Valid_Instance,
|
||||||
Analog_Value_Init,
|
Binary_Value_Name, Binary_Value_Read_Property,
|
||||||
Analog_Value_Count,
|
Binary_Value_Write_Property, Binary_Value_Property_Lists}, {
|
||||||
Analog_Value_Index_To_Instance,
|
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||||
Analog_Value_Valid_Instance,
|
|
||||||
Analog_Value_Name,
|
|
||||||
Analog_Value_Read_Property,
|
|
||||||
Analog_Value_Write_Property,
|
|
||||||
Analog_Value_Property_Lists},
|
|
||||||
{OBJECT_BINARY_INPUT,
|
|
||||||
Binary_Input_Init,
|
|
||||||
Binary_Input_Count,
|
|
||||||
Binary_Input_Index_To_Instance,
|
|
||||||
Binary_Input_Valid_Instance,
|
|
||||||
Binary_Input_Name,
|
|
||||||
Binary_Input_Read_Property,
|
|
||||||
NULL,
|
|
||||||
Binary_Input_Property_Lists},
|
|
||||||
{OBJECT_BINARY_VALUE,
|
|
||||||
Binary_Value_Init,
|
|
||||||
Binary_Value_Count,
|
|
||||||
Binary_Value_Index_To_Instance,
|
|
||||||
Binary_Value_Valid_Instance,
|
|
||||||
Binary_Value_Name,
|
|
||||||
Binary_Value_Read_Property,
|
|
||||||
Binary_Value_Write_Property,
|
|
||||||
Binary_Value_Property_Lists},
|
|
||||||
|
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||||
@@ -176,7 +150,7 @@ void Device_Property_Lists(
|
|||||||
/* Encodes the property APDU and returns the length,
|
/* Encodes the property APDU and returns the length,
|
||||||
or sets the error, and returns -1 */
|
or sets the error, and returns -1 */
|
||||||
int Device_Read_Property(
|
int Device_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = -1;
|
int apdu_len = -1;
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
@@ -294,10 +268,8 @@ void Device_Objects_Property_List(
|
|||||||
pObject = &Object_Table[index];
|
pObject = &Object_Table[index];
|
||||||
}
|
}
|
||||||
if (found && object_property_list) {
|
if (found && object_property_list) {
|
||||||
object_property_list(
|
object_property_list(&pPropertyList->Required.pList,
|
||||||
&pPropertyList->Required.pList,
|
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||||
&pPropertyList->Optional.pList,
|
|
||||||
&pPropertyList->Proprietary.pList);
|
|
||||||
}
|
}
|
||||||
/* fill the count */
|
/* fill the count */
|
||||||
if (pPropertyList->Required.pList) {
|
if (pPropertyList->Required.pList) {
|
||||||
@@ -328,7 +300,7 @@ unsigned Device_Object_List_Count(
|
|||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
unsigned count = 0; /* number of objects */
|
unsigned count = 0; /* number of objects */
|
||||||
unsigned index = 0; /* loop counter */
|
unsigned index = 0; /* loop counter */
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
|
|
||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
@@ -363,8 +335,7 @@ bool Device_Object_List_Identifier(
|
|||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Count &&
|
if (pObject->Object_Count && pObject->Object_Index_To_Instance) {
|
||||||
pObject->Object_Index_To_Instance) {
|
|
||||||
object_index -= count;
|
object_index -= count;
|
||||||
count = pObject->Object_Count();
|
count = pObject->Object_Count();
|
||||||
if (object_index < count) {
|
if (object_index < count) {
|
||||||
@@ -425,8 +396,7 @@ char *Device_Valid_Object_Id(
|
|||||||
|
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Type == object_type) &&
|
if ((pObject->Object_Type == object_type) && (pObject->Object_Name)) {
|
||||||
(pObject->Object_Name)) {
|
|
||||||
name = pObject->Object_Name(object_instance);
|
name = pObject->Object_Name(object_instance);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -437,7 +407,8 @@ char *Device_Valid_Object_Id(
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Device_Count(void)
|
unsigned Device_Count(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -459,7 +430,7 @@ char *Device_Name(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
@@ -547,7 +518,7 @@ int Device_Set_System_Status(
|
|||||||
BACNET_DEVICE_STATUS status,
|
BACNET_DEVICE_STATUS status,
|
||||||
bool local)
|
bool local)
|
||||||
{
|
{
|
||||||
int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
|
int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
|
||||||
|
|
||||||
if (status < MAX_DEVICE_STATUS) {
|
if (status < MAX_DEVICE_STATUS) {
|
||||||
System_Status = status;
|
System_Status = status;
|
||||||
@@ -588,7 +559,7 @@ uint32_t Device_Database_Revision(
|
|||||||
|
|
||||||
/* return the length of the apdu encoded or -1 for error */
|
/* return the length of the apdu encoded or -1 for error */
|
||||||
int Device_Read_Property_Local(
|
int Device_Read_Property_Local(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
int len = 0; /* apdu len intermediate value */
|
int len = 0; /* apdu len intermediate value */
|
||||||
@@ -604,8 +575,7 @@ int Device_Read_Property_Local(
|
|||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -702,8 +672,7 @@ int Device_Read_Property_Local(
|
|||||||
i = 0;
|
i = 0;
|
||||||
pObject = &Object_Table[i];
|
pObject = &Object_Table[i];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Count) &&
|
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
|
||||||
(pObject->Object_Count() > 0)) {
|
|
||||||
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -722,8 +691,9 @@ int Device_Read_Property_Local(
|
|||||||
/* your maximum APDU size. */
|
/* your maximum APDU size. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
for (i = 1; i <= count; i++) {
|
for (i = 1; i <= count; i++) {
|
||||||
found = Device_Object_List_Identifier(i, &object_type,
|
found =
|
||||||
&instance);
|
Device_Object_List_Identifier(i, &object_type,
|
||||||
|
&instance);
|
||||||
if (found) {
|
if (found) {
|
||||||
len =
|
len =
|
||||||
encode_application_object_id(&apdu[apdu_len],
|
encode_application_object_id(&apdu[apdu_len],
|
||||||
@@ -733,7 +703,8 @@ int Device_Read_Property_Local(
|
|||||||
/* can we all fit into the APDU? */
|
/* can we all fit into the APDU? */
|
||||||
if ((apdu_len + len) >= MAX_APDU) {
|
if ((apdu_len + len) >= MAX_APDU) {
|
||||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
rpdata->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -746,8 +717,8 @@ int Device_Read_Property_Local(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Device_Object_List_Identifier(rpdata->array_index, &object_type,
|
if (Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&instance))
|
&object_type, &instance))
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
instance);
|
instance);
|
||||||
@@ -825,8 +796,7 @@ int Device_Read_Property_Local(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
|
||||||
(rpdata->object_property != PROP_OBJECT_LIST) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -858,8 +828,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 {
|
||||||
@@ -918,11 +888,13 @@ bool Device_Write_Property_Local(
|
|||||||
the device. */
|
the device. */
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ static inline void bacnet_init(
|
|||||||
/* set up our confirmed service unrecognized service handler - required! */
|
/* set up our confirmed service unrecognized service handler - required! */
|
||||||
apdu_set_unrecognized_service_handler_handler
|
apdu_set_unrecognized_service_handler_handler
|
||||||
(handler_unrecognized_service);
|
(handler_unrecognized_service);
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
|
||||||
handler_who_has);
|
|
||||||
/* we need to handle who-is to support dynamic device binding */
|
/* we need to handle who-is to support dynamic device binding */
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||||
/* Set the handlers for any confirmed services that we support. */
|
/* Set the handlers for any confirmed services that we support. */
|
||||||
|
|||||||
@@ -155,8 +155,7 @@ int Analog_Input_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ int Analog_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -169,8 +169,7 @@ int Binary_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -207,8 +206,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;
|
||||||
|
|||||||
@@ -337,8 +337,7 @@ int Device_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (property != PROP_OBJECT_LIST) &&
|
||||||
(property != PROP_OBJECT_LIST) &&
|
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
(array_index != BACNET_ARRAY_ALL)) {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -372,8 +371,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 {
|
||||||
|
|||||||
@@ -163,11 +163,11 @@ extern "C" {
|
|||||||
BACNET_ERROR_CODE * error_code);
|
BACNET_ERROR_CODE * error_code);
|
||||||
|
|
||||||
bool DeviceGetRRInfo(
|
bool DeviceGetRRInfo(
|
||||||
uint32_t Object, /* Which particular object - obviously not important for device object */
|
uint32_t Object, /* Which particular object - obviously not important for device object */
|
||||||
BACNET_PROPERTY_ID Property, /* Which property */
|
BACNET_PROPERTY_ID Property, /* Which property */
|
||||||
RR_PROP_INFO *pInfo, /* Where to put the information */
|
RR_PROP_INFO * pInfo, /* Where to put the information */
|
||||||
BACNET_ERROR_CLASS *error_class,
|
BACNET_ERROR_CLASS * error_class,
|
||||||
BACNET_ERROR_CODE *error_code);
|
BACNET_ERROR_CODE * error_code);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ int Analog_Input_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ int Analog_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -169,8 +169,7 @@ int Binary_Value_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (array_index != BACNET_ARRAY_ALL)) {
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
@@ -207,8 +206,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;
|
||||||
|
|||||||
@@ -328,8 +328,7 @@ int Device_Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (property != PROP_OBJECT_LIST) &&
|
||||||
(property != PROP_OBJECT_LIST) &&
|
|
||||||
(array_index != BACNET_ARRAY_ALL)) {
|
(array_index != BACNET_ARRAY_ALL)) {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
*error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
|
|||||||
@@ -146,20 +146,19 @@ void Analog_Input_Present_Value_Set(
|
|||||||
/* return apdu length, or -1 on error */
|
/* return apdu length, or -1 on error */
|
||||||
/* assumption - object already exists */
|
/* assumption - object already exists */
|
||||||
int Analog_Input_Read_Property(
|
int Analog_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
uint8_t *apdu = NULL;
|
uint8_t *apdu = NULL;
|
||||||
|
|
||||||
if ((rpdata == NULL) ||
|
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||||
(rpdata->application_data == NULL) ||
|
|
||||||
(rpdata->application_data_len == 0)) {
|
(rpdata->application_data_len == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
apdu = rpdata->application_data;
|
apdu = rpdata->application_data;
|
||||||
switch (rpdata->object_property) {
|
switch (rpdata->object_property) {
|
||||||
/* object id, object name, object type are handled in Device object */
|
/* object id, object name, object type are handled in Device object */
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0],
|
encode_application_real(&apdu[0],
|
||||||
@@ -190,8 +189,7 @@ int Analog_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ char *Analog_Value_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Analog_Value_Read_Property(
|
int Analog_Value_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
@@ -214,7 +214,7 @@ int Analog_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
apdu = rpdata->application_data;
|
apdu = rpdata->application_data;
|
||||||
switch (rpdata->object_property) {
|
switch (rpdata->object_property) {
|
||||||
/* object id, object name, object type are handled in Device object */
|
/* object id, object name, object type are handled in Device object */
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
real_value = Analog_Value_Present_Value(rpdata->object_instance);
|
real_value = Analog_Value_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_real(&apdu[0], real_value);
|
apdu_len = encode_application_real(&apdu[0], real_value);
|
||||||
@@ -233,7 +233,8 @@ int Analog_Value_Read_Property(
|
|||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
#if 0
|
#if 0
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Analog_Value_Out_Of_Service[object_index];
|
state = Analog_Value_Out_Of_Service[object_index];
|
||||||
#endif
|
#endif
|
||||||
apdu_len = encode_application_boolean(&apdu[0], false);
|
apdu_len = encode_application_boolean(&apdu[0], false);
|
||||||
@@ -272,14 +273,16 @@ int Analog_Value_Read_Property(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
object_index = Analog_Value_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Analog_Value_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
if (Present_Value[object_index][rpdata->array_index - 1] ==
|
if (Present_Value[object_index][rpdata->array_index - 1] ==
|
||||||
ANALOG_LEVEL_NULL)
|
ANALOG_LEVEL_NULL)
|
||||||
apdu_len = encode_application_null(&apdu[0]);
|
apdu_len = encode_application_null(&apdu[0]);
|
||||||
else {
|
else {
|
||||||
real_value =
|
real_value =
|
||||||
Present_Value[object_index][rpdata->array_index - 1];
|
Present_Value[object_index][rpdata->array_index -
|
||||||
|
1];
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_real(&apdu[0], real_value);
|
encode_application_real(&apdu[0], real_value);
|
||||||
}
|
}
|
||||||
@@ -336,13 +339,12 @@ bool Analog_Value_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_REAL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_REAL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
status = Analog_Value_Present_Value_Set(
|
status =
|
||||||
wp_data->object_instance,
|
Analog_Value_Present_Value_Set(wp_data->object_instance,
|
||||||
value.type.Real, wp_data->priority);
|
value.type.Real, wp_data->priority);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
if (wp_data->priority == 6) {
|
if (wp_data->priority == 6) {
|
||||||
@@ -370,10 +372,9 @@ bool Analog_Value_Write_Property(
|
|||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
Analog_Value_Instance_To_Index(wp_data->object_instance);
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ char *Binary_Input_Name(
|
|||||||
/* return apdu length, or -1 on error */
|
/* return apdu length, or -1 on error */
|
||||||
/* assumption - object already exists, and has been bounds checked */
|
/* assumption - object already exists, and has been bounds checked */
|
||||||
int Binary_Input_Read_Property(
|
int Binary_Input_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
BACNET_BIT_STRING bit_string;
|
BACNET_BIT_STRING bit_string;
|
||||||
@@ -187,7 +187,7 @@ int Binary_Input_Read_Property(
|
|||||||
}
|
}
|
||||||
apdu = rpdata->application_data;
|
apdu = rpdata->application_data;
|
||||||
switch (rpdata->object_property) {
|
switch (rpdata->object_property) {
|
||||||
/* object id, object name, object type are handled in Device object */
|
/* object id, object name, object type are handled in Device object */
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
value = Binary_Input_Present_Value(rpdata->object_instance);
|
value = Binary_Input_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], value);
|
apdu_len = encode_application_enumerated(&apdu[0], value);
|
||||||
@@ -219,8 +219,7 @@ int Binary_Input_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
|
|||||||
@@ -201,8 +201,8 @@ static void Binary_Output_Level_Sync(
|
|||||||
bool Binary_Output_Present_Value_Set(
|
bool Binary_Output_Present_Value_Set(
|
||||||
uint32_t instance,
|
uint32_t instance,
|
||||||
BACNET_BINARY_PV binary_value,
|
BACNET_BINARY_PV binary_value,
|
||||||
unsigned priority) /* 0..15 */
|
unsigned priority)
|
||||||
{
|
{ /* 0..15 */
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
if (instance < MAX_BINARY_OUTPUTS) {
|
if (instance < MAX_BINARY_OUTPUTS) {
|
||||||
@@ -239,8 +239,7 @@ void Binary_Output_Out_Of_Service_Set(
|
|||||||
if (instance < MAX_BINARY_OUTPUTS) {
|
if (instance < MAX_BINARY_OUTPUTS) {
|
||||||
Out_Of_Service[instance] = flag;
|
Out_Of_Service[instance] = flag;
|
||||||
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(instance,
|
seeprom_bytes_write(NV_SEEPROM_BINARY_OUTPUT(instance,
|
||||||
NV_SEEPROM_BO_OUT_OF_SERVICE), &Out_Of_Service[instance],
|
NV_SEEPROM_BO_OUT_OF_SERVICE), &Out_Of_Service[instance], 1);
|
||||||
1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +259,7 @@ char *Binary_Output_Name(
|
|||||||
|
|
||||||
/* return apdu len, or -1 on error */
|
/* return apdu len, or -1 on error */
|
||||||
int Binary_Output_Read_Property(
|
int Binary_Output_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
@@ -278,9 +277,10 @@ int Binary_Output_Read_Property(
|
|||||||
}
|
}
|
||||||
apdu = rpdata->application_data;
|
apdu = rpdata->application_data;
|
||||||
switch (rpdata->object_property) {
|
switch (rpdata->object_property) {
|
||||||
/* object id, object name, object type are handled in Device object */
|
/* object id, object name, object type are handled in Device object */
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
present_value = Binary_Output_Present_Value(rpdata->object_instance);
|
present_value =
|
||||||
|
Binary_Output_Present_Value(rpdata->object_instance);
|
||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_STATUS_FLAGS:
|
case PROP_STATUS_FLAGS:
|
||||||
@@ -298,12 +298,14 @@ int Binary_Output_Read_Property(
|
|||||||
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
encode_application_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
object_index = Binary_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
state = Out_Of_Service[object_index];
|
state = Out_Of_Service[object_index];
|
||||||
apdu_len = encode_application_boolean(&apdu[0], state);
|
apdu_len = encode_application_boolean(&apdu[0], state);
|
||||||
break;
|
break;
|
||||||
case PROP_POLARITY:
|
case PROP_POLARITY:
|
||||||
object_index = Binary_Output_Instance_To_Index(rpdata->object_instance);
|
object_index =
|
||||||
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_enumerated(&apdu[0],
|
encode_application_enumerated(&apdu[0],
|
||||||
Polarity[object_index]);
|
Polarity[object_index]);
|
||||||
@@ -343,7 +345,8 @@ int Binary_Output_Read_Property(
|
|||||||
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
Binary_Output_Instance_To_Index(rpdata->object_instance);
|
||||||
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
if (rpdata->array_index <= BACNET_MAX_PRIORITY) {
|
||||||
present_value =
|
present_value =
|
||||||
Binary_Output_Level[object_index][rpdata->array_index - 1];
|
Binary_Output_Level[object_index][rpdata->array_index -
|
||||||
|
1];
|
||||||
if (present_value == BINARY_NULL) {
|
if (present_value == BINARY_NULL) {
|
||||||
apdu_len = encode_application_null(&apdu[apdu_len]);
|
apdu_len = encode_application_null(&apdu[apdu_len]);
|
||||||
} else {
|
} else {
|
||||||
@@ -379,8 +382,7 @@ int Binary_Output_Read_Property(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
||||||
(rpdata->object_property != PROP_PRIORITY_ARRAY) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -408,10 +410,9 @@ bool Binary_Output_Write_Property(
|
|||||||
/* FIXME: len == 0: unable to decode? */
|
/* FIXME: len == 0: unable to decode? */
|
||||||
switch (wp_data->object_property) {
|
switch (wp_data->object_property) {
|
||||||
case PROP_PRESENT_VALUE:
|
case PROP_PRESENT_VALUE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
priority = wp_data->priority;
|
priority = wp_data->priority;
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
@@ -422,8 +423,7 @@ 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;
|
||||||
priority--;
|
priority--;
|
||||||
Binary_Output_Present_Value_Set(
|
Binary_Output_Present_Value_Set(wp_data->object_instance,
|
||||||
wp_data->object_instance,
|
|
||||||
level, priority);
|
level, priority);
|
||||||
} else if (priority == 6) {
|
} else if (priority == 6) {
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
@@ -438,18 +438,16 @@ bool Binary_Output_Write_Property(
|
|||||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_NULL,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_NULL,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
level = BINARY_NULL;
|
level = BINARY_NULL;
|
||||||
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,
|
object_instance, level, priority);
|
||||||
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
|
||||||
@@ -466,26 +464,22 @@ bool Binary_Output_Write_Property(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OUT_OF_SERVICE:
|
case PROP_OUT_OF_SERVICE:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_BOOLEAN,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_BOOLEAN,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
Binary_Output_Out_Of_Service_Set(
|
Binary_Output_Out_Of_Service_Set(wp_data->object_instance,
|
||||||
wp_data->object_instance,
|
|
||||||
value.type.Boolean);
|
value.type.Boolean);
|
||||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
Binary_Output_Level_Sync(wp_data->object_instance);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_POLARITY:
|
case PROP_POLARITY:
|
||||||
status = WPValidateArgType(&value,
|
status =
|
||||||
BACNET_APPLICATION_TAG_ENUMERATED,
|
WPValidateArgType(&value, BACNET_APPLICATION_TAG_ENUMERATED,
|
||||||
&wp_data->error_class,
|
&wp_data->error_class, &wp_data->error_code);
|
||||||
&wp_data->error_code);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if (value.type.Enumerated < MAX_POLARITY) {
|
if (value.type.Enumerated < MAX_POLARITY) {
|
||||||
Binary_Output_Polarity_Set(
|
Binary_Output_Polarity_Set(wp_data->object_instance,
|
||||||
wp_data->object_instance,
|
|
||||||
value.type.Enumerated);
|
value.type.Enumerated);
|
||||||
Binary_Output_Level_Sync(wp_data->object_instance);
|
Binary_Output_Level_Sync(wp_data->object_instance);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
/* forward prototype */
|
/* forward prototype */
|
||||||
int Device_Read_Property_Local(
|
int Device_Read_Property_Local(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata);
|
BACNET_READ_PROPERTY_DATA * rpdata);
|
||||||
bool Device_Write_Property_Local(
|
bool Device_Write_Property_Local(
|
||||||
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
BACNET_WRITE_PROPERTY_DATA * wp_data);
|
||||||
|
|
||||||
@@ -62,55 +62,30 @@ static struct object_functions {
|
|||||||
read_property_function Object_Read_Property;
|
read_property_function Object_Read_Property;
|
||||||
write_property_function Object_Write_Property;
|
write_property_function Object_Write_Property;
|
||||||
rpm_property_lists_function Object_RPM_List;
|
rpm_property_lists_function Object_RPM_List;
|
||||||
} Object_Table[] =
|
} Object_Table[] = {
|
||||||
{
|
{
|
||||||
{OBJECT_DEVICE,
|
OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||||
NULL,/* don't init - recursive! */
|
Device_Count, Device_Index_To_Instance,
|
||||||
Device_Count,
|
Device_Valid_Object_Instance_Number, Device_Name,
|
||||||
Device_Index_To_Instance,
|
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||||
Device_Valid_Object_Instance_Number,
|
Device_Property_Lists}, {
|
||||||
Device_Name,
|
OBJECT_ANALOG_INPUT, Analog_Input_Init, Analog_Input_Count,
|
||||||
Device_Read_Property_Local,
|
Analog_Input_Index_To_Instance, Analog_Input_Valid_Instance,
|
||||||
Device_Write_Property_Local,
|
Analog_Input_Name, Analog_Input_Read_Property, NULL,
|
||||||
Device_Property_Lists},
|
Analog_Input_Property_Lists}, {
|
||||||
{OBJECT_ANALOG_INPUT,
|
OBJECT_ANALOG_VALUE, Analog_Value_Init, Analog_Value_Count,
|
||||||
Analog_Input_Init,
|
Analog_Value_Index_To_Instance, Analog_Value_Valid_Instance,
|
||||||
Analog_Input_Count,
|
Analog_Value_Name, Analog_Value_Read_Property,
|
||||||
Analog_Input_Index_To_Instance,
|
Analog_Value_Write_Property, Analog_Value_Property_Lists}, {
|
||||||
Analog_Input_Valid_Instance,
|
OBJECT_BINARY_INPUT, Binary_Input_Init, Binary_Input_Count,
|
||||||
Analog_Input_Name,
|
Binary_Input_Index_To_Instance, Binary_Input_Valid_Instance,
|
||||||
Analog_Input_Read_Property,
|
Binary_Input_Name, Binary_Input_Read_Property, NULL,
|
||||||
NULL,
|
Binary_Input_Property_Lists}, {
|
||||||
Analog_Input_Property_Lists},
|
OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count,
|
||||||
{OBJECT_ANALOG_VALUE,
|
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||||
Analog_Value_Init,
|
Binary_Output_Name, Binary_Output_Read_Property,
|
||||||
Analog_Value_Count,
|
Binary_Output_Write_Property, Binary_Output_Property_Lists}, {
|
||||||
Analog_Value_Index_To_Instance,
|
MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||||
Analog_Value_Valid_Instance,
|
|
||||||
Analog_Value_Name,
|
|
||||||
Analog_Value_Read_Property,
|
|
||||||
Analog_Value_Write_Property,
|
|
||||||
Analog_Value_Property_Lists},
|
|
||||||
{OBJECT_BINARY_INPUT,
|
|
||||||
Binary_Input_Init,
|
|
||||||
Binary_Input_Count,
|
|
||||||
Binary_Input_Index_To_Instance,
|
|
||||||
Binary_Input_Valid_Instance,
|
|
||||||
Binary_Input_Name,
|
|
||||||
Binary_Input_Read_Property,
|
|
||||||
NULL,
|
|
||||||
Binary_Input_Property_Lists},
|
|
||||||
{OBJECT_BINARY_OUTPUT,
|
|
||||||
Binary_Output_Init,
|
|
||||||
Binary_Output_Count,
|
|
||||||
Binary_Output_Index_To_Instance,
|
|
||||||
Binary_Output_Valid_Instance,
|
|
||||||
Binary_Output_Name,
|
|
||||||
Binary_Output_Read_Property,
|
|
||||||
Binary_Output_Write_Property,
|
|
||||||
Binary_Output_Property_Lists},
|
|
||||||
|
|
||||||
{MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* note: you really only need to define variables for
|
/* note: you really only need to define variables for
|
||||||
@@ -120,8 +95,7 @@ static struct object_functions {
|
|||||||
static uint32_t Object_Instance_Number;
|
static uint32_t Object_Instance_Number;
|
||||||
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
|
||||||
|
|
||||||
static BACNET_REINITIALIZED_STATE Reinitialize_State =
|
static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
|
||||||
BACNET_REINIT_IDLE;
|
|
||||||
|
|
||||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||||
static const int Device_Properties_Required[] = {
|
static const int Device_Properties_Required[] = {
|
||||||
@@ -159,7 +133,7 @@ static const int Device_Properties_Proprietary[] = {
|
|||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct object_functions * Device_Objects_Find_Functions(
|
static struct object_functions *Device_Objects_Find_Functions(
|
||||||
BACNET_OBJECT_TYPE Object_Type)
|
BACNET_OBJECT_TYPE Object_Type)
|
||||||
{
|
{
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
@@ -168,18 +142,18 @@ static struct object_functions * Device_Objects_Find_Functions(
|
|||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
/* handle each object type */
|
/* handle each object type */
|
||||||
if (pObject->Object_Type == Object_Type) {
|
if (pObject->Object_Type == Object_Type) {
|
||||||
return(pObject);
|
return (pObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
pObject++;
|
pObject++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Read_Property_Common(
|
static int Read_Property_Common(
|
||||||
struct object_functions *pObject,
|
struct object_functions *pObject,
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = -1;
|
int apdu_len = -1;
|
||||||
BACNET_CHARACTER_STRING char_string;
|
BACNET_CHARACTER_STRING char_string;
|
||||||
@@ -199,9 +173,8 @@ static int Read_Property_Common(
|
|||||||
rpdata->object_instance = Object_Instance_Number;
|
rpdata->object_instance = Object_Instance_Number;
|
||||||
}
|
}
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0],
|
encode_application_object_id(&apdu[0], rpdata->object_type,
|
||||||
rpdata->object_type,
|
rpdata->object_instance);
|
||||||
rpdata->object_instance);
|
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
if (pObject->Object_Name) {
|
if (pObject->Object_Name) {
|
||||||
@@ -212,8 +185,8 @@ static int Read_Property_Common(
|
|||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_TYPE:
|
case PROP_OBJECT_TYPE:
|
||||||
apdu_len = encode_application_enumerated(&apdu[0],
|
apdu_len =
|
||||||
rpdata->object_type);
|
encode_application_enumerated(&apdu[0], rpdata->object_type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (pObject->Object_Read_Property) {
|
if (pObject->Object_Read_Property) {
|
||||||
@@ -228,7 +201,7 @@ static int Read_Property_Common(
|
|||||||
/* Encodes the property APDU and returns the length,
|
/* Encodes the property APDU and returns the length,
|
||||||
or sets the error, and returns -1 */
|
or sets the error, and returns -1 */
|
||||||
int Device_Read_Property(
|
int Device_Read_Property(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = -1;
|
int apdu_len = -1;
|
||||||
struct object_functions *pObject = NULL;
|
struct object_functions *pObject = NULL;
|
||||||
@@ -313,21 +286,22 @@ void Device_Objects_Property_List(
|
|||||||
|
|
||||||
pObject = Device_Objects_Find_Functions(object_type);
|
pObject = Device_Objects_Find_Functions(object_type);
|
||||||
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
||||||
pObject->Object_RPM_List(
|
pObject->Object_RPM_List(&pPropertyList->Required.pList,
|
||||||
&pPropertyList->Required.pList,
|
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||||
&pPropertyList->Optional.pList,
|
|
||||||
&pPropertyList->Proprietary.pList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch the counts if available otherwise zero them */
|
/* Fetch the counts if available otherwise zero them */
|
||||||
pPropertyList->Required.count = pPropertyList->Required.pList == NULL
|
pPropertyList->Required.count =
|
||||||
? 0 : property_list_count(pPropertyList->Required.pList);
|
pPropertyList->Required.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Required.pList);
|
||||||
|
|
||||||
pPropertyList->Optional.count = pPropertyList->Optional.pList == NULL
|
pPropertyList->Optional.count =
|
||||||
? 0 : property_list_count(pPropertyList->Optional.pList);
|
pPropertyList->Optional.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Optional.pList);
|
||||||
|
|
||||||
pPropertyList->Proprietary.count = pPropertyList->Proprietary.pList == NULL
|
pPropertyList->Proprietary.count =
|
||||||
? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
pPropertyList->Proprietary.pList ==
|
||||||
|
NULL ? 0 : property_list_count(pPropertyList->Proprietary.pList);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -347,7 +321,8 @@ void Device_Property_Lists(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Device_Count(void)
|
unsigned Device_Count(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -363,7 +338,7 @@ char *Device_Name(
|
|||||||
{
|
{
|
||||||
uint8_t encoding = 0;
|
uint8_t encoding = 0;
|
||||||
uint8_t length = 0;
|
uint8_t length = 0;
|
||||||
static char name[NV_EEPROM_DEVICE_NAME_SIZE+1] = "";
|
static char name[NV_EEPROM_DEVICE_NAME_SIZE + 1] = "";
|
||||||
char *pName = NULL;
|
char *pName = NULL;
|
||||||
|
|
||||||
if (object_instance == Object_Instance_Number) {
|
if (object_instance == Object_Instance_Number) {
|
||||||
@@ -372,14 +347,12 @@ char *Device_Name(
|
|||||||
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & name,
|
eeprom_bytes_read(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & name,
|
||||||
NV_EEPROM_DEVICE_NAME_SIZE);
|
NV_EEPROM_DEVICE_NAME_SIZE);
|
||||||
if ((encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
if ((encoding >= MAX_CHARACTER_STRING_ENCODING) ||
|
||||||
(length > NV_EEPROM_DEVICE_NAME_SIZE) ||
|
(length > NV_EEPROM_DEVICE_NAME_SIZE) || (length < 1)) {
|
||||||
(length < 1)) {
|
|
||||||
encoding = CHARACTER_ANSI_X34;
|
encoding = CHARACTER_ANSI_X34;
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_ENCODING, &encoding, 1);
|
||||||
&encoding, 1);
|
|
||||||
sprintf(name, "DEVICE-%lu", Object_Instance_Number);
|
sprintf(name, "DEVICE-%lu", Object_Instance_Number);
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0,
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_0, (uint8_t *) & name[0],
|
||||||
(uint8_t *) & name[0], NV_EEPROM_DEVICE_NAME_SIZE);
|
NV_EEPROM_DEVICE_NAME_SIZE);
|
||||||
length = strlen(name);
|
length = strlen(name);
|
||||||
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &length, 1);
|
eeprom_bytes_write(NV_EEPROM_DEVICE_NAME_LENGTH, &length, 1);
|
||||||
}
|
}
|
||||||
@@ -395,7 +368,7 @@ char *Device_Name(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Device_Reinitialize(
|
bool Device_Reinitialize(
|
||||||
BACNET_REINITIALIZE_DEVICE_DATA *rd_data)
|
BACNET_REINITIALIZE_DEVICE_DATA * rd_data)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
@@ -438,7 +411,7 @@ void Device_Init(
|
|||||||
(uint8_t *) & Object_Instance_Number,
|
(uint8_t *) & Object_Instance_Number,
|
||||||
sizeof(Object_Instance_Number));
|
sizeof(Object_Instance_Number));
|
||||||
}
|
}
|
||||||
(void)Device_Name(Object_Instance_Number);
|
(void) Device_Name(Object_Instance_Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* methods to manipulate the data */
|
/* methods to manipulate the data */
|
||||||
@@ -549,8 +522,7 @@ bool Device_Object_List_Identifier(
|
|||||||
/* initialize the default return values */
|
/* initialize the default return values */
|
||||||
pObject = &Object_Table[0];
|
pObject = &Object_Table[0];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if (pObject->Object_Count &&
|
if (pObject->Object_Count && pObject->Object_Index_To_Instance) {
|
||||||
pObject->Object_Index_To_Instance) {
|
|
||||||
object_index -= count;
|
object_index -= count;
|
||||||
count = pObject->Object_Count();
|
count = pObject->Object_Count();
|
||||||
if (object_index < count) {
|
if (object_index < count) {
|
||||||
@@ -617,7 +589,7 @@ char *Device_Valid_Object_Id(
|
|||||||
|
|
||||||
/* return the length of the apdu encoded or -1 for error */
|
/* return the length of the apdu encoded or -1 for error */
|
||||||
int Device_Read_Property_Local(
|
int Device_Read_Property_Local(
|
||||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* return value */
|
int apdu_len = 0; /* return value */
|
||||||
int len = 0; /* apdu len intermediate value */
|
int len = 0; /* apdu len intermediate value */
|
||||||
@@ -652,8 +624,7 @@ int Device_Read_Property_Local(
|
|||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_VENDOR_IDENTIFIER:
|
case PROP_VENDOR_IDENTIFIER:
|
||||||
apdu_len =
|
apdu_len = encode_application_unsigned(&apdu[0], BACNET_VENDOR_ID);
|
||||||
encode_application_unsigned(&apdu[0], BACNET_VENDOR_ID);
|
|
||||||
break;
|
break;
|
||||||
case PROP_MODEL_NAME:
|
case PROP_MODEL_NAME:
|
||||||
characterstring_init_ansi(&char_string, "bdk-atxx4-mstp");
|
characterstring_init_ansi(&char_string, "bdk-atxx4-mstp");
|
||||||
@@ -671,12 +642,10 @@ int Device_Read_Property_Local(
|
|||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_PROTOCOL_VERSION:
|
case PROP_PROTOCOL_VERSION:
|
||||||
apdu_len =
|
apdu_len = encode_application_unsigned(&apdu[0], 1);
|
||||||
encode_application_unsigned(&apdu[0], 1);
|
|
||||||
break;
|
break;
|
||||||
case PROP_PROTOCOL_REVISION:
|
case PROP_PROTOCOL_REVISION:
|
||||||
apdu_len =
|
apdu_len = encode_application_unsigned(&apdu[0], 5);
|
||||||
encode_application_unsigned(&apdu[0], 5);
|
|
||||||
break;
|
break;
|
||||||
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
case PROP_PROTOCOL_SERVICES_SUPPORTED:
|
||||||
/* Note: list of services that are executed, not initiated. */
|
/* Note: list of services that are executed, not initiated. */
|
||||||
@@ -701,8 +670,7 @@ int Device_Read_Property_Local(
|
|||||||
i = 0;
|
i = 0;
|
||||||
pObject = &Object_Table[i];
|
pObject = &Object_Table[i];
|
||||||
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
|
||||||
if ((pObject->Object_Count) &&
|
if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
|
||||||
(pObject->Object_Count() > 0)) {
|
|
||||||
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
bitstring_set_bit(&bit_string, pObject->Object_Type, true);
|
||||||
}
|
}
|
||||||
pObject++;
|
pObject++;
|
||||||
@@ -730,7 +698,8 @@ int Device_Read_Property_Local(
|
|||||||
/* can we all fit into the APDU? */
|
/* can we all fit into the APDU? */
|
||||||
if ((apdu_len + len) >= MAX_APDU) {
|
if ((apdu_len + len) >= MAX_APDU) {
|
||||||
rpdata->error_class = ERROR_CLASS_SERVICES;
|
rpdata->error_class = ERROR_CLASS_SERVICES;
|
||||||
rpdata->error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
rpdata->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_FOR_OBJECT;
|
||||||
apdu_len = -1;
|
apdu_len = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -743,8 +712,8 @@ int Device_Read_Property_Local(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Device_Object_List_Identifier(rpdata->array_index, &object_type,
|
if (Device_Object_List_Identifier(rpdata->array_index,
|
||||||
&instance))
|
&object_type, &instance))
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_object_id(&apdu[0], object_type,
|
encode_application_object_id(&apdu[0], object_type,
|
||||||
instance);
|
instance);
|
||||||
@@ -803,8 +772,7 @@ int Device_Read_Property_Local(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* only array properties can have array options */
|
/* only array properties can have array options */
|
||||||
if ((apdu_len >= 0) &&
|
if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
|
||||||
(rpdata->object_property != PROP_OBJECT_LIST) &&
|
|
||||||
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
(rpdata->array_index != BACNET_ARRAY_ALL)) {
|
||||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||||
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
|
||||||
@@ -831,8 +799,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 {
|
||||||
@@ -892,18 +860,20 @@ 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;
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_CHARACTER_SET_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
wp_data->error_code = ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
wp_data->error_code =
|
||||||
|
ERROR_CODE_NO_SPACE_TO_WRITE_PROPERTY;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
wp_data->error_class = ERROR_CLASS_PROPERTY;
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void led_off_delay(
|
|||||||
void led_task(
|
void led_task(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
uint8_t i; /* loop counter */
|
uint8_t i; /* loop counter */
|
||||||
|
|
||||||
for (i = 0; i < MAX_LEDS; i++) {
|
for (i = 0; i < MAX_LEDS; i++) {
|
||||||
if (timer_interval_expired(&Off_Delay_Timer[i])) {
|
if (timer_interval_expired(&Off_Delay_Timer[i])) {
|
||||||
@@ -169,7 +169,7 @@ void led_task(
|
|||||||
void led_init(
|
void led_init(
|
||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
uint8_t i; /* loop counter */
|
uint8_t i; /* loop counter */
|
||||||
|
|
||||||
/* configure the port pins as outputs */
|
/* configure the port pins as outputs */
|
||||||
BIT_SET(DDRC, DDC7);
|
BIT_SET(DDRC, DDC7);
|
||||||
|
|||||||
@@ -102,10 +102,8 @@ static void bacnet_init(
|
|||||||
apdu_set_unrecognized_service_handler_handler
|
apdu_set_unrecognized_service_handler_handler
|
||||||
(handler_unrecognized_service);
|
(handler_unrecognized_service);
|
||||||
/* we need to handle who-is to support dynamic device binding */
|
/* we need to handle who-is to support dynamic device binding */
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS,
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
|
||||||
handler_who_is);
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS, handler_who_has);
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_HAS,
|
|
||||||
handler_who_has);
|
|
||||||
/* Set the handlers for any confirmed services that we support. */
|
/* Set the handlers for any confirmed services that we support. */
|
||||||
/* We must implement read property - it's required! */
|
/* We must implement read property - it's required! */
|
||||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ static FIFO_BUFFER Receive_Buffer;
|
|||||||
|
|
||||||
static struct etimer Silence_Timer;
|
static struct etimer Silence_Timer;
|
||||||
|
|
||||||
bool rs485_silence_time_elapsed(uint32_t milliseconds)
|
bool rs485_silence_time_elapsed(
|
||||||
|
uint32_t milliseconds)
|
||||||
{
|
{
|
||||||
return timer_elapsed_milliseconds(&Silence_Timer, milliseconds);
|
return timer_elapsed_milliseconds(&Silence_Timer, milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs485_silence_time_reset(void)
|
void rs485_silence_time_reset(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
timer_elapsed_start(&Silence_Timer);
|
timer_elapsed_start(&Silence_Timer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ extern "C" {
|
|||||||
|
|
||||||
void rs485_turnaround_delay(
|
void rs485_turnaround_delay(
|
||||||
void);
|
void);
|
||||||
void rs485_silence_time_reset(void);
|
void rs485_silence_time_reset(
|
||||||
bool rs485_silence_time_elapsed(uint32_t milliseconds);
|
void);
|
||||||
|
bool rs485_silence_time_elapsed(
|
||||||
|
uint32_t milliseconds);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,10 +425,10 @@ int seeprom_bytes_write_page(
|
|||||||
* first byte of the same page.
|
* first byte of the same page.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int seeprom_bytes_write(
|
int seeprom_bytes_write(
|
||||||
uint16_t off, /* SEEPROM starting memory address */
|
uint16_t off, /* SEEPROM starting memory address */
|
||||||
uint8_t * buf, /* data to send */
|
uint8_t * buf, /* data to send */
|
||||||
int len) /* number of bytes of data */
|
int len)
|
||||||
{
|
{ /* number of bytes of data */
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user