Indented.
This commit is contained in:
@@ -426,8 +426,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 {
|
||||||
|
|||||||
@@ -244,8 +244,7 @@ int RPM_Encode_Property(
|
|||||||
rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0],
|
rpm_ack_encode_apdu_object_property_error(&Temp_Buf[0],
|
||||||
error_class, error_code);
|
error_class, error_code);
|
||||||
len =
|
len =
|
||||||
memcopy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len,
|
memcopy(&apdu[0], &Temp_Buf[0], offset + apdu_len, len, max_apdu);
|
||||||
max_apdu);
|
|
||||||
if (!len) {
|
if (!len) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -344,8 +343,8 @@ void handler_read_property_multiple(
|
|||||||
rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], object_type,
|
rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], object_type,
|
||||||
object_instance);
|
object_instance);
|
||||||
copy_len =
|
copy_len =
|
||||||
memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], apdu_len,
|
||||||
apdu_len, len, sizeof(Handler_Transmit_Buffer));
|
len, sizeof(Handler_Transmit_Buffer));
|
||||||
if (!copy_len) {
|
if (!copy_len) {
|
||||||
apdu_len =
|
apdu_len =
|
||||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||||
|
|||||||
@@ -45,11 +45,11 @@
|
|||||||
/* note: initial the linked list of read_access_data */
|
/* note: initial the linked list of read_access_data */
|
||||||
static int rpm_ack_decode_service_request(
|
static int rpm_ack_decode_service_request(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int apdu_len, /* total length of the apdu */
|
int apdu_len, /* total length of the apdu */
|
||||||
BACNET_READ_ACCESS_DATA * read_access_data)
|
BACNET_READ_ACCESS_DATA * read_access_data)
|
||||||
{
|
{
|
||||||
int decoded_len = 0; /* return value */
|
int decoded_len = 0; /* return value */
|
||||||
int len = 0; /* number of bytes returned from decoding */
|
int len = 0; /* number of bytes returned from decoding */
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||||
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
||||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||||
@@ -60,9 +60,8 @@ static int rpm_ack_decode_service_request(
|
|||||||
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) {
|
||||||
len = rpm_ack_decode_object_id(
|
len =
|
||||||
apdu, apdu_len,
|
rpm_ack_decode_object_id(apdu, apdu_len, &rpm_object->object_type,
|
||||||
&rpm_object->object_type,
|
|
||||||
&rpm_object->object_instance);
|
&rpm_object->object_instance);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
old_rpm_object->next = NULL;
|
old_rpm_object->next = NULL;
|
||||||
@@ -76,9 +75,8 @@ static int rpm_ack_decode_service_request(
|
|||||||
rpm_object->listOfProperties = rpm_property;
|
rpm_object->listOfProperties = rpm_property;
|
||||||
old_rpm_property = rpm_property;
|
old_rpm_property = rpm_property;
|
||||||
while (rpm_property && apdu_len) {
|
while (rpm_property && apdu_len) {
|
||||||
len = rpm_ack_decode_object_property(
|
len =
|
||||||
apdu,
|
rpm_ack_decode_object_property(apdu, apdu_len,
|
||||||
apdu_len,
|
|
||||||
&rpm_property->propertyIdentifier,
|
&rpm_property->propertyIdentifier,
|
||||||
&rpm_property->propertyArrayIndex);
|
&rpm_property->propertyArrayIndex);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
@@ -94,15 +92,13 @@ static int rpm_ack_decode_service_request(
|
|||||||
apdu_len--;
|
apdu_len--;
|
||||||
apdu++;
|
apdu++;
|
||||||
/* 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 */
|
||||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||||
rpm_property->value = value;
|
rpm_property->value = value;
|
||||||
old_value = value;
|
old_value = value;
|
||||||
while (value && (apdu_len > 0)) {
|
while (value && (apdu_len > 0)) {
|
||||||
len = bacapp_decode_application_data(
|
len =
|
||||||
apdu,
|
bacapp_decode_application_data(apdu, apdu_len, value);
|
||||||
apdu_len,
|
|
||||||
value);
|
|
||||||
decoded_len += len;
|
decoded_len += len;
|
||||||
apdu_len -= len;
|
apdu_len -= len;
|
||||||
apdu += len;
|
apdu += len;
|
||||||
@@ -113,7 +109,8 @@ static int rpm_ack_decode_service_request(
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
old_value = value;
|
old_value = value;
|
||||||
value = calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
value =
|
||||||
|
calloc(1, sizeof(BACNET_APPLICATION_DATA_VALUE));
|
||||||
old_value->next = value;
|
old_value->next = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,8 +171,7 @@ static void PrintReadPropertyMultipleData(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
while (value) {
|
while (value) {
|
||||||
bacapp_print_value(stdout,
|
bacapp_print_value(stdout, value,
|
||||||
value,
|
|
||||||
listOfProperties->propertyIdentifier);
|
listOfProperties->propertyIdentifier);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (value->next) {
|
if (value->next) {
|
||||||
@@ -205,19 +201,20 @@ void handler_read_property_multiple_ack(
|
|||||||
BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
|
BACNET_CONFIRMED_SERVICE_ACK_DATA * service_data)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
BACNET_READ_ACCESS_DATA * rpm_data;
|
BACNET_READ_ACCESS_DATA *rpm_data;
|
||||||
BACNET_READ_ACCESS_DATA * old_rpm_data;
|
BACNET_READ_ACCESS_DATA *old_rpm_data;
|
||||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||||
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
||||||
BACNET_APPLICATION_DATA_VALUE *value;
|
BACNET_APPLICATION_DATA_VALUE *value;
|
||||||
BACNET_APPLICATION_DATA_VALUE *old_value;
|
BACNET_APPLICATION_DATA_VALUE *old_value;
|
||||||
|
|
||||||
(void) src;
|
(void) src;
|
||||||
(void) service_data; /* we could use these... */
|
(void) service_data; /* we could use these... */
|
||||||
|
|
||||||
rpm_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
rpm_data = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
||||||
if (rpm_data) {
|
if (rpm_data) {
|
||||||
len = rpm_ack_decode_service_request(service_request, service_len,
|
len =
|
||||||
|
rpm_ack_decode_service_request(service_request, service_len,
|
||||||
rpm_data);
|
rpm_data);
|
||||||
}
|
}
|
||||||
#if 1
|
#if 1
|
||||||
|
|||||||
@@ -50,32 +50,28 @@ void handler_ucov_notification(
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
/* create linked list to store data if more
|
/* create linked list to store data if more
|
||||||
than one property value is expected */
|
than one property value is expected */
|
||||||
property_value.next = NULL;
|
property_value.next = NULL;
|
||||||
cov_data.listOfValues = &property_value;
|
cov_data.listOfValues = &property_value;
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "UCOV: Received Notification!\n");
|
fprintf(stderr, "UCOV: Received Notification!\n");
|
||||||
#endif
|
#endif
|
||||||
/* decode the service request only */
|
/* decode the service request only */
|
||||||
len = cov_notify_decode_service_request(
|
len =
|
||||||
service_request, service_len, &cov_data);
|
cov_notify_decode_service_request(service_request, service_len,
|
||||||
|
&cov_data);
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
fprintf(stderr, "UCOV: PID=%u ",
|
fprintf(stderr, "UCOV: PID=%u ", cov_data.subscriberProcessIdentifier);
|
||||||
cov_data.subscriberProcessIdentifier);
|
fprintf(stderr, "instance=%u ", cov_data.initiatingDeviceIdentifier);
|
||||||
fprintf(stderr, "instance=%u ",
|
|
||||||
cov_data.initiatingDeviceIdentifier);
|
|
||||||
fprintf(stderr, "%s %u ",
|
fprintf(stderr, "%s %u ",
|
||||||
bactext_object_type_name(
|
bactext_object_type_name(cov_data.monitoredObjectIdentifier.type),
|
||||||
cov_data.monitoredObjectIdentifier.type),
|
|
||||||
cov_data.monitoredObjectIdentifier.instance);
|
cov_data.monitoredObjectIdentifier.instance);
|
||||||
fprintf(stderr, "time remaining=%u seconds ",
|
fprintf(stderr, "time remaining=%u seconds ", cov_data.timeRemaining);
|
||||||
cov_data.timeRemaining);
|
|
||||||
fprintf(stderr, "%s ",
|
fprintf(stderr, "%s ",
|
||||||
bactext_property_name(property_value.propertyIdentifier));
|
bactext_property_name(property_value.propertyIdentifier));
|
||||||
if (property_value.propertyArrayIndex != BACNET_ARRAY_ALL) {
|
if (property_value.propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||||
fprintf(stderr, "%u ",
|
fprintf(stderr, "%u ", property_value.propertyArrayIndex);
|
||||||
property_value.propertyArrayIndex);
|
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ void Send_I_Am(
|
|||||||
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (bytes_sent <= 0)
|
if (bytes_sent <= 0)
|
||||||
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n",
|
fprintf(stderr, "Failed to Send I-Am Reply (%s)!\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ void Send_Who_Is_Router_To_Network(
|
|||||||
BACNET_NPDU_DATA npdu_data;
|
BACNET_NPDU_DATA npdu_data;
|
||||||
|
|
||||||
npdu_encode_npdu_network(&npdu_data,
|
npdu_encode_npdu_network(&npdu_data,
|
||||||
NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK,
|
NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, false,
|
||||||
false,
|
|
||||||
MESSAGE_PRIORITY_NORMAL);
|
MESSAGE_PRIORITY_NORMAL);
|
||||||
/* fixme: should dnet/dlen/dadr be set in NPDU? */
|
/* fixme: should dnet/dlen/dadr be set in NPDU? */
|
||||||
pdu_len =
|
pdu_len =
|
||||||
@@ -112,8 +111,7 @@ void Send_I_Am_Router_To_Network(
|
|||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
|
|
||||||
npdu_encode_npdu_network(&npdu_data,
|
npdu_encode_npdu_network(&npdu_data,
|
||||||
NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK,
|
NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK, false,
|
||||||
false,
|
|
||||||
MESSAGE_PRIORITY_NORMAL);
|
MESSAGE_PRIORITY_NORMAL);
|
||||||
pdu_len =
|
pdu_len =
|
||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||||
@@ -157,9 +155,7 @@ void Send_Initialize_Routing_Table(
|
|||||||
BACNET_ROUTER_PORT *router_port;
|
BACNET_ROUTER_PORT *router_port;
|
||||||
unsigned i = 0; /* counter */
|
unsigned i = 0; /* counter */
|
||||||
|
|
||||||
npdu_encode_npdu_network(&npdu_data,
|
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_INIT_RT_TABLE, true,
|
||||||
NETWORK_MESSAGE_INIT_RT_TABLE,
|
|
||||||
true,
|
|
||||||
MESSAGE_PRIORITY_NORMAL);
|
MESSAGE_PRIORITY_NORMAL);
|
||||||
pdu_len =
|
pdu_len =
|
||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||||
@@ -208,10 +204,8 @@ void Send_Initialize_Routing_Table_Ack(
|
|||||||
int bytes_sent = 0;
|
int bytes_sent = 0;
|
||||||
BACNET_NPDU_DATA npdu_data;
|
BACNET_NPDU_DATA npdu_data;
|
||||||
|
|
||||||
npdu_encode_npdu_network(&npdu_data,
|
npdu_encode_npdu_network(&npdu_data, NETWORK_MESSAGE_INIT_RT_TABLE_ACK,
|
||||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK,
|
false, MESSAGE_PRIORITY_NORMAL);
|
||||||
false,
|
|
||||||
MESSAGE_PRIORITY_NORMAL);
|
|
||||||
pdu_len =
|
pdu_len =
|
||||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||||
/* encode the optional DNET list portion of the packet */
|
/* encode the optional DNET list portion of the packet */
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ uint8_t Send_Read_Property_Multiple_Request(
|
|||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
size_t max_pdu,
|
size_t max_pdu,
|
||||||
uint32_t device_id, /* destination device */
|
uint32_t device_id, /* destination device */
|
||||||
BACNET_READ_ACCESS_DATA *read_access_data)
|
BACNET_READ_ACCESS_DATA * read_access_data)
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS dest;
|
BACNET_ADDRESS dest;
|
||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
@@ -72,14 +72,10 @@ uint8_t Send_Read_Property_Multiple_Request(
|
|||||||
/* encode the NPDU portion of the packet */
|
/* encode the NPDU portion of the packet */
|
||||||
datalink_get_my_address(&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||||
pdu_len =
|
pdu_len = npdu_encode_pdu(&pdu[0], &dest, &my_address, &npdu_data);
|
||||||
npdu_encode_pdu(&pdu[0], &dest, &my_address,
|
|
||||||
&npdu_data);
|
|
||||||
/* encode the APDU portion of the packet */
|
/* encode the APDU portion of the packet */
|
||||||
len = rpm_encode_apdu(
|
len =
|
||||||
&pdu[pdu_len],
|
rpm_encode_apdu(&pdu[pdu_len], max_pdu - pdu_len, invoke_id,
|
||||||
max_pdu - pdu_len,
|
|
||||||
invoke_id,
|
|
||||||
read_access_data);
|
read_access_data);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -94,8 +90,7 @@ uint8_t Send_Read_Property_Multiple_Request(
|
|||||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||||
&npdu_data, &pdu[0], (uint16_t) pdu_len);
|
&npdu_data, &pdu[0], (uint16_t) pdu_len);
|
||||||
bytes_sent =
|
bytes_sent =
|
||||||
datalink_send_pdu(&dest, &npdu_data,
|
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
|
||||||
&pdu[0], pdu_len);
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
if (bytes_sent <= 0)
|
if (bytes_sent <= 0)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ static void MyRejectHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void My_Router_Handler(
|
static void My_Router_Handler(
|
||||||
BACNET_ADDRESS *src,
|
BACNET_ADDRESS * src,
|
||||||
BACNET_NPDU_DATA *npdu_data,
|
BACNET_NPDU_DATA * npdu_data,
|
||||||
uint8_t * npdu, /* PDU data */
|
uint8_t * npdu, /* PDU data */
|
||||||
uint16_t npdu_len)
|
uint16_t npdu_len)
|
||||||
{
|
{
|
||||||
uint16_t npdu_offset = 0;
|
uint16_t npdu_offset = 0;
|
||||||
@@ -122,26 +122,26 @@ static void My_Router_Handler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
port_mappings = npdu[0];
|
port_mappings = npdu[0];
|
||||||
printf("\nPort Mappings: %u\n",port_mappings);
|
printf("\nPort Mappings: %u\n", port_mappings);
|
||||||
npdu_offset = 1;
|
npdu_offset = 1;
|
||||||
npdu_len--;
|
npdu_len--;
|
||||||
while (npdu_len) {
|
while (npdu_len) {
|
||||||
len = decode_unsigned16(&npdu[npdu_offset], &dnet);
|
len = decode_unsigned16(&npdu[npdu_offset], &dnet);
|
||||||
printf("DNET=%hu, ",dnet);
|
printf("DNET=%hu, ", dnet);
|
||||||
npdu_offset += len;
|
npdu_offset += len;
|
||||||
npdu_len -= len;
|
npdu_len -= len;
|
||||||
if (!npdu_len) {
|
if (!npdu_len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
port_id = npdu[npdu_offset];
|
port_id = npdu[npdu_offset];
|
||||||
printf("Port ID=%u, ",port_id);
|
printf("Port ID=%u, ", port_id);
|
||||||
npdu_offset++;
|
npdu_offset++;
|
||||||
npdu_len--;
|
npdu_len--;
|
||||||
if (!npdu_len) {
|
if (!npdu_len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
port_info_len = npdu[npdu_offset];
|
port_info_len = npdu[npdu_offset];
|
||||||
printf("Port Info Length=%u, ",port_info_len);
|
printf("Port Info Length=%u, ", port_info_len);
|
||||||
npdu_offset++;
|
npdu_offset++;
|
||||||
npdu_len--;
|
npdu_len--;
|
||||||
printf("Port Info=\"");
|
printf("Port Info=\"");
|
||||||
@@ -150,7 +150,7 @@ static void My_Router_Handler(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j < port_info_len) {
|
if (j < port_info_len) {
|
||||||
printf("%02X",npdu[npdu_offset]);
|
printf("%02X", npdu[npdu_offset]);
|
||||||
npdu_offset++;
|
npdu_offset++;
|
||||||
npdu_len--;
|
npdu_len--;
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ static void My_NPDU_Handler(
|
|||||||
|
|
||||||
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
||||||
if (npdu_data.network_layer_message) {
|
if (npdu_data.network_layer_message) {
|
||||||
My_Router_Handler(src,&npdu_data,&pdu[apdu_offset],
|
My_Router_Handler(src, &npdu_data, &pdu[apdu_offset],
|
||||||
(uint16_t) (pdu_len - apdu_offset));
|
(uint16_t) (pdu_len - apdu_offset));
|
||||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||||
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
||||||
@@ -325,7 +325,8 @@ static void address_parse(BACNET_ADDRESS * dst,
|
|||||||
dst->mac_len = 6;
|
dst->mac_len = 6;
|
||||||
for (index = 0; index < 4; index++) {
|
for (index = 0; index < 4; index++) {
|
||||||
dst->mac[index] = mac[index];
|
dst->mac[index] = mac[index];
|
||||||
} encode_unsigned16(&dst->mac[4],
|
}
|
||||||
|
encode_unsigned16(&dst->mac[4],
|
||||||
port);
|
port);
|
||||||
} else {
|
} else {
|
||||||
count =
|
count =
|
||||||
@@ -364,22 +365,14 @@ int main(int argc, char *argv[]) {
|
|||||||
filename_remove_path(argv[0]));
|
filename_remove_path(argv[0]));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ((
|
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||||
argc > 1) && (
|
|
||||||
strcmp(argv[1],
|
|
||||||
"--help") == 0)) {
|
|
||||||
printf("Send BACnet Initialize-Routing-Table message to a network\r\n"
|
printf("Send BACnet Initialize-Routing-Table message to a network\r\n"
|
||||||
"and wait for responses. Displays their network information.\r\n"
|
"and wait for responses. Displays their network information.\r\n"
|
||||||
"\r\n"
|
"\r\n" "address:\r\n"
|
||||||
"address:\r\n"
|
|
||||||
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\r\n"
|
"MAC address in xx:xx:xx:xx:xx:xx format or IP x.x.x.x:port\r\n"
|
||||||
"DNET ID Len Info:\r\n"
|
"DNET ID Len Info:\r\n" "Port-info data:\r\n" " DNET:\r\n"
|
||||||
"Port-info data:\r\n"
|
" Destination network number 0-65534\r\n" " ID:\r\n"
|
||||||
" DNET:\r\n"
|
" Port Identifier number 0-255\r\n" " Info:\r\n"
|
||||||
" Destination network number 0-65534\r\n"
|
|
||||||
" ID:\r\n"
|
|
||||||
" Port Identifier number 0-255\r\n"
|
|
||||||
" Info:\r\n"
|
|
||||||
" Octet string of data, up to 255 octets\r\n"
|
" Octet string of data, up to 255 octets\r\n"
|
||||||
"To query the complete routing table, do not include any port-info.\r\n"
|
"To query the complete routing table, do not include any port-info.\r\n"
|
||||||
"To query using Initialize-Routing-Table message to 192.168.0.18:\r\n"
|
"To query using Initialize-Routing-Table message to 192.168.0.18:\r\n"
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ static void milliseconds_task_win32(
|
|||||||
|
|
||||||
/* functions used by the MS/TP state machine to put or get data */
|
/* functions used by the MS/TP state machine to put or get data */
|
||||||
uint16_t MSTP_Put_Receive(
|
uint16_t MSTP_Put_Receive(
|
||||||
volatile struct mstp_port_struct_t * mstp_port)
|
volatile struct mstp_port_struct_t *mstp_port)
|
||||||
{
|
{
|
||||||
(void) mstp_port;
|
(void) mstp_port;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ static void write_received_packet(
|
|||||||
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
||||||
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
||||||
incl_len = orig_len = 8 + max_data + 2;
|
incl_len = orig_len = 8 + max_data + 2;
|
||||||
} else {
|
} else {
|
||||||
incl_len = orig_len = 8;
|
incl_len = orig_len = 8;
|
||||||
|
|||||||
@@ -308,12 +308,12 @@ int Binary_Output_Encode_Property_APDU(
|
|||||||
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
apdu_len = encode_application_enumerated(&apdu[0], present_value);
|
||||||
break;
|
break;
|
||||||
case PROP_ACTIVE_TEXT:
|
case PROP_ACTIVE_TEXT:
|
||||||
characterstring_init_ansi(&char_string,"on" );
|
characterstring_init_ansi(&char_string, "on");
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
case PROP_INACTIVE_TEXT:
|
case PROP_INACTIVE_TEXT:
|
||||||
characterstring_init_ansi(&char_string,"off" );
|
characterstring_init_ansi(&char_string, "off");
|
||||||
apdu_len =
|
apdu_len =
|
||||||
encode_application_character_string(&apdu[0], &char_string);
|
encode_application_character_string(&apdu[0], &char_string);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -216,23 +216,21 @@ static void Init_DataLink(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup(void)
|
void cleanup(void) {
|
||||||
{
|
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||||
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
||||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||||
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
||||||
|
|
||||||
rpm_object = Read_Access_Data;
|
rpm_object = Read_Access_Data;
|
||||||
old_rpm_object = rpm_object;
|
old_rpm_object = rpm_object;
|
||||||
while (rpm_object) {
|
while (rpm_object) {
|
||||||
rpm_property = rpm_object->listOfProperties;
|
rpm_property = rpm_object->listOfProperties;
|
||||||
while (rpm_property) {
|
while (rpm_property) {
|
||||||
old_rpm_property = rpm_property;
|
old_rpm_property = rpm_property;
|
||||||
rpm_property = rpm_property->next;
|
rpm_property = rpm_property->next;
|
||||||
free(old_rpm_property);
|
free(old_rpm_property);
|
||||||
}
|
} old_rpm_object = rpm_object;
|
||||||
old_rpm_object = rpm_object;
|
|
||||||
rpm_object = rpm_object->next;
|
rpm_object = rpm_object->next;
|
||||||
free(old_rpm_object);
|
free(old_rpm_object);
|
||||||
}
|
}
|
||||||
@@ -251,14 +249,16 @@ int main(int argc, char *argv[]) {
|
|||||||
time_t timeout_seconds = 0;
|
time_t timeout_seconds = 0;
|
||||||
uint8_t invoke_id = 0;
|
uint8_t invoke_id = 0;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
uint8_t buffer[MAX_PDU] = {0};
|
uint8_t buffer[MAX_PDU] = {
|
||||||
|
0};
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object;
|
BACNET_READ_ACCESS_DATA *rpm_object;
|
||||||
BACNET_PROPERTY_REFERENCE *rpm_property;
|
BACNET_PROPERTY_REFERENCE *rpm_property;
|
||||||
|
|
||||||
|
|
||||||
if (argc < 5) {
|
if (argc < 5) {
|
||||||
printf("Usage: %s device-instance object-type object-instance "
|
printf("Usage: %s device-instance object-type object-instance "
|
||||||
"property index [object-type ...]\r\n", filename_remove_path(argv[0]));
|
"property index [object-type ...]\r\n",
|
||||||
|
filename_remove_path(argv[0]));
|
||||||
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
|
||||||
printf("device-instance:\r\n"
|
printf("device-instance:\r\n"
|
||||||
"BACnet Device Object Instance number that you are\r\n"
|
"BACnet Device Object Instance number that you are\r\n"
|
||||||
@@ -285,8 +285,7 @@ int main(int argc, char *argv[]) {
|
|||||||
"If the property is an array, individual elements can\r\n"
|
"If the property is an array, individual elements can\r\n"
|
||||||
"be read. If this parameter is missing and the property\r\n"
|
"be read. If this parameter is missing and the property\r\n"
|
||||||
"is an array, the entire array will be read.\r\n"
|
"is an array, the entire array will be read.\r\n"
|
||||||
"\r\nExample:\r\n"
|
"\r\nExample:\r\n" "If you want read the ALL property in\r\n"
|
||||||
"If you want read the ALL property in\r\n"
|
|
||||||
"Device object 123, you would use the following command:\r\n"
|
"Device object 123, you would use the following command:\r\n"
|
||||||
"%s 123 8 123 8 -1\r\n"
|
"%s 123 8 123 8 -1\r\n"
|
||||||
"If you want read the OPTIONAL property in\r\n"
|
"If you want read the OPTIONAL property in\r\n"
|
||||||
@@ -294,10 +293,8 @@ int main(int argc, char *argv[]) {
|
|||||||
"%s 123 8 123 80 -1\r\n"
|
"%s 123 8 123 80 -1\r\n"
|
||||||
"If you want read the REQUIRED property in\r\n"
|
"If you want read the REQUIRED property in\r\n"
|
||||||
"Device object 123, you would use the following command:\r\n"
|
"Device object 123, you would use the following command:\r\n"
|
||||||
"%s 123 8 123 105 -1\r\n",
|
"%s 123 8 123 105 -1\r\n", filename_remove_path(argv[0]),
|
||||||
filename_remove_path(argv[0]),
|
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||||
filename_remove_path(argv[0]),
|
|
||||||
filename_remove_path(argv[0]));
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -315,8 +312,7 @@ int main(int argc, char *argv[]) {
|
|||||||
arg_sets = 0;
|
arg_sets = 0;
|
||||||
while (rpm_object) {
|
while (rpm_object) {
|
||||||
tag_value_arg = 2 + (arg_sets * 4);
|
tag_value_arg = 2 + (arg_sets * 4);
|
||||||
rpm_object->object_type =
|
rpm_object->object_type = strtol(argv[tag_value_arg], NULL, 0);
|
||||||
strtol(argv[tag_value_arg], NULL, 0);
|
|
||||||
tag_value_arg++;
|
tag_value_arg++;
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (args_remaining <= 0) {
|
if (args_remaining <= 0) {
|
||||||
@@ -328,8 +324,7 @@ int main(int argc, char *argv[]) {
|
|||||||
rpm_object->object_type, MAX_BACNET_OBJECT_TYPE + 1);
|
rpm_object->object_type, MAX_BACNET_OBJECT_TYPE + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rpm_object->object_instance =
|
rpm_object->object_instance = strtol(argv[tag_value_arg], NULL, 0);
|
||||||
strtol(argv[tag_value_arg], NULL, 0);
|
|
||||||
tag_value_arg++;
|
tag_value_arg++;
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (args_remaining <= 0) {
|
if (args_remaining <= 0) {
|
||||||
@@ -350,12 +345,14 @@ int main(int argc, char *argv[]) {
|
|||||||
tag_value_arg++;
|
tag_value_arg++;
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (args_remaining <= 0) {
|
if (args_remaining <= 0) {
|
||||||
fprintf(stderr, "Error: not enough object property quads.\r\n");
|
fprintf(stderr,
|
||||||
|
"Error: not enough object property quads.\r\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
if (rpm_property->propertyIdentifier > MAX_BACNET_PROPERTY_ID) {
|
||||||
fprintf(stderr, "property=%u - it must be less than %u\r\n",
|
fprintf(stderr, "property=%u - it must be less than %u\r\n",
|
||||||
rpm_property->propertyIdentifier, MAX_BACNET_PROPERTY_ID + 1);
|
rpm_property->propertyIdentifier,
|
||||||
|
MAX_BACNET_PROPERTY_ID + 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rpm_property->propertyArrayIndex =
|
rpm_property->propertyArrayIndex =
|
||||||
@@ -413,10 +410,9 @@ int main(int argc, char *argv[]) {
|
|||||||
&Target_Address);
|
&Target_Address);
|
||||||
if (found) {
|
if (found) {
|
||||||
if (invoke_id == 0) {
|
if (invoke_id == 0) {
|
||||||
invoke_id = Send_Read_Property_Multiple_Request(
|
invoke_id =
|
||||||
&buffer[0],
|
Send_Read_Property_Multiple_Request(&buffer[0],
|
||||||
sizeof(buffer),
|
sizeof(buffer), Target_Device_Object_Instance,
|
||||||
Target_Device_Object_Instance,
|
|
||||||
Read_Access_Data);
|
Read_Access_Data);
|
||||||
} else if (tsm_invoke_id_free(invoke_id))
|
} else if (tsm_invoke_id_free(invoke_id))
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ int main(int argc, char *argv[]) {
|
|||||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* decode the command line parameters */
|
/* decode the command line parameters */ cov_data.
|
||||||
cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||||
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
||||||
cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0);
|
cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0);
|
||||||
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ static void Init_Service_Handlers(
|
|||||||
void)
|
void)
|
||||||
{
|
{
|
||||||
/* Note: this applications doesn't need to handle who-is
|
/* Note: this applications doesn't need to handle who-is
|
||||||
it is confusing for the user! */
|
it is confusing for the user! */
|
||||||
/* set the handler for all the services we don't implement
|
/* set the handler for all the services we don't implement
|
||||||
It is required to send the proper reject message... */
|
It is required to send the proper reject message... */
|
||||||
apdu_set_unrecognized_service_handler_handler
|
apdu_set_unrecognized_service_handler_handler
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ static void MyRejectHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void My_Router_Handler(
|
static void My_Router_Handler(
|
||||||
BACNET_ADDRESS *src,
|
BACNET_ADDRESS * src,
|
||||||
BACNET_NPDU_DATA *npdu_data,
|
BACNET_NPDU_DATA * npdu_data,
|
||||||
uint8_t * npdu, /* PDU data */
|
uint8_t * npdu, /* PDU data */
|
||||||
uint16_t npdu_len)
|
uint16_t npdu_len)
|
||||||
{
|
{
|
||||||
uint16_t npdu_offset = 0;
|
uint16_t npdu_offset = 0;
|
||||||
@@ -109,7 +109,7 @@ static void My_Router_Handler(
|
|||||||
printf("\nNetworks: ");
|
printf("\nNetworks: ");
|
||||||
while (npdu_len) {
|
while (npdu_len) {
|
||||||
len = decode_unsigned16(&npdu[npdu_offset], &dnet);
|
len = decode_unsigned16(&npdu[npdu_offset], &dnet);
|
||||||
printf("%hu",dnet);
|
printf("%hu", dnet);
|
||||||
npdu_len -= len;
|
npdu_len -= len;
|
||||||
if (npdu_len) {
|
if (npdu_len) {
|
||||||
printf(", ");
|
printf(", ");
|
||||||
@@ -141,7 +141,7 @@ void My_NPDU_Handler(
|
|||||||
|
|
||||||
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
||||||
if (npdu_data.network_layer_message) {
|
if (npdu_data.network_layer_message) {
|
||||||
My_Router_Handler(src,&npdu_data,&pdu[apdu_offset],
|
My_Router_Handler(src, &npdu_data, &pdu[apdu_offset],
|
||||||
(uint16_t) (pdu_len - apdu_offset));
|
(uint16_t) (pdu_len - apdu_offset));
|
||||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||||
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
if ((npdu_data.protocol_version == BACNET_PROTOCOL_VERSION) &&
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ extern "C" {
|
|||||||
bool decode_context_boolean(
|
bool decode_context_boolean(
|
||||||
uint8_t * apdu);
|
uint8_t * apdu);
|
||||||
|
|
||||||
int decode_context_boolean2(
|
int decode_context_boolean2(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
bool *boolean_value);
|
bool * boolean_value);
|
||||||
|
|
||||||
/* from clause 20.2.10 Encoding of a Bit String Value */
|
/* from clause 20.2.10 Encoding of a Bit String Value */
|
||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
@@ -126,7 +126,7 @@ extern "C" {
|
|||||||
|
|
||||||
int decode_context_bitstring(
|
int decode_context_bitstring(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_BIT_STRING * bit_string);
|
BACNET_BIT_STRING * bit_string);
|
||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
int encode_bitstring(
|
int encode_bitstring(
|
||||||
@@ -154,14 +154,14 @@ extern "C" {
|
|||||||
/* from clause 20.2.7 Encoding of a Double Precision Real Number Value */
|
/* from clause 20.2.7 Encoding of a Double Precision Real Number Value */
|
||||||
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
int encode_application_double(
|
int encode_application_double(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
double value);
|
double value);
|
||||||
|
|
||||||
int encode_context_double(
|
int encode_context_double(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int tag_number,
|
int tag_number,
|
||||||
double value);
|
double value);
|
||||||
|
|
||||||
/* from clause 20.2.14 Encoding of an Object Identifier Value */
|
/* from clause 20.2.14 Encoding of an Object Identifier Value */
|
||||||
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
||||||
@@ -171,11 +171,11 @@ int encode_context_double(
|
|||||||
uint16_t * object_type,
|
uint16_t * object_type,
|
||||||
uint32_t * instance);
|
uint32_t * instance);
|
||||||
|
|
||||||
int decode_context_object_id(
|
int decode_context_object_id(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
uint16_t *object_type,
|
uint16_t * object_type,
|
||||||
uint32_t * instance);
|
uint32_t * instance);
|
||||||
|
|
||||||
int encode_bacnet_object_id(
|
int encode_bacnet_object_id(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
@@ -210,7 +210,7 @@ int encode_context_double(
|
|||||||
BACNET_OCTET_STRING * octet_string);
|
BACNET_OCTET_STRING * octet_string);
|
||||||
int decode_context_octet_string(
|
int decode_context_octet_string(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_OCTET_STRING * octet_string);
|
BACNET_OCTET_STRING * octet_string);
|
||||||
|
|
||||||
|
|
||||||
@@ -231,10 +231,10 @@ int encode_context_double(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint32_t len_value,
|
uint32_t len_value,
|
||||||
BACNET_CHARACTER_STRING * char_string);
|
BACNET_CHARACTER_STRING * char_string);
|
||||||
int decode_context_character_string(
|
int decode_context_character_string(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_CHARACTER_STRING * char_string);
|
BACNET_CHARACTER_STRING * char_string);
|
||||||
|
|
||||||
|
|
||||||
/* from clause 20.2.4 Encoding of an Unsigned Integer Value */
|
/* from clause 20.2.4 Encoding of an Unsigned Integer Value */
|
||||||
@@ -254,10 +254,10 @@ int encode_context_double(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint32_t len_value,
|
uint32_t len_value,
|
||||||
uint32_t * value);
|
uint32_t * value);
|
||||||
int decode_context_unsigned(
|
int decode_context_unsigned(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
uint32_t * value);
|
uint32_t * value);
|
||||||
|
|
||||||
/* from clause 20.2.5 Encoding of a Signed Integer Value */
|
/* from clause 20.2.5 Encoding of a Signed Integer Value */
|
||||||
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
||||||
@@ -276,10 +276,10 @@ int encode_context_double(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint32_t len_value,
|
uint32_t len_value,
|
||||||
int32_t * value);
|
int32_t * value);
|
||||||
int decode_context_signed(
|
int decode_context_signed(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
int32_t * value);
|
int32_t * value);
|
||||||
|
|
||||||
|
|
||||||
/* from clause 20.2.11 Encoding of an Enumerated Value */
|
/* from clause 20.2.11 Encoding of an Enumerated Value */
|
||||||
@@ -289,10 +289,10 @@ int encode_context_double(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint32_t len_value,
|
uint32_t len_value,
|
||||||
int *value);
|
int *value);
|
||||||
int decode_context_enumerated(
|
int decode_context_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_value,
|
uint8_t tag_value,
|
||||||
int *value);
|
int *value);
|
||||||
int encode_bacnet_enumerated(
|
int encode_bacnet_enumerated(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int value);
|
int value);
|
||||||
@@ -320,13 +320,13 @@ int encode_context_double(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
int tag_number,
|
int tag_number,
|
||||||
BACNET_TIME * btime);
|
BACNET_TIME * btime);
|
||||||
int decode_application_time(
|
int decode_application_time(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_TIME * btime);
|
BACNET_TIME * btime);
|
||||||
int decode_context_bacnet_time(
|
int decode_context_bacnet_time(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_TIME * btime);
|
BACNET_TIME * btime);
|
||||||
|
|
||||||
|
|
||||||
/* BACnet Date */
|
/* BACnet Date */
|
||||||
@@ -354,10 +354,10 @@ int encode_context_double(
|
|||||||
int decode_application_date(
|
int decode_application_date(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DATE * bdate);
|
BACNET_DATE * bdate);
|
||||||
int decode_context_date(
|
int decode_context_date(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DATE * bdate);
|
BACNET_DATE * bdate);
|
||||||
|
|
||||||
/* from clause 20.1.2.4 max-segments-accepted */
|
/* from clause 20.1.2.4 max-segments-accepted */
|
||||||
/* and clause 20.1.2.5 max-APDU-length-accepted */
|
/* and clause 20.1.2.5 max-APDU-length-accepted */
|
||||||
|
|||||||
@@ -37,10 +37,10 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BACNET_OBJECT_ID objectIdentifier;
|
BACNET_OBJECT_ID objectIdentifier;
|
||||||
BACNET_PROPERTY_ID propertyIdentifier;
|
BACNET_PROPERTY_ID propertyIdentifier;
|
||||||
uint32_t arrayIndex;
|
uint32_t arrayIndex;
|
||||||
BACNET_OBJECT_ID deviceIndentifier;
|
BACNET_OBJECT_ID deviceIndentifier;
|
||||||
} BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE;
|
} BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE;
|
||||||
|
|
||||||
|
|
||||||
@@ -48,28 +48,25 @@ typedef struct {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
int bacapp_encode_device_obj_property_ref(
|
int bacapp_encode_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
||||||
|
|
||||||
int bacapp_encode_context_device_obj_property_ref(
|
int bacapp_encode_context_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
||||||
|
|
||||||
int bacapp_decode_device_obj_property_ref(
|
int bacapp_decode_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
||||||
|
|
||||||
int bacapp_decode_context_device_obj_property_ref(
|
int bacapp_decode_context_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#endif //_BAC_DEV_PROP_REF_H_
|
#endif //_BAC_DEV_PROP_REF_H_
|
||||||
|
|
||||||
|
|||||||
@@ -43,62 +43,60 @@
|
|||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BOOLEAN_VALUE,
|
BOOLEAN_VALUE,
|
||||||
BINARY_VALUE,
|
BINARY_VALUE,
|
||||||
EVENT_TYPE,
|
EVENT_TYPE,
|
||||||
POLARITY,
|
POLARITY,
|
||||||
PROGRAM_CHANGE,
|
PROGRAM_CHANGE,
|
||||||
PROGRAM_STATE,
|
PROGRAM_STATE,
|
||||||
REASON_FOR_HALT,
|
REASON_FOR_HALT,
|
||||||
RELIABILITY,
|
RELIABILITY,
|
||||||
STATE,
|
STATE,
|
||||||
SYSTEM_STATUS,
|
SYSTEM_STATUS,
|
||||||
UNITS,
|
UNITS,
|
||||||
UNSIGNED_VALUE,
|
UNSIGNED_VALUE,
|
||||||
LIFE_SAFETY_MODE,
|
LIFE_SAFETY_MODE,
|
||||||
LIFE_SAFETY_STATE,
|
LIFE_SAFETY_STATE,
|
||||||
} BACNET_PROPERTY_STATE_TYPE;
|
} BACNET_PROPERTY_STATE_TYPE;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BACNET_PROPERTY_STATE_TYPE tag;
|
BACNET_PROPERTY_STATE_TYPE tag;
|
||||||
union {
|
union {
|
||||||
bool booleanValue;
|
bool booleanValue;
|
||||||
BACNET_BINARY_PV binaryValue;
|
BACNET_BINARY_PV binaryValue;
|
||||||
BACNET_EVENT_TYPE eventType;
|
BACNET_EVENT_TYPE eventType;
|
||||||
BACNET_POLARITY polarity;
|
BACNET_POLARITY polarity;
|
||||||
BACNET_PROGRAM_REQUEST programChange;
|
BACNET_PROGRAM_REQUEST programChange;
|
||||||
BACNET_PROGRAM_STATE programState;
|
BACNET_PROGRAM_STATE programState;
|
||||||
BACNET_PROGRAM_ERROR programError;
|
BACNET_PROGRAM_ERROR programError;
|
||||||
BACNET_RELIABILITY reliability;
|
BACNET_RELIABILITY reliability;
|
||||||
BACNET_EVENT_STATE state;
|
BACNET_EVENT_STATE state;
|
||||||
BACNET_DEVICE_STATUS systemStatus;
|
BACNET_DEVICE_STATUS systemStatus;
|
||||||
BACNET_ENGINEERING_UNITS units;
|
BACNET_ENGINEERING_UNITS units;
|
||||||
uint32_t unsignedValue;
|
uint32_t unsignedValue;
|
||||||
BACNET_LIFE_SAFETY_MODE lifeSafetyMode;
|
BACNET_LIFE_SAFETY_MODE lifeSafetyMode;
|
||||||
BACNET_LIFE_SAFETY_STATE lifeSafetyState;
|
BACNET_LIFE_SAFETY_STATE lifeSafetyState;
|
||||||
} state;
|
} state;
|
||||||
} BACNET_PROPERTY_STATE;
|
} BACNET_PROPERTY_STATE;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
int bacapp_decode_property_state(
|
int bacapp_decode_property_state(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_PROPERTY_STATE * value);
|
BACNET_PROPERTY_STATE * value);
|
||||||
|
|
||||||
int bacapp_decode_context_property_state(
|
int bacapp_decode_context_property_state(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_PROPERTY_STATE * value);
|
BACNET_PROPERTY_STATE * value);
|
||||||
|
|
||||||
int bacapp_encode_property_state(
|
int bacapp_encode_property_state(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_PROPERTY_STATE * value);
|
BACNET_PROPERTY_STATE * value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#endif // _BAC_PROP_STATES_H_
|
#endif // _BAC_PROP_STATES_H_
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ extern "C" {
|
|||||||
|
|
||||||
int decode_context_real(
|
int decode_context_real(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
float *real_value);
|
float *real_value);
|
||||||
int encode_bacnet_real(
|
int encode_bacnet_real(
|
||||||
float value,
|
float value,
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ extern "C" {
|
|||||||
uint8_t Send_Read_Property_Multiple_Request(
|
uint8_t Send_Read_Property_Multiple_Request(
|
||||||
uint8_t * pdu,
|
uint8_t * pdu,
|
||||||
size_t max_pdu,
|
size_t max_pdu,
|
||||||
uint32_t device_id, /* destination device */
|
uint32_t device_id, /* destination device */
|
||||||
BACNET_READ_ACCESS_DATA *read_access_data);
|
BACNET_READ_ACCESS_DATA * read_access_data);
|
||||||
|
|
||||||
/* returns the invoke ID for confirmed request, or 0 if failed */
|
/* returns the invoke ID for confirmed request, or 0 if failed */
|
||||||
uint8_t Send_Write_Property_Request(
|
uint8_t Send_Write_Property_Request(
|
||||||
|
|||||||
@@ -138,19 +138,19 @@ extern "C" {
|
|||||||
void datetime_time_wildcard_set(
|
void datetime_time_wildcard_set(
|
||||||
BACNET_TIME * btime);
|
BACNET_TIME * btime);
|
||||||
|
|
||||||
int bacapp_encode_context_datetime(
|
int bacapp_encode_context_datetime(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DATE_TIME * value);
|
BACNET_DATE_TIME * value);
|
||||||
|
|
||||||
int bacapp_decode_datetime(
|
int bacapp_decode_datetime(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DATE_TIME * value);
|
BACNET_DATE_TIME * value);
|
||||||
|
|
||||||
int bacapp_decode_context_datetime(
|
int bacapp_decode_context_datetime(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DATE_TIME * value);
|
BACNET_DATE_TIME * value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,20 +44,17 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#if DEBUG_ENABLED
|
#if DEBUG_ENABLED
|
||||||
void debug_printf(
|
void debug_printf(
|
||||||
const char *format,
|
const char *format,
|
||||||
...);
|
...);
|
||||||
#else
|
#else
|
||||||
static void debug_printf(
|
static void debug_printf(
|
||||||
const char *format,
|
const char *format,
|
||||||
...)
|
...) {
|
||||||
{
|
format = format;
|
||||||
format = format;
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+116
-116
@@ -44,8 +44,8 @@
|
|||||||
#include "bacdevobjpropref.h"
|
#include "bacdevobjpropref.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CHANGE_OF_VALUE_BITS,
|
CHANGE_OF_VALUE_BITS,
|
||||||
CHANGE_OF_VALUE_REAL
|
CHANGE_OF_VALUE_REAL
|
||||||
} CHANGE_OF_VALUE_TYPE;
|
} CHANGE_OF_VALUE_TYPE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -53,103 +53,103 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct BACnet_Event_Notification_Data {
|
typedef struct BACnet_Event_Notification_Data {
|
||||||
uint32_t processIdentifier;
|
uint32_t processIdentifier;
|
||||||
BACNET_OBJECT_ID initiatingObjectIdentifier;
|
BACNET_OBJECT_ID initiatingObjectIdentifier;
|
||||||
BACNET_OBJECT_ID eventObjectIdentifier;
|
BACNET_OBJECT_ID eventObjectIdentifier;
|
||||||
BACNET_TIMESTAMP timeStamp;
|
BACNET_TIMESTAMP timeStamp;
|
||||||
uint32_t notificationClass;
|
uint32_t notificationClass;
|
||||||
uint8_t priority;
|
uint8_t priority;
|
||||||
BACNET_EVENT_TYPE eventType;
|
BACNET_EVENT_TYPE eventType;
|
||||||
BACNET_CHARACTER_STRING* messageText; /* OPTIONAL - Set to NULL if not being used */
|
BACNET_CHARACTER_STRING *messageText; /* OPTIONAL - Set to NULL if not being used */
|
||||||
BACNET_NOTIFY_TYPE notifyType;
|
BACNET_NOTIFY_TYPE notifyType;
|
||||||
bool ackRequired;
|
bool ackRequired;
|
||||||
BACNET_EVENT_STATE fromState;
|
BACNET_EVENT_STATE fromState;
|
||||||
BACNET_EVENT_STATE toState;
|
BACNET_EVENT_STATE toState;
|
||||||
/*
|
/*
|
||||||
** Each of these structures in the union maps to a particular eventtype
|
** Each of these structures in the union maps to a particular eventtype
|
||||||
** Based on BACnetNotificationParameters
|
** Based on BACnetNotificationParameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
union {
|
union {
|
||||||
/*
|
/*
|
||||||
** EVENT_CHANGE_OF_BITSTRING
|
** EVENT_CHANGE_OF_BITSTRING
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
BACNET_BIT_STRING referencedBitString;
|
BACNET_BIT_STRING referencedBitString;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
} changeOfBitstring;
|
} changeOfBitstring;
|
||||||
/*
|
/*
|
||||||
** EVENT_CHANGE_OF_STATE
|
** EVENT_CHANGE_OF_STATE
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
BACNET_PROPERTY_STATE newState;
|
BACNET_PROPERTY_STATE newState;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
} changeOfState;
|
} changeOfState;
|
||||||
/*
|
/*
|
||||||
** EVENT_CHANGE_OF_VALUE
|
** EVENT_CHANGE_OF_VALUE
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
union {
|
union {
|
||||||
BACNET_BIT_STRING changedBits;
|
BACNET_BIT_STRING changedBits;
|
||||||
float changeValue;
|
float changeValue;
|
||||||
} newValue;
|
} newValue;
|
||||||
CHANGE_OF_VALUE_TYPE tag;
|
CHANGE_OF_VALUE_TYPE tag;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
} changeOfValue;
|
} changeOfValue;
|
||||||
/*
|
/*
|
||||||
** EVENT_COMMAND_FAILURE
|
** EVENT_COMMAND_FAILURE
|
||||||
**
|
**
|
||||||
** Not Supported!
|
** Not Supported!
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
** EVENT_FLOATING_LIMIT
|
** EVENT_FLOATING_LIMIT
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
float referenceValue;
|
float referenceValue;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
float setPointValue;
|
float setPointValue;
|
||||||
float errorLimit;
|
float errorLimit;
|
||||||
} floatingLimit;
|
} floatingLimit;
|
||||||
/*
|
/*
|
||||||
** EVENT_OUT_OF_RANGE
|
** EVENT_OUT_OF_RANGE
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
float exceedingValue;
|
float exceedingValue;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
float deadband;
|
float deadband;
|
||||||
float exceededLimit;
|
float exceededLimit;
|
||||||
} outOfRange;
|
} outOfRange;
|
||||||
/*
|
/*
|
||||||
** EVENT_CHANGE_OF_LIFE_SAFETY
|
** EVENT_CHANGE_OF_LIFE_SAFETY
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
BACNET_LIFE_SAFETY_STATE newState;
|
BACNET_LIFE_SAFETY_STATE newState;
|
||||||
BACNET_LIFE_SAFETY_MODE newMode;
|
BACNET_LIFE_SAFETY_MODE newMode;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
BACNET_LIFE_SAFETY_OPERATION operationExpected;
|
BACNET_LIFE_SAFETY_OPERATION operationExpected;
|
||||||
} changeOfLifeSafety;
|
} changeOfLifeSafety;
|
||||||
/*
|
/*
|
||||||
** EVENT_EXTENDED
|
** EVENT_EXTENDED
|
||||||
**
|
**
|
||||||
** Not Supported!
|
** Not Supported!
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
** EVENT_BUFFER_READY
|
** EVENT_BUFFER_READY
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE bufferProperty;
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE bufferProperty;
|
||||||
uint32_t previousNotification;
|
uint32_t previousNotification;
|
||||||
uint32_t currentNotification;
|
uint32_t currentNotification;
|
||||||
} bufferReady;
|
} bufferReady;
|
||||||
/*
|
/*
|
||||||
** EVENT_UNSIGNED_RANGE
|
** EVENT_UNSIGNED_RANGE
|
||||||
*/
|
*/
|
||||||
struct {
|
struct {
|
||||||
uint32_t exceedingValue;
|
uint32_t exceedingValue;
|
||||||
BACNET_BIT_STRING statusFlags;
|
BACNET_BIT_STRING statusFlags;
|
||||||
uint32_t exceededLimit;
|
uint32_t exceededLimit;
|
||||||
} unsignedRange;
|
} unsignedRange;
|
||||||
} notificationParams;
|
} notificationParams;
|
||||||
} BACNET_EVENT_NOTIFICATION_DATA;
|
} BACNET_EVENT_NOTIFICATION_DATA;
|
||||||
|
|
||||||
|
|
||||||
@@ -162,48 +162,48 @@ extern "C" {
|
|||||||
** Creates a Confirmed Event Notification APDU
|
** Creates a Confirmed Event Notification APDU
|
||||||
**
|
**
|
||||||
****************************************************/
|
****************************************************/
|
||||||
int cevent_notify_encode_apdu(
|
int cevent_notify_encode_apdu(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t invoke_id,
|
uint8_t invoke_id,
|
||||||
BACNET_EVENT_NOTIFICATION_DATA * data);
|
BACNET_EVENT_NOTIFICATION_DATA * data);
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
**
|
**
|
||||||
** Creates an Unconfirmed Event Notification APDU
|
** Creates an Unconfirmed Event Notification APDU
|
||||||
**
|
**
|
||||||
****************************************************/
|
****************************************************/
|
||||||
int uevent_notify_encode_apdu(
|
int uevent_notify_encode_apdu(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_EVENT_NOTIFICATION_DATA * data);
|
BACNET_EVENT_NOTIFICATION_DATA * data);
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
**
|
**
|
||||||
** Encodes the service data part of Event Notification
|
** Encodes the service data part of Event Notification
|
||||||
**
|
**
|
||||||
****************************************************/
|
****************************************************/
|
||||||
int event_notify_encode_service_request(
|
int event_notify_encode_service_request(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_EVENT_NOTIFICATION_DATA * data);
|
BACNET_EVENT_NOTIFICATION_DATA * data);
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
**
|
**
|
||||||
** Decodes the service data part of Event Notification
|
** Decodes the service data part of Event Notification
|
||||||
**
|
**
|
||||||
****************************************************/
|
****************************************************/
|
||||||
int event_notify_decode_service_request(
|
int event_notify_decode_service_request(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
unsigned apdu_len,
|
unsigned apdu_len,
|
||||||
BACNET_EVENT_NOTIFICATION_DATA * data);
|
BACNET_EVENT_NOTIFICATION_DATA * data);
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
**
|
**
|
||||||
** Sends an Unconfirmed Event Notifcation to a dest
|
** Sends an Unconfirmed Event Notifcation to a dest
|
||||||
**
|
**
|
||||||
****************************************************/
|
****************************************************/
|
||||||
int uevent_notify_send(
|
int uevent_notify_send(
|
||||||
uint8_t * buffer,
|
uint8_t * buffer,
|
||||||
BACNET_EVENT_NOTIFICATION_DATA * data,
|
BACNET_EVENT_NOTIFICATION_DATA * data,
|
||||||
BACNET_ADDRESS *dest);
|
BACNET_ADDRESS * dest);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ extern "C" {
|
|||||||
|
|
||||||
/* copy len bytes from src to offset of dest if there is enough space. */
|
/* copy len bytes from src to offset of dest if there is enough space. */
|
||||||
/* returns 0 if there is not enough space, or the number of bytes copied. */
|
/* returns 0 if there is not enough space, or the number of bytes copied. */
|
||||||
size_t memcopy(
|
size_t memcopy(
|
||||||
void * dest,
|
void *dest,
|
||||||
void * src,
|
void *src,
|
||||||
size_t offset, /* where in dest to put the data */
|
size_t offset, /* where in dest to put the data */
|
||||||
size_t len, /* amount of data to copy */
|
size_t len, /* amount of data to copy */
|
||||||
size_t max); /* total size of destination */
|
size_t max); /* total size of destination */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ extern "C" {
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
size_t max_apdu,
|
size_t max_apdu,
|
||||||
uint8_t invoke_id,
|
uint8_t invoke_id,
|
||||||
BACNET_READ_ACCESS_DATA *read_access_data);
|
BACNET_READ_ACCESS_DATA * read_access_data);
|
||||||
|
|
||||||
/* decode the object portion of the service request only */
|
/* decode the object portion of the service request only */
|
||||||
int rpm_decode_object_id(
|
int rpm_decode_object_id(
|
||||||
|
|||||||
@@ -38,20 +38,20 @@
|
|||||||
#include "bacdcode.h"
|
#include "bacdcode.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TIME_STAMP_TIME = 0,
|
TIME_STAMP_TIME = 0,
|
||||||
TIME_STAMP_SEQUENCE = 1,
|
TIME_STAMP_SEQUENCE = 1,
|
||||||
TIME_STAMP_DATETIME = 2,
|
TIME_STAMP_DATETIME = 2,
|
||||||
} BACNET_TIMESTAMP_TAG;
|
} BACNET_TIMESTAMP_TAG;
|
||||||
|
|
||||||
typedef uint8_t TYPE_BACNET_TIMESTAMP_TYPE;
|
typedef uint8_t TYPE_BACNET_TIMESTAMP_TYPE;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
TYPE_BACNET_TIMESTAMP_TYPE tag;
|
TYPE_BACNET_TIMESTAMP_TYPE tag;
|
||||||
union {
|
union {
|
||||||
BACNET_TIME time;
|
BACNET_TIME time;
|
||||||
uint16_t sequenceNum;
|
uint16_t sequenceNum;
|
||||||
BACNET_DATE_TIME dateTime;
|
BACNET_DATE_TIME dateTime;
|
||||||
} value;
|
} value;
|
||||||
} BACNET_TIMESTAMP;
|
} BACNET_TIMESTAMP;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -60,19 +60,17 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int bacapp_encode_context_timestamp(
|
int bacapp_encode_context_timestamp(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_TIMESTAMP * value);
|
BACNET_TIMESTAMP * value);
|
||||||
|
|
||||||
int bacapp_decode_context_timestamp(
|
int bacapp_decode_context_timestamp(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_TIMESTAMP * value);
|
BACNET_TIMESTAMP * value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef BUILD_DLL
|
#ifdef BUILD_DLL
|
||||||
#define DLL_EXPORT __declspec(dllexport)
|
#define DLL_EXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define DLL_EXPORT __declspec(dllimport)
|
#define DLL_EXPORT __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DLL_EXPORT SomeFunction(const LPCSTR sometext);
|
void DLL_EXPORT SomeFunction(
|
||||||
|
const LPCSTR sometext);
|
||||||
|
|
||||||
#endif // __MAIN_H__
|
#endif // __MAIN_H__
|
||||||
|
|||||||
@@ -328,4 +328,3 @@ int Device_Encode_Property_APDU(
|
|||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,18 +105,17 @@ static struct mstp_flag_t {
|
|||||||
} MSTP_Flag;
|
} MSTP_Flag;
|
||||||
|
|
||||||
/* data passed to receive handler */
|
/* data passed to receive handler */
|
||||||
struct mstp_packet_info_t
|
struct mstp_packet_info_t {
|
||||||
{
|
|
||||||
/* A Boolean flag set to TRUE by the Receive State Machine */
|
/* A Boolean flag set to TRUE by the Receive State Machine */
|
||||||
/* if a valid frame is received. */
|
/* if a valid frame is received. */
|
||||||
unsigned valid_frame:1;
|
unsigned valid_frame:1;
|
||||||
/* preamble flags */
|
/* preamble flags */
|
||||||
unsigned preamble1:1;
|
unsigned preamble1:1;
|
||||||
unsigned preamble2:1;
|
unsigned preamble2:1;
|
||||||
uint8_t header[6]; /* buffer to put the header bytes */
|
uint8_t header[6]; /* buffer to put the header bytes */
|
||||||
uint8_t *buffer; /* buffer to put the data */
|
uint8_t *buffer; /* buffer to put the data */
|
||||||
uint8_t buffer_len; /* buffer to put the data */
|
uint8_t buffer_len; /* buffer to put the data */
|
||||||
uint8_t index; /* index into receive buffer */
|
uint8_t index; /* index into receive buffer */
|
||||||
};
|
};
|
||||||
static struct nitoo_packet_info_t MSTP_Receive_Packet;
|
static struct nitoo_packet_info_t MSTP_Receive_Packet;
|
||||||
|
|
||||||
@@ -286,10 +285,12 @@ static void MSTP_Send_Frame(
|
|||||||
#if 0
|
#if 0
|
||||||
/* return true if the packet is good. */
|
/* return true if the packet is good. */
|
||||||
/* note: buffer should include the CRC as the last byte */
|
/* note: buffer should include the CRC as the last byte */
|
||||||
static bool crc_header_good(uint8_t *buffer, uint8_t len)
|
static bool crc_header_good(
|
||||||
|
uint8_t * buffer,
|
||||||
|
uint8_t len)
|
||||||
{
|
{
|
||||||
uint8_t i; /* loop counter */
|
uint8_t i; /* loop counter */
|
||||||
uint8_t crc8 = 0xFF; /* loop counter */
|
uint8_t crc8 = 0xFF; /* loop counter */
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
crc8 = CRC_Calc_Header(buffer[i], crc8);
|
crc8 = CRC_Calc_Header(buffer[i], crc8);
|
||||||
@@ -299,9 +300,10 @@ static bool crc_header_good(uint8_t *buffer, uint8_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void mstp_receive_handler(void)
|
static void mstp_receive_handler(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint8_t data_register = 0; /* data from UART */
|
uint8_t data_register = 0; /* data from UART */
|
||||||
|
|
||||||
if (RS485_ReceiveError()) {
|
if (RS485_ReceiveError()) {
|
||||||
timer_silence_reset();
|
timer_silence_reset();
|
||||||
@@ -327,13 +329,15 @@ static void mstp_receive_handler(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DataLength == 0) {
|
if (DataLength == 0) {
|
||||||
MSTP_Receive_Packet.header[MSTP_Receive_Packet.index] = data_register;
|
MSTP_Receive_Packet.header[MSTP_Receive_Packet.index] =
|
||||||
|
data_register;
|
||||||
if (MSTP_Receive_Packet.index == 5) {
|
if (MSTP_Receive_Packet.index == 5) {
|
||||||
if (crc_header_good(MSTP_Receive_Packet.header, 6)) {
|
if (crc_header_good(MSTP_Receive_Packet.header, 6)) {
|
||||||
FrameType = MSTP_Receive_Packet.header[0];
|
FrameType = MSTP_Receive_Packet.header[0];
|
||||||
DestinationAddress = MSTP_Receive_Packet.header[1];
|
DestinationAddress = MSTP_Receive_Packet.header[1];
|
||||||
SourceAddress = MSTP_Receive_Packet.header[2];
|
SourceAddress = MSTP_Receive_Packet.header[2];
|
||||||
DataLength = (MSTP_Receive_Packet.header[3] * 256) +
|
DataLength =
|
||||||
|
(MSTP_Receive_Packet.header[3] * 256) +
|
||||||
MSTP_Receive_Packet.header[4];
|
MSTP_Receive_Packet.header[4];
|
||||||
if (DataLength == 0) {
|
if (DataLength == 0) {
|
||||||
MSTP_Receive_Packet.valid_frame = true;
|
MSTP_Receive_Packet.valid_frame = true;
|
||||||
@@ -347,11 +351,12 @@ static void mstp_receive_handler(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MSTP_Receive_Packet.buffer[MSTP_Receive_Packet.index] = data_register;
|
MSTP_Receive_Packet.buffer[MSTP_Receive_Packet.index] =
|
||||||
|
data_register;
|
||||||
if (packet_info->index == packet_info->len) {
|
if (packet_info->index == packet_info->len) {
|
||||||
/* PDU length ended */
|
/* PDU length ended */
|
||||||
packet_info->ready = true;
|
packet_info->ready = true;
|
||||||
} else if (packet_info->index >= sizeof(packet_info->buffer)){
|
} else if (packet_info->index >= sizeof(packet_info->buffer)) {
|
||||||
/* exceeded the size of the storage */
|
/* exceeded the size of the storage */
|
||||||
packet_info->len = packet_info->index;
|
packet_info->len = packet_info->index;
|
||||||
packet_info->ready = true;
|
packet_info->ready = true;
|
||||||
@@ -361,7 +366,8 @@ static void mstp_receive_handler(void)
|
|||||||
MSTP_Receive_Packet.index++;
|
MSTP_Receive_Packet.index++;
|
||||||
if (packet_info->ready) {
|
if (packet_info->ready) {
|
||||||
/* validate the CRC */
|
/* validate the CRC */
|
||||||
if (!lrc_packet_good(packet_info->buffer,packet_info->len+1)) {
|
if (!lrc_packet_good(packet_info->buffer,
|
||||||
|
packet_info->len + 1)) {
|
||||||
packet_info->ready = false;
|
packet_info->ready = false;
|
||||||
}
|
}
|
||||||
/* pull off the CRC */
|
/* pull off the CRC */
|
||||||
@@ -616,9 +622,8 @@ static void MSTP_Slave_Node_FSM(
|
|||||||
MSTP_Flag.ReceivePacketPending = true;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_TEST_REQUEST:
|
case FRAME_TYPE_TEST_REQUEST:
|
||||||
MSTP_Send_Frame(FRAME_TYPE_TEST_RESPONSE,
|
MSTP_Send_Frame(FRAME_TYPE_TEST_RESPONSE, SourceAddress,
|
||||||
SourceAddress, This_Station, &InputBuffer[0],
|
This_Station, &InputBuffer[0], DataLength);
|
||||||
DataLength);
|
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_TEST_RESPONSE:
|
case FRAME_TYPE_TEST_RESPONSE:
|
||||||
default:
|
default:
|
||||||
@@ -634,8 +639,8 @@ static void MSTP_Slave_Node_FSM(
|
|||||||
/* and enter the IDLE state to wait for the next frame. */
|
/* and enter the IDLE state to wait for the next frame. */
|
||||||
/* Note: optimized such that we are never a client */
|
/* Note: optimized such that we are never a client */
|
||||||
MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
|
MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
|
||||||
TransmitPacketDest, This_Station,
|
TransmitPacketDest, This_Station, (uint8_t *) & TransmitPacket[0],
|
||||||
(uint8_t *) & TransmitPacket[0], TransmitPacketLen);
|
TransmitPacketLen);
|
||||||
MSTP_Flag.TransmitPacketPending = false;
|
MSTP_Flag.TransmitPacketPending = false;
|
||||||
MSTP_Flag.ReceivePacketPending = false;
|
MSTP_Flag.ReceivePacketPending = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ int Encode_Property_APDU(
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if MAX_BINARY_VALUES
|
#if MAX_BINARY_VALUES
|
||||||
case OBJECT_BINARY_VALUE:
|
case OBJECT_BINARY_VALUE:
|
||||||
if (Binary_Value_Valid_Instance(rp_data->object_instance)) {
|
if (Binary_Value_Valid_Instance(rp_data->object_instance)) {
|
||||||
apdu_len =
|
apdu_len =
|
||||||
Binary_Value_Encode_Property_APDU(&apdu[0],
|
Binary_Value_Encode_Property_APDU(&apdu[0],
|
||||||
|
|||||||
@@ -36,24 +36,24 @@
|
|||||||
/* This file has been customized for use with ATMEGA168 */
|
/* This file has been customized for use with ATMEGA168 */
|
||||||
#if defined(__AVR_ATmega168__)
|
#if defined(__AVR_ATmega168__)
|
||||||
/* USART defines for RS-485 port */
|
/* USART defines for RS-485 port */
|
||||||
#define UCSRB UCSR0B
|
#define UCSRB UCSR0B
|
||||||
#define TXEN TXEN0
|
#define TXEN TXEN0
|
||||||
#define RXEN RXEN0
|
#define RXEN RXEN0
|
||||||
#define UCSRC UCSR0C
|
#define UCSRC UCSR0C
|
||||||
#define UCSZ1 UCSZ01
|
#define UCSZ1 UCSZ01
|
||||||
#define UCSZ0 UCSZ00
|
#define UCSZ0 UCSZ00
|
||||||
#define UCSRA UCSR0A
|
#define UCSRA UCSR0A
|
||||||
#define U2X U2X0
|
#define U2X U2X0
|
||||||
#define UBRRL UBRR0
|
#define UBRRL UBRR0
|
||||||
#define UCSRA UCSR0A
|
#define UCSRA UCSR0A
|
||||||
#define UDRE UDRE0
|
#define UDRE UDRE0
|
||||||
#define UDR UDR0
|
#define UDR UDR0
|
||||||
#define TXC TXC0
|
#define TXC TXC0
|
||||||
#define FE FE0
|
#define FE FE0
|
||||||
#define DOR DOR0
|
#define DOR DOR0
|
||||||
#define UPE UPE0
|
#define UPE UPE0
|
||||||
#define DOR DOR0
|
#define DOR DOR0
|
||||||
#define RXC RXC0
|
#define RXC RXC0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ bool timer_silence_elapsed(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_silence_reset(void)
|
void timer_silence_reset(
|
||||||
|
void)
|
||||||
{
|
{
|
||||||
uint8_t sreg;
|
uint8_t sreg;
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ static void snap_received_packet(
|
|||||||
mtu[30] = mstp_port->HeaderCRCActual;
|
mtu[30] = mstp_port->HeaderCRCActual;
|
||||||
mtu_len = 31;
|
mtu_len = 31;
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
||||||
for (i = 0; i < max_data; i++) {
|
for (i = 0; i < max_data; i++) {
|
||||||
mtu[31 + i] = mstp_port->InputBuffer[i];
|
mtu[31 + i] = mstp_port->InputBuffer[i];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,8 +217,8 @@ static void write_received_packet(
|
|||||||
fwrite(header, sizeof(header), 1, pFile);
|
fwrite(header, sizeof(header), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
|
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
|
||||||
fwrite((char *)&(mstp_port->DataCRCActualMSB), 1, 1, pFile);
|
fwrite((char *) &(mstp_port->DataCRCActualMSB), 1, 1, pFile);
|
||||||
fwrite((char *)&(mstp_port->DataCRCActualLSB), 1, 1, pFile);
|
fwrite((char *) &(mstp_port->DataCRCActualLSB), 1, 1, pFile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "rx_fsm: failed to open %s: %s\n", Capture_Filename,
|
fprintf(stderr, "rx_fsm: failed to open %s: %s\n", Capture_Filename,
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ bool bip_init(
|
|||||||
bip_set_socket(-1);
|
bip_set_socket(-1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Enables transmission and receipt of broadcast messages on the socket.*/
|
/* Enables transmission and receipt of broadcast messages on the socket. */
|
||||||
rv = setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, (char *) &value,
|
rv = setsockopt(sock_fd, SOL_SOCKET, SO_BROADCAST, (char *) &value,
|
||||||
sizeof(value));
|
sizeof(value));
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
|
|||||||
@@ -294,14 +294,13 @@ static void Init_DataLink(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(
|
int main(int argc, char *argv[]) {
|
||||||
int argc,
|
BACNET_ADDRESS src = {
|
||||||
char *argv[])
|
0}; /* address where message came from */
|
||||||
{
|
|
||||||
BACNET_ADDRESS src = { 0 }; /* address where message came from */
|
|
||||||
uint16_t pdu_len = 0;
|
uint16_t pdu_len = 0;
|
||||||
unsigned timeout = 100; /* milliseconds */
|
unsigned timeout = 100; /* milliseconds */
|
||||||
BACNET_ADDRESS my_address, broadcast_address;
|
BACNET_ADDRESS my_address,
|
||||||
|
broadcast_address;
|
||||||
|
|
||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ static void write_received_packet(
|
|||||||
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
fwrite(&ts_sec, sizeof(ts_sec), 1, pFile);
|
||||||
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
fwrite(&ts_usec, sizeof(ts_usec), 1, pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
|
max_data = min(mstp_port->InputBufferSize, mstp_port->DataLength);
|
||||||
incl_len = orig_len = 8 + max_data + 2;
|
incl_len = orig_len = 8 + max_data + 2;
|
||||||
} else {
|
} else {
|
||||||
incl_len = orig_len = 8;
|
incl_len = orig_len = 8;
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ int arf_decode_service_request(
|
|||||||
int tag_len = 0;
|
int tag_len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ int awf_decode_service_request(
|
|||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int32_t signed_value = 0;
|
int32_t signed_value = 0;
|
||||||
uint32_t unsigned_value = 0;
|
uint32_t unsigned_value = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
|
|||||||
+417
-439
File diff suppressed because it is too large
Load Diff
+114
-122
@@ -42,143 +42,129 @@
|
|||||||
|
|
||||||
int bacapp_encode_context_device_obj_property_ref(
|
int bacapp_encode_context_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
|
|
||||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = bacapp_encode_device_obj_property_ref(&apdu[apdu_len], value);
|
len = bacapp_encode_device_obj_property_ref(&apdu[apdu_len], value);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_encode_device_obj_property_ref(
|
int bacapp_encode_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
|
|
||||||
len = encode_context_object_id(&apdu[apdu_len], 0,
|
len =
|
||||||
value->objectIdentifier.type,
|
encode_context_object_id(&apdu[apdu_len], 0,
|
||||||
value->objectIdentifier.instance);
|
value->objectIdentifier.type, value->objectIdentifier.instance);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_context_enumerated(&apdu[apdu_len], 1,
|
len =
|
||||||
value->propertyIdentifier);
|
encode_context_enumerated(&apdu[apdu_len], 1,
|
||||||
apdu_len += len;
|
value->propertyIdentifier);
|
||||||
|
apdu_len += len;
|
||||||
|
|
||||||
if ( value->arrayIndex > 0 )
|
if (value->arrayIndex > 0) {
|
||||||
{
|
len = encode_context_unsigned(&apdu[apdu_len], 2, value->arrayIndex);
|
||||||
len = encode_context_unsigned(&apdu[apdu_len], 2,
|
apdu_len += len;
|
||||||
value->arrayIndex);
|
}
|
||||||
apdu_len += len;
|
len =
|
||||||
}
|
encode_context_object_id(&apdu[apdu_len], 3,
|
||||||
len = encode_context_object_id(&apdu[apdu_len], 3,
|
value->deviceIndentifier.type, value->deviceIndentifier.instance);
|
||||||
value->deviceIndentifier.type,
|
apdu_len += len;
|
||||||
value->deviceIndentifier.instance);
|
|
||||||
apdu_len += len;
|
|
||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_decode_device_obj_property_ref(
|
int bacapp_decode_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
|
|
||||||
if ( -1 == ( len = decode_context_object_id(&apdu[apdu_len], 0,
|
if (-1 == (len =
|
||||||
&value->objectIdentifier.type,
|
decode_context_object_id(&apdu[apdu_len], 0,
|
||||||
&value->objectIdentifier.instance)) )
|
&value->objectIdentifier.type,
|
||||||
{
|
&value->objectIdentifier.instance))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
if ( -1 == ( len = decode_context_enumerated(&apdu[apdu_len], 1,
|
if (-1 == (len =
|
||||||
&value->propertyIdentifier)))
|
decode_context_enumerated(&apdu[apdu_len], 1,
|
||||||
{
|
&value->propertyIdentifier))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
if ( decode_is_context_tag(&apdu[apdu_len], 2 ))
|
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||||
{
|
if (-1 == (len =
|
||||||
if ( -1 == ( len = decode_context_unsigned(&apdu[apdu_len], 2,
|
decode_context_unsigned(&apdu[apdu_len], 2,
|
||||||
&value->arrayIndex)))
|
&value->arrayIndex))) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
apdu_len += len;
|
||||||
apdu_len += len;
|
} else {
|
||||||
}
|
value->arrayIndex = 0;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
value->arrayIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( decode_is_context_tag(&apdu[apdu_len], 3 ))
|
if (decode_is_context_tag(&apdu[apdu_len], 3)) {
|
||||||
{
|
if (-1 == (len =
|
||||||
if ( -1 == ( len = decode_context_object_id(&apdu[apdu_len], 3,
|
decode_context_object_id(&apdu[apdu_len], 3,
|
||||||
&value->deviceIndentifier.type,
|
&value->deviceIndentifier.type,
|
||||||
&value->deviceIndentifier.instance)) )
|
&value->deviceIndentifier.instance))) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
apdu_len += len;
|
||||||
apdu_len += len;
|
} else {
|
||||||
}
|
value->deviceIndentifier.instance = 0;
|
||||||
else
|
value->deviceIndentifier.type = 0;
|
||||||
{
|
}
|
||||||
value->deviceIndentifier.instance = 0;
|
|
||||||
value->deviceIndentifier.type = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_decode_context_device_obj_property_ref(
|
int bacapp_decode_context_device_obj_property_ref(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE * value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int section_length;
|
int section_length;
|
||||||
|
|
||||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||||
len++;
|
len++;
|
||||||
section_length = bacapp_decode_device_obj_property_ref(
|
section_length =
|
||||||
&apdu[len], value);
|
bacapp_decode_device_obj_property_ref(&apdu[len], value);
|
||||||
|
|
||||||
if ( section_length == -1 )
|
if (section_length == -1) {
|
||||||
{
|
len = -1;
|
||||||
len = -1;
|
} else {
|
||||||
}
|
len += section_length;
|
||||||
else
|
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
||||||
{
|
len++;
|
||||||
len += section_length;
|
} else {
|
||||||
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
len = -1;
|
||||||
len++;
|
}
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
len = -1;
|
||||||
len = -1;
|
}
|
||||||
}
|
return len;
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = -1;
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
@@ -186,38 +172,44 @@ int bacapp_decode_context_device_obj_property_ref(
|
|||||||
void testDevIdPropRef(
|
void testDevIdPropRef(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE inData;
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE inData;
|
||||||
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE outData;
|
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE outData;
|
||||||
uint8_t buffer[MAX_APDU];
|
uint8_t buffer[MAX_APDU];
|
||||||
int inLen;
|
int inLen;
|
||||||
int outLen;
|
int outLen;
|
||||||
|
|
||||||
|
|
||||||
inData.objectIdentifier.instance = 0x1234;
|
inData.objectIdentifier.instance = 0x1234;
|
||||||
inData.objectIdentifier.type = 15;
|
inData.objectIdentifier.type = 15;
|
||||||
|
|
||||||
inData.propertyIdentifier = 25;
|
inData.propertyIdentifier = 25;
|
||||||
|
|
||||||
inData.arrayIndex = 0x5678;
|
inData.arrayIndex = 0x5678;
|
||||||
|
|
||||||
inData.deviceIndentifier.instance = 0x4343;
|
inData.deviceIndentifier.instance = 0x4343;
|
||||||
inData.deviceIndentifier.type = 28;
|
inData.deviceIndentifier.type = 28;
|
||||||
|
|
||||||
inLen = bacapp_encode_device_obj_property_ref(buffer, &inData);
|
inLen = bacapp_encode_device_obj_property_ref(buffer, &inData);
|
||||||
outLen = bacapp_decode_device_obj_property_ref(buffer, &outData);
|
outLen = bacapp_decode_device_obj_property_ref(buffer, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
|
|
||||||
ct_test(pTest, inData.objectIdentifier.instance == outData.objectIdentifier.instance);
|
ct_test(pTest,
|
||||||
ct_test(pTest, inData.objectIdentifier.type == outData.objectIdentifier.type);
|
inData.objectIdentifier.instance == outData.objectIdentifier.instance);
|
||||||
|
ct_test(pTest,
|
||||||
|
inData.objectIdentifier.type == outData.objectIdentifier.type);
|
||||||
|
|
||||||
ct_test(pTest, inData.propertyIdentifier == outData.propertyIdentifier);
|
ct_test(pTest, inData.propertyIdentifier == outData.propertyIdentifier);
|
||||||
|
|
||||||
ct_test(pTest, inData.arrayIndex == outData.arrayIndex);
|
ct_test(pTest, inData.arrayIndex == outData.arrayIndex);
|
||||||
|
|
||||||
ct_test(pTest, inData.deviceIndentifier.instance == outData.deviceIndentifier.instance);
|
ct_test(pTest,
|
||||||
ct_test(pTest, inData.deviceIndentifier.type == outData.deviceIndentifier.type);
|
inData.deviceIndentifier.instance ==
|
||||||
|
outData.deviceIndentifier.instance);
|
||||||
|
ct_test(pTest,
|
||||||
|
inData.deviceIndentifier.type == outData.deviceIndentifier.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_DEV_ID_PROP_REF
|
#ifdef TEST_DEV_ID_PROP_REF
|
||||||
|
|
||||||
int main(
|
int main(
|
||||||
|
|||||||
+264
-235
@@ -44,160 +44,163 @@ int bacapp_decode_property_state(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_PROPERTY_STATE * value)
|
BACNET_PROPERTY_STATE * value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
uint32_t len_value_type;
|
uint32_t len_value_type;
|
||||||
int section_length;
|
int section_length;
|
||||||
|
|
||||||
|
|
||||||
section_length =
|
section_length =
|
||||||
decode_tag_number_and_value(&apdu[len], (uint8_t*)&value->tag,
|
decode_tag_number_and_value(&apdu[len], (uint8_t *) & value->tag,
|
||||||
&len_value_type);
|
&len_value_type);
|
||||||
|
|
||||||
if ( -1 == section_length )
|
if (-1 == section_length) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
len += section_length;
|
len += section_length;
|
||||||
switch(value->tag)
|
switch (value->tag) {
|
||||||
{
|
case BOOLEAN_VALUE:
|
||||||
case BOOLEAN_VALUE:
|
value->state.booleanValue = decode_boolean(len_value_type);
|
||||||
value->state.booleanValue = decode_boolean(len_value_type);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case BINARY_VALUE:
|
case BINARY_VALUE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.binaryValue)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.binaryValue))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case EVENT_TYPE:
|
case EVENT_TYPE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.eventType)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.eventType))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case POLARITY:
|
case POLARITY:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.polarity)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.polarity))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case PROGRAM_CHANGE:
|
case PROGRAM_CHANGE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.programChange)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.programChange))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case PROGRAM_STATE:
|
case PROGRAM_STATE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.programState)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.programState))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case REASON_FOR_HALT:
|
case REASON_FOR_HALT:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.programError)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.programError))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case RELIABILITY:
|
case RELIABILITY:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.reliability)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.reliability))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE:
|
case STATE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.state)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.state))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SYSTEM_STATUS:
|
case SYSTEM_STATUS:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.systemStatus)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.systemStatus))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case UNITS:
|
case UNITS:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.units)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.units))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case UNSIGNED_VALUE:
|
case UNSIGNED_VALUE:
|
||||||
if ( -1 == ( section_length = decode_unsigned(&apdu[len], len_value_type, &value->state.unsignedValue)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_unsigned(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.unsignedValue))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case LIFE_SAFETY_MODE:
|
case LIFE_SAFETY_MODE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.lifeSafetyMode)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.lifeSafetyMode))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case LIFE_SAFETY_STATE:
|
case LIFE_SAFETY_STATE:
|
||||||
if ( -1 == ( section_length = decode_enumerated(&apdu[len], len_value_type, &value->state.lifeSafetyState)))
|
if (-1 == (section_length =
|
||||||
{
|
decode_enumerated(&apdu[len], len_value_type,
|
||||||
return -1;
|
&value->state.lifeSafetyState))) {
|
||||||
}
|
return -1;
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_decode_context_property_state(
|
int bacapp_decode_context_property_state(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_PROPERTY_STATE * value)
|
BACNET_PROPERTY_STATE * value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int section_length;
|
int section_length;
|
||||||
|
|
||||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||||
len++;
|
len++;
|
||||||
section_length = bacapp_decode_property_state(
|
section_length = bacapp_decode_property_state(&apdu[len], value);
|
||||||
&apdu[len], value);
|
|
||||||
|
|
||||||
if ( section_length == -1 )
|
if (section_length == -1) {
|
||||||
{
|
len = -1;
|
||||||
len = -1;
|
} else {
|
||||||
}
|
len += section_length;
|
||||||
else
|
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
||||||
{
|
len++;
|
||||||
len += section_length;
|
} else {
|
||||||
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
len = -1;
|
||||||
len++;
|
}
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
len = -1;
|
||||||
len = -1;
|
}
|
||||||
}
|
return len;
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = -1;
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_encode_property_state(
|
int bacapp_encode_property_state(
|
||||||
@@ -206,70 +209,96 @@ int bacapp_encode_property_state(
|
|||||||
{
|
{
|
||||||
int len = 0; /* length of each encoding */
|
int len = 0; /* length of each encoding */
|
||||||
if (value && apdu) {
|
if (value && apdu) {
|
||||||
switch(value->tag)
|
switch (value->tag) {
|
||||||
{
|
case BOOLEAN_VALUE:
|
||||||
case BOOLEAN_VALUE:
|
len =
|
||||||
len = encode_context_boolean(&apdu[0], 0, value->state.booleanValue);
|
encode_context_boolean(&apdu[0], 0,
|
||||||
break;
|
value->state.booleanValue);
|
||||||
|
break;
|
||||||
|
|
||||||
case BINARY_VALUE:
|
case BINARY_VALUE:
|
||||||
len = encode_context_enumerated(&apdu[0], 1, value->state.binaryValue);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 1,
|
||||||
|
value->state.binaryValue);
|
||||||
|
break;
|
||||||
|
|
||||||
case EVENT_TYPE:
|
case EVENT_TYPE:
|
||||||
len = encode_context_enumerated(&apdu[0], 2, value->state.eventType);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 2,
|
||||||
|
value->state.eventType);
|
||||||
|
break;
|
||||||
|
|
||||||
case POLARITY:
|
case POLARITY:
|
||||||
len = encode_context_enumerated(&apdu[0], 3, value->state.polarity);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 3,
|
||||||
|
value->state.polarity);
|
||||||
|
break;
|
||||||
|
|
||||||
case PROGRAM_CHANGE:
|
case PROGRAM_CHANGE:
|
||||||
len = encode_context_enumerated(&apdu[0], 4, value->state.programChange);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 4,
|
||||||
|
value->state.programChange);
|
||||||
|
break;
|
||||||
|
|
||||||
case PROGRAM_STATE:
|
case PROGRAM_STATE:
|
||||||
len = encode_context_enumerated(&apdu[0], 5, value->state.programState);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 5,
|
||||||
|
value->state.programState);
|
||||||
|
break;
|
||||||
|
|
||||||
case REASON_FOR_HALT:
|
case REASON_FOR_HALT:
|
||||||
len = encode_context_enumerated(&apdu[0], 6, value->state.programError);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 6,
|
||||||
|
value->state.programError);
|
||||||
|
break;
|
||||||
|
|
||||||
case RELIABILITY:
|
case RELIABILITY:
|
||||||
len = encode_context_enumerated(&apdu[0], 7, value->state.reliability);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 7,
|
||||||
|
value->state.reliability);
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE:
|
case STATE:
|
||||||
len = encode_context_enumerated(&apdu[0], 8, value->state.state);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 8, value->state.state);
|
||||||
|
break;
|
||||||
|
|
||||||
case SYSTEM_STATUS:
|
case SYSTEM_STATUS:
|
||||||
len = encode_context_enumerated(&apdu[0], 9, value->state.systemStatus);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 9,
|
||||||
|
value->state.systemStatus);
|
||||||
|
break;
|
||||||
|
|
||||||
case UNITS:
|
case UNITS:
|
||||||
len = encode_context_enumerated(&apdu[0], 10, value->state.units);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 10,
|
||||||
|
value->state.units);
|
||||||
|
break;
|
||||||
|
|
||||||
case UNSIGNED_VALUE:
|
case UNSIGNED_VALUE:
|
||||||
len = encode_context_unsigned(&apdu[0], 11, value->state.unsignedValue);
|
len =
|
||||||
break;
|
encode_context_unsigned(&apdu[0], 11,
|
||||||
|
value->state.unsignedValue);
|
||||||
|
break;
|
||||||
|
|
||||||
case LIFE_SAFETY_MODE:
|
case LIFE_SAFETY_MODE:
|
||||||
len = encode_context_enumerated(&apdu[0], 12, value->state.lifeSafetyMode);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 12,
|
||||||
|
value->state.lifeSafetyMode);
|
||||||
|
break;
|
||||||
|
|
||||||
case LIFE_SAFETY_STATE:
|
case LIFE_SAFETY_STATE:
|
||||||
len = encode_context_enumerated(&apdu[0], 13, value->state.lifeSafetyState);
|
len =
|
||||||
break;
|
encode_context_enumerated(&apdu[0], 13,
|
||||||
|
value->state.lifeSafetyState);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
@@ -277,104 +306,104 @@ int bacapp_encode_property_state(
|
|||||||
void testPropStates(
|
void testPropStates(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_PROPERTY_STATE inData;
|
BACNET_PROPERTY_STATE inData;
|
||||||
BACNET_PROPERTY_STATE outData;
|
BACNET_PROPERTY_STATE outData;
|
||||||
uint8_t appMsg[MAX_APDU];
|
uint8_t appMsg[MAX_APDU];
|
||||||
int inLen;
|
int inLen;
|
||||||
int outLen;
|
int outLen;
|
||||||
|
|
||||||
inData.tag = BOOLEAN_VALUE;
|
inData.tag = BOOLEAN_VALUE;
|
||||||
inData.state.booleanValue = true;
|
inData.state.booleanValue = true;
|
||||||
|
|
||||||
inLen = bacapp_encode_property_state(appMsg, &inData);
|
inLen = bacapp_encode_property_state(appMsg, &inData);
|
||||||
|
|
||||||
memset(&outData, 0, sizeof(outData));
|
memset(&outData, 0, sizeof(outData));
|
||||||
|
|
||||||
outLen = bacapp_decode_property_state(appMsg, &outData);
|
outLen = bacapp_decode_property_state(appMsg, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
ct_test(pTest, inData.tag == outData.tag );
|
ct_test(pTest, inData.tag == outData.tag);
|
||||||
ct_test(pTest, inData.state.booleanValue == outData.state.booleanValue );
|
ct_test(pTest, inData.state.booleanValue == outData.state.booleanValue);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
*****************
|
*****************
|
||||||
****************/
|
****************/
|
||||||
inData.tag = BINARY_VALUE;
|
inData.tag = BINARY_VALUE;
|
||||||
inData.state.binaryValue = BINARY_ACTIVE;
|
inData.state.binaryValue = BINARY_ACTIVE;
|
||||||
|
|
||||||
inLen = bacapp_encode_property_state(appMsg, &inData);
|
inLen = bacapp_encode_property_state(appMsg, &inData);
|
||||||
|
|
||||||
memset(&outData, 0, sizeof(outData));
|
memset(&outData, 0, sizeof(outData));
|
||||||
|
|
||||||
outLen = bacapp_decode_property_state(appMsg, &outData);
|
outLen = bacapp_decode_property_state(appMsg, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
ct_test(pTest, inData.tag == outData.tag );
|
ct_test(pTest, inData.tag == outData.tag);
|
||||||
ct_test(pTest, inData.state.binaryValue == outData.state.binaryValue );
|
ct_test(pTest, inData.state.binaryValue == outData.state.binaryValue);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
*****************
|
*****************
|
||||||
****************/
|
****************/
|
||||||
inData.tag = EVENT_TYPE;
|
inData.tag = EVENT_TYPE;
|
||||||
inData.state.eventType = EVENT_BUFFER_READY;
|
inData.state.eventType = EVENT_BUFFER_READY;
|
||||||
|
|
||||||
inLen = bacapp_encode_property_state(appMsg, &inData);
|
inLen = bacapp_encode_property_state(appMsg, &inData);
|
||||||
|
|
||||||
memset(&outData, 0, sizeof(outData));
|
memset(&outData, 0, sizeof(outData));
|
||||||
|
|
||||||
outLen = bacapp_decode_property_state(appMsg, &outData);
|
outLen = bacapp_decode_property_state(appMsg, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
ct_test(pTest, inData.tag == outData.tag );
|
ct_test(pTest, inData.tag == outData.tag);
|
||||||
ct_test(pTest, inData.state.eventType == outData.state.eventType );
|
ct_test(pTest, inData.state.eventType == outData.state.eventType);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
*****************
|
*****************
|
||||||
****************/
|
****************/
|
||||||
inData.tag = POLARITY;
|
inData.tag = POLARITY;
|
||||||
inData.state.polarity = POLARITY_REVERSE;
|
inData.state.polarity = POLARITY_REVERSE;
|
||||||
|
|
||||||
inLen = bacapp_encode_property_state(appMsg, &inData);
|
inLen = bacapp_encode_property_state(appMsg, &inData);
|
||||||
|
|
||||||
memset(&outData, 0, sizeof(outData));
|
memset(&outData, 0, sizeof(outData));
|
||||||
|
|
||||||
outLen = bacapp_decode_property_state(appMsg, &outData);
|
outLen = bacapp_decode_property_state(appMsg, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
ct_test(pTest, inData.tag == outData.tag );
|
ct_test(pTest, inData.tag == outData.tag);
|
||||||
ct_test(pTest, inData.state.polarity == outData.state.polarity );
|
ct_test(pTest, inData.state.polarity == outData.state.polarity);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
*****************
|
*****************
|
||||||
****************/
|
****************/
|
||||||
inData.tag = PROGRAM_CHANGE;
|
inData.tag = PROGRAM_CHANGE;
|
||||||
inData.state.programChange = PROGRAM_REQUEST_RESTART;
|
inData.state.programChange = PROGRAM_REQUEST_RESTART;
|
||||||
|
|
||||||
inLen = bacapp_encode_property_state(appMsg, &inData);
|
inLen = bacapp_encode_property_state(appMsg, &inData);
|
||||||
|
|
||||||
memset(&outData, 0, sizeof(outData));
|
memset(&outData, 0, sizeof(outData));
|
||||||
|
|
||||||
outLen = bacapp_decode_property_state(appMsg, &outData);
|
outLen = bacapp_decode_property_state(appMsg, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
ct_test(pTest, inData.tag == outData.tag );
|
ct_test(pTest, inData.tag == outData.tag);
|
||||||
ct_test(pTest, inData.state.programChange == outData.state.programChange );
|
ct_test(pTest, inData.state.programChange == outData.state.programChange);
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
*****************
|
*****************
|
||||||
****************/
|
****************/
|
||||||
inData.tag = UNSIGNED_VALUE;
|
inData.tag = UNSIGNED_VALUE;
|
||||||
inData.state.unsignedValue = 0xdeadbeef;
|
inData.state.unsignedValue = 0xdeadbeef;
|
||||||
|
|
||||||
inLen = bacapp_encode_property_state(appMsg, &inData);
|
inLen = bacapp_encode_property_state(appMsg, &inData);
|
||||||
|
|
||||||
memset(&outData, 0, sizeof(outData));
|
memset(&outData, 0, sizeof(outData));
|
||||||
|
|
||||||
outLen = bacapp_decode_property_state(appMsg, &outData);
|
outLen = bacapp_decode_property_state(appMsg, &outData);
|
||||||
|
|
||||||
ct_test(pTest, outLen == inLen);
|
ct_test(pTest, outLen == inLen);
|
||||||
ct_test(pTest, inData.tag == outData.tag );
|
ct_test(pTest, inData.tag == outData.tag);
|
||||||
ct_test(pTest, inData.state.unsignedValue == outData.state.unsignedValue );
|
ct_test(pTest, inData.state.unsignedValue == outData.state.unsignedValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-12
@@ -78,23 +78,22 @@ int decode_real(
|
|||||||
|
|
||||||
int decode_context_real(
|
int decode_context_real(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
float *real_value)
|
float *real_value)
|
||||||
{
|
{
|
||||||
uint32_t len_value;
|
uint32_t len_value;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
if (decode_is_context_tag(&apdu[len], tag_number)) {
|
if (decode_is_context_tag(&apdu[len], tag_number)) {
|
||||||
len += decode_tag_number_and_value(&apdu[len], &tag_number,
|
len +=
|
||||||
&len_value);
|
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||||
len += decode_real(&apdu[len], real_value);
|
len += decode_real(&apdu[len], real_value);
|
||||||
}
|
} else {
|
||||||
else
|
len = -1;
|
||||||
{
|
}
|
||||||
len = -1;
|
return len;
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* from clause 20.2.6 Encoding of a Real Number Value */
|
/* from clause 20.2.6 Encoding of a Real Number Value */
|
||||||
/* returns the number of apdu bytes consumed */
|
/* returns the number of apdu bytes consumed */
|
||||||
int encode_bacnet_real(
|
int encode_bacnet_real(
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ uint8_t bitstring_bits_used(
|
|||||||
uint8_t bitstring_bytes_used(
|
uint8_t bitstring_bytes_used(
|
||||||
BACNET_BIT_STRING * bit_string)
|
BACNET_BIT_STRING * bit_string)
|
||||||
{
|
{
|
||||||
uint8_t len = 0; /* return value */
|
uint8_t len = 0; /* return value */
|
||||||
uint8_t used_bytes = 0;
|
uint8_t used_bytes = 0;
|
||||||
uint8_t last_bit = 0;
|
uint8_t last_bit = 0;
|
||||||
|
|
||||||
@@ -544,7 +544,7 @@ bool octetstring_value_same(
|
|||||||
BACNET_OCTET_STRING * octet_string1,
|
BACNET_OCTET_STRING * octet_string1,
|
||||||
BACNET_OCTET_STRING * octet_string2)
|
BACNET_OCTET_STRING * octet_string2)
|
||||||
{
|
{
|
||||||
size_t i = 0; /* loop counter */
|
size_t i = 0; /* loop counter */
|
||||||
|
|
||||||
if (octet_string1 && octet_string2) {
|
if (octet_string1 && octet_string2) {
|
||||||
if ((octet_string1->length == octet_string2->length) &&
|
if ((octet_string1->length == octet_string2->length) &&
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ int cov_notify_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0; /* for decoding */
|
uint32_t decoded_value = 0; /* for decoding */
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
int property = 0; /* for decoding */
|
||||||
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ int cov_subscribe_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0; /* for decoding */
|
uint32_t decoded_value = 0; /* for decoding */
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
/* tag 0 - subscriberProcessIdentifier */
|
/* tag 0 - subscriberProcessIdentifier */
|
||||||
@@ -519,7 +519,7 @@ int cov_subscribe_property_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0; /* for decoding */
|
uint32_t decoded_value = 0; /* for decoding */
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
int property = 0; /* for decoding */
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
|
|||||||
+69
-79
@@ -75,7 +75,7 @@ static uint8_t month_days(
|
|||||||
if ((month == 2) && is_leap_year(year))
|
if ((month == 2) && is_leap_year(year))
|
||||||
return 29;
|
return 29;
|
||||||
else if (month >= 1 && month <= 12)
|
else if (month >= 1 && month <= 12)
|
||||||
return (uint8_t)month_days[month];
|
return (uint8_t) month_days[month];
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -435,48 +435,47 @@ int bacapp_encode_context_datetime(
|
|||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DATE_TIME * value)
|
BACNET_DATE_TIME * value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
|
|
||||||
|
|
||||||
if ( apdu && value )
|
if (apdu && value) {
|
||||||
{
|
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
apdu_len += len;
|
||||||
apdu_len += len;
|
|
||||||
|
|
||||||
len = encode_application_date(&apdu[apdu_len], &value->date);
|
len = encode_application_date(&apdu[apdu_len], &value->date);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_application_time(&apdu[apdu_len], &value->time);
|
len = encode_application_time(&apdu[apdu_len], &value->time);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
}
|
}
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_decode_datetime(
|
int bacapp_decode_datetime(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
BACNET_DATE_TIME * value)
|
BACNET_DATE_TIME * value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int section_len;
|
int section_len;
|
||||||
|
|
||||||
if ( -1 == ( section_len = decode_application_date(&apdu[len], &value->date) ) )
|
if (-1 == (section_len =
|
||||||
{
|
decode_application_date(&apdu[len], &value->date))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len += section_len;
|
len += section_len;
|
||||||
|
|
||||||
if ( -1 == ( section_len = decode_application_time(&apdu[len], &value->time) ) )
|
if (-1 == (section_len =
|
||||||
{
|
decode_application_time(&apdu[len], &value->time))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len += section_len;
|
len += section_len;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_decode_context_datetime(
|
int bacapp_decode_context_datetime(
|
||||||
@@ -484,35 +483,27 @@ int bacapp_decode_context_datetime(
|
|||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_DATE_TIME * value)
|
BACNET_DATE_TIME * value)
|
||||||
{
|
{
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
if (decode_is_opening_tag_number(&apdu[apdu_len], tag_number)) {
|
||||||
apdu_len++;
|
apdu_len++;
|
||||||
}
|
} else {
|
||||||
else
|
return -1;
|
||||||
{
|
}
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( -1 == (len = bacapp_decode_datetime(&apdu[apdu_len], value)))
|
if (-1 == (len = bacapp_decode_datetime(&apdu[apdu_len], value))) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
} else {
|
||||||
}
|
apdu_len += len;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
apdu_len += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (decode_is_closing_tag_number(&apdu[apdu_len], tag_number))
|
if (decode_is_closing_tag_number(&apdu[apdu_len], tag_number)) {
|
||||||
{
|
apdu_len++;
|
||||||
apdu_len++;
|
} else {
|
||||||
}
|
return -1;
|
||||||
else
|
}
|
||||||
{
|
return apdu_len;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return apdu_len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -836,36 +827,36 @@ void testBACnetDayOfWeek(
|
|||||||
void testDatetimeCodec(
|
void testDatetimeCodec(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
uint8_t apdu[MAX_APDU];
|
uint8_t apdu[MAX_APDU];
|
||||||
BACNET_DATE_TIME datetimeIn;
|
BACNET_DATE_TIME datetimeIn;
|
||||||
BACNET_DATE_TIME datetimeOut;
|
BACNET_DATE_TIME datetimeOut;
|
||||||
int inLen;
|
int inLen;
|
||||||
int outLen;
|
int outLen;
|
||||||
|
|
||||||
datetimeIn.date.day = 1;
|
datetimeIn.date.day = 1;
|
||||||
datetimeIn.date.month = 2;
|
datetimeIn.date.month = 2;
|
||||||
datetimeIn.date.wday = 3;
|
datetimeIn.date.wday = 3;
|
||||||
datetimeIn.date.year = 1904;
|
datetimeIn.date.year = 1904;
|
||||||
|
|
||||||
datetimeIn.time.hour = 5;
|
datetimeIn.time.hour = 5;
|
||||||
datetimeIn.time.min = 6;
|
datetimeIn.time.min = 6;
|
||||||
datetimeIn.time.sec = 7;
|
datetimeIn.time.sec = 7;
|
||||||
datetimeIn.time.hundredths = 8;
|
datetimeIn.time.hundredths = 8;
|
||||||
|
|
||||||
inLen = bacapp_encode_context_datetime(apdu, 10, &datetimeIn);
|
inLen = bacapp_encode_context_datetime(apdu, 10, &datetimeIn);
|
||||||
outLen = bacapp_decode_context_datetime(apdu, 10, &datetimeOut);
|
outLen = bacapp_decode_context_datetime(apdu, 10, &datetimeOut);
|
||||||
|
|
||||||
ct_test(pTest, inLen == outLen );
|
ct_test(pTest, inLen == outLen);
|
||||||
|
|
||||||
ct_test(pTest, datetimeIn.date.day == datetimeOut.date.day);
|
ct_test(pTest, datetimeIn.date.day == datetimeOut.date.day);
|
||||||
ct_test(pTest, datetimeIn.date.month == datetimeOut.date.month);
|
ct_test(pTest, datetimeIn.date.month == datetimeOut.date.month);
|
||||||
ct_test(pTest, datetimeIn.date.wday == datetimeOut.date.wday);
|
ct_test(pTest, datetimeIn.date.wday == datetimeOut.date.wday);
|
||||||
ct_test(pTest, datetimeIn.date.year == datetimeOut.date.year);
|
ct_test(pTest, datetimeIn.date.year == datetimeOut.date.year);
|
||||||
|
|
||||||
ct_test(pTest, datetimeIn.time.hour == datetimeOut.time.hour);
|
ct_test(pTest, datetimeIn.time.hour == datetimeOut.time.hour);
|
||||||
ct_test(pTest, datetimeIn.time.min == datetimeOut.time.min);
|
ct_test(pTest, datetimeIn.time.min == datetimeOut.time.min);
|
||||||
ct_test(pTest, datetimeIn.time.sec == datetimeOut.time.sec);
|
ct_test(pTest, datetimeIn.time.sec == datetimeOut.time.sec);
|
||||||
ct_test(pTest, datetimeIn.time.hundredths == datetimeOut.time.hundredths);
|
ct_test(pTest, datetimeIn.time.hundredths == datetimeOut.time.hundredths);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -909,4 +900,3 @@ int main(
|
|||||||
|
|
||||||
#endif /* TEST_DATE_TIME */
|
#endif /* TEST_DATE_TIME */
|
||||||
#endif /* TEST */
|
#endif /* TEST */
|
||||||
|
|
||||||
|
|||||||
+1216
-1069
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@
|
|||||||
char *filename_remove_path(
|
char *filename_remove_path(
|
||||||
const char *filename_in)
|
const char *filename_in)
|
||||||
{
|
{
|
||||||
char *filename_out = (char *)filename_in;
|
char *filename_out = (char *) filename_in;
|
||||||
|
|
||||||
/* allow the device ID to be set */
|
/* allow the device ID to be set */
|
||||||
if (filename_in) {
|
if (filename_in) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ int iam_decode_service_request(
|
|||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
uint16_t object_type = 0; /* should be a Device Object */
|
uint16_t object_type = 0; /* should be a Device Object */
|
||||||
uint32_t object_instance = 0;
|
uint32_t object_instance = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ int ihave_decode_service_request(
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
/* deviceIdentifier */
|
/* deviceIdentifier */
|
||||||
|
|||||||
+10
-11
@@ -36,12 +36,12 @@
|
|||||||
/* copy len bytes from src to offset of dest if there is enough space. */
|
/* copy len bytes from src to offset of dest if there is enough space. */
|
||||||
/* returns 0 if there is not enough space, or the number of bytes copied. */
|
/* returns 0 if there is not enough space, or the number of bytes copied. */
|
||||||
size_t memcopy(
|
size_t memcopy(
|
||||||
void * dest,
|
void *dest,
|
||||||
void * src,
|
void *src,
|
||||||
size_t offset, /* where in dest to put the data */
|
size_t offset, /* where in dest to put the data */
|
||||||
size_t len, /* amount of data to copy */
|
size_t len, /* amount of data to copy */
|
||||||
size_t max) /* total size of destination */
|
size_t max)
|
||||||
{
|
{ /* total size of destination */
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t copy_len = 0;
|
size_t copy_len = 0;
|
||||||
char *s1, *s2;
|
char *s1, *s2;
|
||||||
@@ -73,15 +73,14 @@ void test_memcopy(
|
|||||||
char big_buffer[480] = "";
|
char big_buffer[480] = "";
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
len = memcopy(&buffer[0], &data1[0], 0,
|
len = memcopy(&buffer[0], &data1[0], 0, sizeof(data1), sizeof(buffer));
|
||||||
sizeof(data1), sizeof(buffer));
|
|
||||||
ct_test(pTest, len == sizeof(data1));
|
ct_test(pTest, len == sizeof(data1));
|
||||||
ct_test(pTest, memcmp(&buffer[0], &data1[0], len) == 0);
|
ct_test(pTest, memcmp(&buffer[0], &data1[0], len) == 0);
|
||||||
len = memcopy(&buffer[0], &data2[0], len,
|
len = memcopy(&buffer[0], &data2[0], len, sizeof(data2), sizeof(buffer));
|
||||||
sizeof(data2), sizeof(buffer));
|
|
||||||
ct_test(pTest, len == sizeof(data2));
|
ct_test(pTest, len == sizeof(data2));
|
||||||
len = memcopy(&buffer[0], &big_buffer[0], 1,
|
len =
|
||||||
sizeof(big_buffer), sizeof(buffer));
|
memcopy(&buffer[0], &big_buffer[0], 1, sizeof(big_buffer),
|
||||||
|
sizeof(buffer));
|
||||||
ct_test(pTest, len == 0);
|
ct_test(pTest, len == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ int rp_decode_service_request(
|
|||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
int property = 0; /* for decoding */
|
||||||
uint32_t array_value = 0; /* for decoding */
|
uint32_t array_value = 0; /* for decoding */
|
||||||
|
|
||||||
@@ -214,8 +214,8 @@ int rp_ack_decode_service_request(
|
|||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
int tag_len = 0; /* length of tag decode */
|
int tag_len = 0; /* length of tag decode */
|
||||||
int len = 0; /* total length of decodes */
|
int len = 0; /* total length of decodes */
|
||||||
uint16_t object = 0; /* object type */
|
uint16_t object = 0; /* object type */
|
||||||
int property = 0; /* for decoding */
|
int property = 0; /* for decoding */
|
||||||
uint32_t array_value = 0; /* for decoding */
|
uint32_t array_value = 0; /* for decoding */
|
||||||
|
|
||||||
/* FIXME: check apdu_len against the len during decode */
|
/* FIXME: check apdu_len against the len during decode */
|
||||||
|
|||||||
+16
-13
@@ -110,13 +110,13 @@ int rpm_encode_apdu(
|
|||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
size_t max_apdu,
|
size_t max_apdu,
|
||||||
uint8_t invoke_id,
|
uint8_t invoke_id,
|
||||||
BACNET_READ_ACCESS_DATA *read_access_data)
|
BACNET_READ_ACCESS_DATA * read_access_data)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
int len = 0; /* length of the data */
|
int len = 0; /* length of the data */
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object; /* current object */
|
BACNET_READ_ACCESS_DATA *rpm_object; /* current object */
|
||||||
uint8_t apdu_temp[16]; /* temp for data before copy */
|
uint8_t apdu_temp[16]; /* temp for data before copy */
|
||||||
BACNET_PROPERTY_REFERENCE *rpm_property; /* current property */
|
BACNET_PROPERTY_REFERENCE *rpm_property; /* current property */
|
||||||
|
|
||||||
len = rpm_encode_apdu_init(&apdu_temp[0], invoke_id);
|
len = rpm_encode_apdu_init(&apdu_temp[0], invoke_id);
|
||||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||||
@@ -126,9 +126,9 @@ int rpm_encode_apdu(
|
|||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
rpm_object = read_access_data;
|
rpm_object = read_access_data;
|
||||||
while (rpm_object) {
|
while (rpm_object) {
|
||||||
len = encode_context_object_id(&apdu_temp[0], 0,
|
len =
|
||||||
rpm_object->object_type,
|
encode_context_object_id(&apdu_temp[0], 0, rpm_object->object_type,
|
||||||
rpm_object->object_instance);
|
rpm_object->object_instance);
|
||||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -144,7 +144,8 @@ int rpm_encode_apdu(
|
|||||||
rpm_property = rpm_object->listOfProperties;
|
rpm_property = rpm_object->listOfProperties;
|
||||||
while (rpm_property) {
|
while (rpm_property) {
|
||||||
/* stuff as many properties into it as APDU length will allow */
|
/* stuff as many properties into it as APDU length will allow */
|
||||||
len = encode_context_enumerated(&apdu_temp[0], 0,
|
len =
|
||||||
|
encode_context_enumerated(&apdu_temp[0], 0,
|
||||||
rpm_property->propertyIdentifier);
|
rpm_property->propertyIdentifier);
|
||||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
@@ -153,9 +154,11 @@ int rpm_encode_apdu(
|
|||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
/* optional array index */
|
/* optional array index */
|
||||||
if (rpm_property->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
if (rpm_property->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||||
len = encode_context_unsigned(&apdu_temp[0], 1,
|
len =
|
||||||
|
encode_context_unsigned(&apdu_temp[0], 1,
|
||||||
rpm_property->propertyArrayIndex);
|
rpm_property->propertyArrayIndex);
|
||||||
len = memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
len =
|
||||||
|
memcopy(&apdu[0], &apdu_temp[0], apdu_len, len, max_apdu);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -183,7 +186,7 @@ int rpm_decode_object_id(
|
|||||||
uint32_t * object_instance)
|
uint32_t * object_instance)
|
||||||
{
|
{
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
if (apdu && apdu_len && object_type && object_instance) {
|
if (apdu && apdu_len && object_type && object_instance) {
|
||||||
@@ -383,7 +386,7 @@ int rpm_ack_decode_object_id(
|
|||||||
uint32_t * object_instance)
|
uint32_t * object_instance)
|
||||||
{
|
{
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
|
|
||||||
/* check for value pointers */
|
/* check for value pointers */
|
||||||
if (apdu && apdu_len && object_type && object_instance) {
|
if (apdu && apdu_len && object_type && object_instance) {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
void sbuf_init(
|
void sbuf_init(
|
||||||
STATIC_BUFFER * b, /* static buffer structure */
|
STATIC_BUFFER * b, /* static buffer structure */
|
||||||
char *data, /* data block */
|
char *data, /* data block */
|
||||||
unsigned size) /* actual size, in bytes, of the data block or array of data */
|
unsigned size)
|
||||||
{
|
{ /* actual size, in bytes, of the data block or array of data */
|
||||||
if (b) {
|
if (b) {
|
||||||
b->data = data;
|
b->data = data;
|
||||||
b->size = size;
|
b->size = size;
|
||||||
|
|||||||
+169
-151
@@ -37,120 +37,116 @@
|
|||||||
|
|
||||||
int bacapp_encode_context_timestamp(
|
int bacapp_encode_context_timestamp(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_TIMESTAMP * value)
|
BACNET_TIMESTAMP * value)
|
||||||
{
|
{
|
||||||
int len = 0; /* length of each encoding */
|
int len = 0; /* length of each encoding */
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
|
|
||||||
if (value && apdu) {
|
if (value && apdu) {
|
||||||
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
len = encode_opening_tag(&apdu[apdu_len], tag_number);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
switch(value->tag)
|
switch (value->tag) {
|
||||||
{
|
case TIME_STAMP_TIME:
|
||||||
case TIME_STAMP_TIME:
|
len =
|
||||||
len = encode_context_time(&apdu[apdu_len], 0, &value->value.time);
|
encode_context_time(&apdu[apdu_len], 0,
|
||||||
break;
|
&value->value.time);
|
||||||
|
break;
|
||||||
|
|
||||||
case TIME_STAMP_SEQUENCE:
|
case TIME_STAMP_SEQUENCE:
|
||||||
len = encode_context_unsigned(&apdu[apdu_len], 1, value->value.sequenceNum);
|
len =
|
||||||
break;
|
encode_context_unsigned(&apdu[apdu_len], 1,
|
||||||
|
value->value.sequenceNum);
|
||||||
|
break;
|
||||||
|
|
||||||
case TIME_STAMP_DATETIME:
|
case TIME_STAMP_DATETIME:
|
||||||
len = bacapp_encode_context_datetime(&apdu[apdu_len], 2, &value->value.dateTime);
|
len =
|
||||||
break;
|
bacapp_encode_context_datetime(&apdu[apdu_len], 2,
|
||||||
|
&value->value.dateTime);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
len = 0;
|
len = 0;
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
|
|
||||||
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
len = encode_closing_tag(&apdu[apdu_len], tag_number);
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
}
|
}
|
||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_decode_context_timestamp(
|
int bacapp_decode_context_timestamp(
|
||||||
uint8_t * apdu,
|
uint8_t * apdu,
|
||||||
uint8_t tag_number,
|
uint8_t tag_number,
|
||||||
BACNET_TIMESTAMP * value)
|
BACNET_TIMESTAMP * value)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int section_len;
|
int section_len;
|
||||||
uint32_t len_value_type;
|
uint32_t len_value_type;
|
||||||
uint32_t sequenceNum;
|
uint32_t sequenceNum;
|
||||||
|
|
||||||
|
|
||||||
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
if (decode_is_opening_tag_number(&apdu[len], tag_number)) {
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
section_len =
|
section_len =
|
||||||
decode_tag_number_and_value(&apdu[len], &value->tag,
|
decode_tag_number_and_value(&apdu[len], &value->tag,
|
||||||
&len_value_type);
|
&len_value_type);
|
||||||
|
|
||||||
if ( -1 == section_len )
|
if (-1 == section_len) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
switch (value->tag) {
|
||||||
switch( value->tag )
|
case TIME_STAMP_TIME:
|
||||||
{
|
if ((section_len =
|
||||||
case TIME_STAMP_TIME:
|
decode_context_bacnet_time(&apdu[len], TIME_STAMP_TIME,
|
||||||
if ( (section_len = decode_context_bacnet_time(&apdu[len], TIME_STAMP_TIME, &value->value.time)) == -1 )
|
&value->value.time)) == -1) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
} else {
|
||||||
}
|
len += section_len;
|
||||||
else
|
}
|
||||||
{
|
break;
|
||||||
len += section_len;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TIME_STAMP_SEQUENCE:
|
case TIME_STAMP_SEQUENCE:
|
||||||
if ( (section_len = decode_context_unsigned(&apdu[len], TIME_STAMP_SEQUENCE, &sequenceNum)) == -1 )
|
if ((section_len =
|
||||||
{
|
decode_context_unsigned(&apdu[len],
|
||||||
return -1;
|
TIME_STAMP_SEQUENCE, &sequenceNum)) == -1) {
|
||||||
}
|
return -1;
|
||||||
else
|
} else {
|
||||||
{
|
if (sequenceNum <= 0xffff) {
|
||||||
if ( sequenceNum <= 0xffff )
|
len += section_len;
|
||||||
{
|
value->value.sequenceNum = (uint16_t) sequenceNum;
|
||||||
len += section_len;
|
} else {
|
||||||
value->value.sequenceNum = (uint16_t)sequenceNum;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
break;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TIME_STAMP_DATETIME:
|
case TIME_STAMP_DATETIME:
|
||||||
if ( (section_len = bacapp_decode_context_datetime(&apdu[len], TIME_STAMP_DATETIME, &value->value.dateTime)) == -1 )
|
if ((section_len =
|
||||||
{
|
bacapp_decode_context_datetime(&apdu[len],
|
||||||
return -1;
|
TIME_STAMP_DATETIME,
|
||||||
}
|
&value->value.dateTime)) == -1) {
|
||||||
else
|
return -1;
|
||||||
{
|
} else {
|
||||||
len += section_len;
|
len += section_len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
if (decode_is_closing_tag_number(&apdu[len], tag_number)) {
|
||||||
len++;
|
len++;
|
||||||
}
|
} else {
|
||||||
else
|
return -1;
|
||||||
{
|
}
|
||||||
return -1;
|
}
|
||||||
}
|
return len;
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
@@ -163,91 +159,114 @@ int bacapp_decode_context_timestamp(
|
|||||||
void testTimestampSequence(
|
void testTimestampSequence(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_TIMESTAMP testTimestampIn;
|
BACNET_TIMESTAMP testTimestampIn;
|
||||||
BACNET_TIMESTAMP testTimestampOut;
|
BACNET_TIMESTAMP testTimestampOut;
|
||||||
uint8_t buffer[MAX_APDU];
|
uint8_t buffer[MAX_APDU];
|
||||||
int inLen;
|
int inLen;
|
||||||
int outLen;
|
int outLen;
|
||||||
|
|
||||||
testTimestampIn.tag = TIME_STAMP_SEQUENCE;
|
testTimestampIn.tag = TIME_STAMP_SEQUENCE;
|
||||||
testTimestampIn.value.sequenceNum = 0x1234;
|
testTimestampIn.value.sequenceNum = 0x1234;
|
||||||
|
|
||||||
memset(&testTimestampOut, 0, sizeof(testTimestampOut));
|
memset(&testTimestampOut, 0, sizeof(testTimestampOut));
|
||||||
|
|
||||||
|
|
||||||
inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
|
inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
|
||||||
outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);
|
outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);
|
||||||
|
|
||||||
ct_test(pTest, inLen == outLen);
|
ct_test(pTest, inLen == outLen);
|
||||||
ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
|
ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
|
||||||
ct_test(pTest, testTimestampIn.value.sequenceNum == testTimestampOut.value.sequenceNum);
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.sequenceNum ==
|
||||||
|
testTimestampOut.value.sequenceNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testTimestampTime(
|
void testTimestampTime(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_TIMESTAMP testTimestampIn;
|
BACNET_TIMESTAMP testTimestampIn;
|
||||||
BACNET_TIMESTAMP testTimestampOut;
|
BACNET_TIMESTAMP testTimestampOut;
|
||||||
uint8_t buffer[MAX_APDU];
|
uint8_t buffer[MAX_APDU];
|
||||||
int inLen;
|
int inLen;
|
||||||
int outLen;
|
int outLen;
|
||||||
|
|
||||||
testTimestampIn.tag = TIME_STAMP_TIME;
|
testTimestampIn.tag = TIME_STAMP_TIME;
|
||||||
testTimestampIn.value.time.hour = 1;
|
testTimestampIn.value.time.hour = 1;
|
||||||
testTimestampIn.value.time.min = 2;
|
testTimestampIn.value.time.min = 2;
|
||||||
testTimestampIn.value.time.sec = 3;
|
testTimestampIn.value.time.sec = 3;
|
||||||
testTimestampIn.value.time.hundredths = 4;
|
testTimestampIn.value.time.hundredths = 4;
|
||||||
|
|
||||||
memset(&testTimestampOut, 0, sizeof(testTimestampOut));
|
memset(&testTimestampOut, 0, sizeof(testTimestampOut));
|
||||||
|
|
||||||
|
|
||||||
inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
|
inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
|
||||||
outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);
|
outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);
|
||||||
|
|
||||||
ct_test(pTest, inLen == outLen);
|
ct_test(pTest, inLen == outLen);
|
||||||
ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
|
ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
|
||||||
ct_test(pTest, testTimestampIn.value.time.hour == testTimestampOut.value.time.hour);
|
ct_test(pTest,
|
||||||
ct_test(pTest, testTimestampIn.value.time.min == testTimestampOut.value.time.min);
|
testTimestampIn.value.time.hour == testTimestampOut.value.time.hour);
|
||||||
ct_test(pTest, testTimestampIn.value.time.sec == testTimestampOut.value.time.sec);
|
ct_test(pTest,
|
||||||
ct_test(pTest, testTimestampIn.value.time.hundredths == testTimestampOut.value.time.hundredths);
|
testTimestampIn.value.time.min == testTimestampOut.value.time.min);
|
||||||
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.time.sec == testTimestampOut.value.time.sec);
|
||||||
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.time.hundredths ==
|
||||||
|
testTimestampOut.value.time.hundredths);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testTimestampTimeDate(
|
void testTimestampTimeDate(
|
||||||
Test * pTest)
|
Test * pTest)
|
||||||
{
|
{
|
||||||
BACNET_TIMESTAMP testTimestampIn;
|
BACNET_TIMESTAMP testTimestampIn;
|
||||||
BACNET_TIMESTAMP testTimestampOut;
|
BACNET_TIMESTAMP testTimestampOut;
|
||||||
uint8_t buffer[MAX_APDU];
|
uint8_t buffer[MAX_APDU];
|
||||||
int inLen;
|
int inLen;
|
||||||
int outLen;
|
int outLen;
|
||||||
|
|
||||||
testTimestampIn.tag = TIME_STAMP_DATETIME;
|
testTimestampIn.tag = TIME_STAMP_DATETIME;
|
||||||
testTimestampIn.value.dateTime.time.hour = 1;
|
testTimestampIn.value.dateTime.time.hour = 1;
|
||||||
testTimestampIn.value.dateTime.time.min = 2;
|
testTimestampIn.value.dateTime.time.min = 2;
|
||||||
testTimestampIn.value.dateTime.time.sec = 3;
|
testTimestampIn.value.dateTime.time.sec = 3;
|
||||||
testTimestampIn.value.dateTime.time.hundredths = 4;
|
testTimestampIn.value.dateTime.time.hundredths = 4;
|
||||||
|
|
||||||
testTimestampIn.value.dateTime.date.year = 1901;
|
testTimestampIn.value.dateTime.date.year = 1901;
|
||||||
testTimestampIn.value.dateTime.date.month = 1;
|
testTimestampIn.value.dateTime.date.month = 1;
|
||||||
testTimestampIn.value.dateTime.date.wday = 2;
|
testTimestampIn.value.dateTime.date.wday = 2;
|
||||||
testTimestampIn.value.dateTime.date.day = 3;
|
testTimestampIn.value.dateTime.date.day = 3;
|
||||||
|
|
||||||
memset(&testTimestampOut, 0, sizeof(testTimestampOut));
|
memset(&testTimestampOut, 0, sizeof(testTimestampOut));
|
||||||
|
|
||||||
inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
|
inLen = bacapp_encode_context_timestamp(buffer, 2, &testTimestampIn);
|
||||||
outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);
|
outLen = bacapp_decode_context_timestamp(buffer, 2, &testTimestampOut);
|
||||||
|
|
||||||
ct_test(pTest, inLen == outLen);
|
ct_test(pTest, inLen == outLen);
|
||||||
ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
|
ct_test(pTest, testTimestampIn.tag == testTimestampOut.tag);
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.time.hour == testTimestampOut.value.dateTime.time.hour);
|
ct_test(pTest,
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.time.min == testTimestampOut.value.dateTime.time.min);
|
testTimestampIn.value.dateTime.time.hour ==
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.time.sec == testTimestampOut.value.dateTime.time.sec);
|
testTimestampOut.value.dateTime.time.hour);
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.time.hundredths == testTimestampOut.value.dateTime.time.hundredths);
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.dateTime.time.min ==
|
||||||
|
testTimestampOut.value.dateTime.time.min);
|
||||||
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.dateTime.time.sec ==
|
||||||
|
testTimestampOut.value.dateTime.time.sec);
|
||||||
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.dateTime.time.hundredths ==
|
||||||
|
testTimestampOut.value.dateTime.time.hundredths);
|
||||||
|
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.date.year == testTimestampOut.value.dateTime.date.year);
|
ct_test(pTest,
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.date.month == testTimestampOut.value.dateTime.date.month);
|
testTimestampIn.value.dateTime.date.year ==
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.date.wday == testTimestampOut.value.dateTime.date.wday);
|
testTimestampOut.value.dateTime.date.year);
|
||||||
ct_test(pTest, testTimestampIn.value.dateTime.date.day == testTimestampOut.value.dateTime.date.day);
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.dateTime.date.month ==
|
||||||
|
testTimestampOut.value.dateTime.date.month);
|
||||||
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.dateTime.date.wday ==
|
||||||
|
testTimestampOut.value.dateTime.date.wday);
|
||||||
|
ct_test(pTest,
|
||||||
|
testTimestampIn.value.dateTime.date.day ==
|
||||||
|
testTimestampOut.value.dateTime.date.day);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,4 +299,3 @@ int main(
|
|||||||
|
|
||||||
#endif // TEST_TIME_STAMP
|
#endif // TEST_TIME_STAMP
|
||||||
#endif // TEST
|
#endif // TEST
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ int whohas_decode_service_request(
|
|||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value = 0;
|
uint32_t len_value = 0;
|
||||||
uint32_t decoded_value = 0; /* for decoding */
|
uint32_t decoded_value = 0; /* for decoding */
|
||||||
uint16_t decoded_type = 0; /* for decoding */
|
uint16_t decoded_type = 0; /* for decoding */
|
||||||
|
|
||||||
if (apdu_len && data) {
|
if (apdu_len && data) {
|
||||||
/* optional limits - must be used as a pair */
|
/* optional limits - must be used as a pair */
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ int wp_decode_service_request(
|
|||||||
int tag_len = 0;
|
int tag_len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
uint16_t type = 0; /* for decoding */
|
uint16_t type = 0; /* for decoding */
|
||||||
int property = 0; /* for decoding */
|
int property = 0; /* for decoding */
|
||||||
uint32_t unsigned_value = 0;
|
uint32_t unsigned_value = 0;
|
||||||
int i = 0; /* loop counter */
|
int i = 0; /* loop counter */
|
||||||
|
|||||||
Reference in New Issue
Block a user