Bugfix/clang tidy applied 2022 (#232)
* clang-tidy applied fixes to src folder * clang-tidy applied fixes to apps folder Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -212,11 +212,12 @@ pretty-ports:
|
|||||||
find ./ports -maxdepth 2 -type f -iname *.h -o -iname *.c -exec \
|
find ./ports -maxdepth 2 -type f -iname *.h -o -iname *.c -exec \
|
||||||
clang-format -i -style=file -fallback-style=none {} \;
|
clang-format -i -style=file -fallback-style=none {} \;
|
||||||
|
|
||||||
|
CLANG_TIDY_OPTIONS = -fix-errors -checks="readability-braces-around-statements"
|
||||||
|
CLANG_TIDY_OPTIONS += -- -Isrc -Iports/linux
|
||||||
.PHONY: tidy
|
.PHONY: tidy
|
||||||
tidy:
|
tidy:
|
||||||
find ./src -iname *.h -o -iname *.c -exec \
|
find ./src -iname *.h -o -iname *.c -exec clang-tidy {} $(CLANG_TIDY_OPTIONS) \;
|
||||||
clang-tidy {} -fix-errors -checks="readability-braces-around-statements" \
|
find ./apps -iname *.c -exec clang-tidy {} $(CLANG_TIDY_OPTIONS) \;
|
||||||
-- -Isrc -Iports/linux \;
|
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
|
|||||||
@@ -393,8 +393,9 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
|
|||||||
+2
-1
@@ -246,8 +246,9 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
|
|||||||
+70
-43
@@ -215,11 +215,12 @@ static void MyAbortHandler(
|
|||||||
#endif
|
#endif
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
Last_Error_Class = ERROR_CLASS_SERVICES;
|
Last_Error_Class = ERROR_CLASS_SERVICES;
|
||||||
if (abort_reason < MAX_BACNET_ABORT_REASON)
|
if (abort_reason < MAX_BACNET_ABORT_REASON) {
|
||||||
Last_Error_Code =
|
Last_Error_Code =
|
||||||
(ERROR_CODE_ABORT_BUFFER_OVERFLOW - 1) + abort_reason;
|
(ERROR_CODE_ABORT_BUFFER_OVERFLOW - 1) + abort_reason;
|
||||||
else
|
} else {
|
||||||
Last_Error_Code = ERROR_CODE_ABORT_OTHER;
|
Last_Error_Code = ERROR_CODE_ABORT_OTHER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,11 +237,12 @@ static void MyRejectHandler(
|
|||||||
#endif
|
#endif
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
Last_Error_Class = ERROR_CLASS_SERVICES;
|
Last_Error_Class = ERROR_CLASS_SERVICES;
|
||||||
if (reject_reason < MAX_BACNET_REJECT_REASON)
|
if (reject_reason < MAX_BACNET_REJECT_REASON) {
|
||||||
Last_Error_Code =
|
Last_Error_Code =
|
||||||
(ERROR_CODE_REJECT_BUFFER_OVERFLOW - 1) + reject_reason;
|
(ERROR_CODE_REJECT_BUFFER_OVERFLOW - 1) + reject_reason;
|
||||||
else
|
} else {
|
||||||
Last_Error_Code = ERROR_CODE_REJECT_OTHER;
|
Last_Error_Code = ERROR_CODE_REJECT_OTHER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,8 +267,9 @@ static void MyReadPropertyAckHandler(uint8_t *service_request,
|
|||||||
Read_Property_Multiple_Data.rpm_data = rp_data;
|
Read_Property_Multiple_Data.rpm_data = rp_data;
|
||||||
Read_Property_Multiple_Data.new_data = true;
|
Read_Property_Multiple_Data.new_data = true;
|
||||||
} else {
|
} else {
|
||||||
if (len < 0) /* Eg, failed due to no segmentation */
|
if (len < 0) { /* Eg, failed due to no segmentation */
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
|
}
|
||||||
free(rp_data);
|
free(rp_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,8 +297,9 @@ static void MyReadPropertyMultipleAckHandler(uint8_t *service_request,
|
|||||||
Read_Property_Multiple_Data.new_data = true;
|
Read_Property_Multiple_Data.new_data = true;
|
||||||
/* Will process and free the RPM data later */
|
/* Will process and free the RPM data later */
|
||||||
} else {
|
} else {
|
||||||
if (len < 0) /* Eg, failed due to no segmentation */
|
if (len < 0) { /* Eg, failed due to no segmentation */
|
||||||
Error_Detected = true;
|
Error_Detected = true;
|
||||||
|
}
|
||||||
free(rpm_data);
|
free(rpm_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,9 +425,10 @@ static void CheckIsWritableProperty(BACNET_OBJECT_TYPE object_type,
|
|||||||
* Life Safety Tracking_Value, Reliability, Mode,
|
* Life Safety Tracking_Value, Reliability, Mode,
|
||||||
* or Present_Value when Out_Of_Service is TRUE.
|
* or Present_Value when Out_Of_Service is TRUE.
|
||||||
*/
|
*/
|
||||||
if (bIsWritable)
|
if (bIsWritable) {
|
||||||
fprintf(stdout, " Writable");
|
fprintf(stdout, " Writable");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const char *protocol_services_supported_text(size_t bit_index)
|
static const char *protocol_services_supported_text(size_t bit_index)
|
||||||
{
|
{
|
||||||
@@ -498,8 +503,9 @@ static bool PrettyPrintPropertyValue(
|
|||||||
fprintf(stream, " %s,",
|
fprintf(stream, " %s,",
|
||||||
protocol_services_supported_text(j));
|
protocol_services_supported_text(j));
|
||||||
}
|
}
|
||||||
} else /* not supported */
|
} else { /* not supported */
|
||||||
fprintf(stream, ",");
|
fprintf(stream, ",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(stream, "\n ");
|
fprintf(stream, "\n ");
|
||||||
}
|
}
|
||||||
@@ -518,8 +524,9 @@ static bool PrettyPrintPropertyValue(
|
|||||||
assert(false); /* How did I get here? Fix your code. */
|
assert(false); /* How did I get here? Fix your code. */
|
||||||
/* Meanwhile, a fallback plan */
|
/* Meanwhile, a fallback plan */
|
||||||
status = bacapp_print_value(stdout, object_value);
|
status = bacapp_print_value(stdout, object_value);
|
||||||
} else
|
} else {
|
||||||
fprintf(stream, "? \n");
|
fprintf(stream, "? \n");
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -576,8 +583,9 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
PROP_PROTOCOL_CONFORMANCE_CLASS;
|
PROP_PROTOCOL_CONFORMANCE_CLASS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (object_type == OBJECT_DATETIME_VALUE)
|
if (object_type == OBJECT_DATETIME_VALUE) {
|
||||||
break; /* A special case - no braces for this pair */
|
break; /* A special case - no braces for this pair */
|
||||||
|
}
|
||||||
/* Else, fall through to normal processing. */
|
/* Else, fall through to normal processing. */
|
||||||
default:
|
default:
|
||||||
/* Normal array: open brace */
|
/* Normal array: open brace */
|
||||||
@@ -587,8 +595,9 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Using_Walked_List)
|
if (!Using_Walked_List) {
|
||||||
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
|
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
|
||||||
|
}
|
||||||
/* value(s) loop until there is no "next" ... */
|
/* value(s) loop until there is no "next" ... */
|
||||||
while (value != NULL) {
|
while (value != NULL) {
|
||||||
object_value.object_property = rpm_property->propertyIdentifier;
|
object_value.object_property = rpm_property->propertyIdentifier;
|
||||||
@@ -608,19 +617,22 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
* print it! */
|
* print it! */
|
||||||
Walked_List_Length = value->type.Unsigned_Int;
|
Walked_List_Length = value->type.Unsigned_Int;
|
||||||
if (rpm_property->propertyIdentifier ==
|
if (rpm_property->propertyIdentifier ==
|
||||||
PROP_OBJECT_LIST)
|
PROP_OBJECT_LIST) {
|
||||||
Object_List_Length = value->type.Unsigned_Int;
|
Object_List_Length = value->type.Unsigned_Int;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} else
|
} else {
|
||||||
assert(Walked_List_Index ==
|
assert(Walked_List_Index ==
|
||||||
(uint32_t)rpm_property->propertyArrayIndex);
|
(uint32_t)rpm_property->propertyArrayIndex);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Walked_List_Index++;
|
Walked_List_Index++;
|
||||||
/* If we got the whole Object List array in one RP call,
|
/* If we got the whole Object List array in one RP call,
|
||||||
* keep the Index and List_Length in sync as we cycle
|
* keep the Index and List_Length in sync as we cycle
|
||||||
* through. */
|
* through. */
|
||||||
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST)
|
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
||||||
Object_List_Length = ++Object_List_Index;
|
Object_List_Length = ++Object_List_Index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Walked_List_Index == 1) {
|
if (Walked_List_Index == 1) {
|
||||||
/* If the array is empty (nothing for this first entry),
|
/* If the array is empty (nothing for this first entry),
|
||||||
@@ -634,10 +646,11 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
/* Open this Array of Objects for the first entry (unless
|
/* Open this Array of Objects for the first entry (unless
|
||||||
* opening brace has already printed, since this is an array
|
* opening brace has already printed, since this is an array
|
||||||
* of values[] ) */
|
* of values[] ) */
|
||||||
if (value->next == NULL)
|
if (value->next == NULL) {
|
||||||
fprintf(stdout, "{ \n ");
|
fprintf(stdout, "{ \n ");
|
||||||
else
|
} else {
|
||||||
fprintf(stdout, "\n ");
|
fprintf(stdout, "\n ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
|
||||||
@@ -685,18 +698,21 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
|||||||
|
|
||||||
/* If the object is a Sequence, it needs its own bracketing
|
/* If the object is a Sequence, it needs its own bracketing
|
||||||
* braces */
|
* braces */
|
||||||
if (isSequence)
|
if (isSequence) {
|
||||||
fprintf(stdout, "{");
|
fprintf(stdout, "{");
|
||||||
|
}
|
||||||
bacapp_print_value(stdout, &object_value);
|
bacapp_print_value(stdout, &object_value);
|
||||||
if (isSequence)
|
if (isSequence) {
|
||||||
fprintf(stdout, "}");
|
fprintf(stdout, "}");
|
||||||
|
}
|
||||||
|
|
||||||
if ((Walked_List_Index < Walked_List_Length) ||
|
if ((Walked_List_Index < Walked_List_Length) ||
|
||||||
(value->next != NULL)) {
|
(value->next != NULL)) {
|
||||||
/* There are more. */
|
/* There are more. */
|
||||||
fprintf(stdout, ", ");
|
fprintf(stdout, ", ");
|
||||||
if (!(Walked_List_Index % 3))
|
if (!(Walked_List_Index % 3)) {
|
||||||
fprintf(stdout, "\n ");
|
fprintf(stdout, "\n ");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stdout, " } \n");
|
fprintf(stdout, " } \n");
|
||||||
}
|
}
|
||||||
@@ -966,9 +982,9 @@ static EPICS_STATES ProcessRPMData(
|
|||||||
if (myState == GET_HEADING_RESPONSE) {
|
if (myState == GET_HEADING_RESPONSE) {
|
||||||
nextState = PRINT_HEADING;
|
nextState = PRINT_HEADING;
|
||||||
/* press ahead with or without the data */
|
/* press ahead with or without the data */
|
||||||
} else if (bSuccess && (myState == GET_ALL_RESPONSE))
|
} else if (bSuccess && (myState == GET_ALL_RESPONSE)) {
|
||||||
nextState = NEXT_OBJECT;
|
nextState = NEXT_OBJECT;
|
||||||
else if (bSuccess) { /* and GET_LIST_OF_ALL_RESPONSE */
|
} else if (bSuccess) { /* and GET_LIST_OF_ALL_RESPONSE */
|
||||||
/* Now append the properties we waited on. */
|
/* Now append the properties we waited on. */
|
||||||
if (bHasStructuredViewList) {
|
if (bHasStructuredViewList) {
|
||||||
Property_List[Property_List_Index] = PROP_STRUCTURED_OBJECT_LIST;
|
Property_List[Property_List_Index] = PROP_STRUCTURED_OBJECT_LIST;
|
||||||
@@ -1071,11 +1087,13 @@ static int CheckCommandLineArgs(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
/* Destination Network Number */
|
/* Destination Network Number */
|
||||||
if (Target_Address.mac_len == 0)
|
if (Target_Address.mac_len == 0) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "Must provide a Target MAC before DNET \n");
|
stderr, "Must provide a Target MAC before DNET \n");
|
||||||
if (++i < argc)
|
}
|
||||||
|
if (++i < argc) {
|
||||||
Target_Address.net = (uint16_t)strtol(argv[i], NULL, 0);
|
Target_Address.net = (uint16_t)strtol(argv[i], NULL, 0);
|
||||||
|
}
|
||||||
/* Used strtol so dest.net can be either 0x1234 or 4660 */
|
/* Used strtol so dest.net can be either 0x1234 or 4660 */
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
@@ -1210,8 +1228,9 @@ static void PrintHeading(void)
|
|||||||
int i, len = bitstring_bits_used(&value->type.Bit_String);
|
int i, len = bitstring_bits_used(&value->type.Bit_String);
|
||||||
printf("-- services reported by this device\n");
|
printf("-- services reported by this device\n");
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i))
|
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i)) {
|
||||||
printf(" %s\n", protocol_services_supported_text(i));
|
printf(" %s\n", protocol_services_supported_text(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("-- use \'Initiate\' or \'Execute\' or both for services.\n");
|
printf("-- use \'Initiate\' or \'Execute\' or both for services.\n");
|
||||||
@@ -1257,8 +1276,9 @@ static void PrintHeading(void)
|
|||||||
int i, len = bitstring_bits_used(&value->type.Bit_String);
|
int i, len = bitstring_bits_used(&value->type.Bit_String);
|
||||||
printf("-- objects reported by this device\n");
|
printf("-- objects reported by this device\n");
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i))
|
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i)) {
|
||||||
printf(" %s\n", bactext_object_type_name(i));
|
printf(" %s\n", bactext_object_type_name(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("-- possible objects in this device\n");
|
printf("-- possible objects in this device\n");
|
||||||
@@ -1478,8 +1498,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Update by adding the MAC address */
|
/* Update by adding the MAC address */
|
||||||
if (max_apdu == 0)
|
if (max_apdu == 0) {
|
||||||
max_apdu = MAX_APDU; /* Whatever set for this datalink. */
|
max_apdu = MAX_APDU; /* Whatever set for this datalink. */
|
||||||
|
}
|
||||||
address_add_binding(
|
address_add_binding(
|
||||||
Target_Device_Object_Instance, max_apdu, &Target_Address);
|
Target_Device_Object_Instance, max_apdu, &Target_Address);
|
||||||
}
|
}
|
||||||
@@ -1572,10 +1593,11 @@ int main(int argc, char *argv[])
|
|||||||
buffer, MAX_PDU, Target_Device_Object_Instance, rpm_object);
|
buffer, MAX_PDU, Target_Device_Object_Instance, rpm_object);
|
||||||
if (Request_Invoke_ID > 0) {
|
if (Request_Invoke_ID > 0) {
|
||||||
elapsed_seconds = 0;
|
elapsed_seconds = 0;
|
||||||
if (myState == GET_LIST_OF_ALL_REQUEST)
|
if (myState == GET_LIST_OF_ALL_REQUEST) {
|
||||||
myState = GET_LIST_OF_ALL_RESPONSE;
|
myState = GET_LIST_OF_ALL_RESPONSE;
|
||||||
else
|
} else {
|
||||||
myState = GET_ALL_RESPONSE;
|
myState = GET_ALL_RESPONSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1606,10 +1628,10 @@ int main(int argc, char *argv[])
|
|||||||
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||||
elapsed_seconds = 0;
|
elapsed_seconds = 0;
|
||||||
Request_Invoke_ID = 0;
|
Request_Invoke_ID = 0;
|
||||||
if (myState == GET_HEADING_RESPONSE)
|
if (myState == GET_HEADING_RESPONSE) {
|
||||||
myState = PRINT_HEADING;
|
myState = PRINT_HEADING;
|
||||||
/* just press ahead without the data */
|
/* just press ahead without the data */
|
||||||
else if (Error_Detected) {
|
} else if (Error_Detected) {
|
||||||
if (Last_Error_Code ==
|
if (Last_Error_Code ==
|
||||||
ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) {
|
ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) {
|
||||||
/* The normal case for Device Object */
|
/* The normal case for Device Object */
|
||||||
@@ -1620,37 +1642,40 @@ int main(int argc, char *argv[])
|
|||||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED) {
|
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED) {
|
||||||
myState = GET_PROPERTY_REQUEST;
|
myState = GET_PROPERTY_REQUEST;
|
||||||
StartNextObject(rpm_object, &myObject);
|
StartNextObject(rpm_object, &myObject);
|
||||||
} else if (myState == GET_ALL_RESPONSE)
|
} else if (myState == GET_ALL_RESPONSE) {
|
||||||
/* Try again, just to get a list of properties. */
|
/* Try again, just to get a list of properties. */
|
||||||
myState = GET_LIST_OF_ALL_REQUEST;
|
myState = GET_LIST_OF_ALL_REQUEST;
|
||||||
else {
|
} else {
|
||||||
/* Else drop back to RP. */
|
/* Else drop back to RP. */
|
||||||
myState = GET_PROPERTY_REQUEST;
|
myState = GET_PROPERTY_REQUEST;
|
||||||
StartNextObject(rpm_object, &myObject);
|
StartNextObject(rpm_object, &myObject);
|
||||||
}
|
}
|
||||||
} else if (Has_RPM)
|
} else if (Has_RPM) {
|
||||||
myState = GET_ALL_REQUEST; /* Let's try again */
|
myState = GET_ALL_REQUEST; /* Let's try again */
|
||||||
else
|
} else {
|
||||||
myState = GET_PROPERTY_REQUEST;
|
myState = GET_PROPERTY_REQUEST;
|
||||||
|
}
|
||||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
||||||
fprintf(stderr, "\rError: TSM Timeout!\n");
|
fprintf(stderr, "\rError: TSM Timeout!\n");
|
||||||
tsm_free_invoke_id(Request_Invoke_ID);
|
tsm_free_invoke_id(Request_Invoke_ID);
|
||||||
Request_Invoke_ID = 0;
|
Request_Invoke_ID = 0;
|
||||||
elapsed_seconds = 0;
|
elapsed_seconds = 0;
|
||||||
if (myState == GET_HEADING_RESPONSE)
|
if (myState == GET_HEADING_RESPONSE) {
|
||||||
myState = PRINT_HEADING;
|
myState = PRINT_HEADING;
|
||||||
/* just press ahead without the data */
|
/* just press ahead without the data */
|
||||||
else
|
} else {
|
||||||
myState = GET_ALL_REQUEST; /* Let's try again */
|
myState = GET_ALL_REQUEST; /* Let's try again */
|
||||||
|
}
|
||||||
} else if (Error_Detected) {
|
} else if (Error_Detected) {
|
||||||
/* Don't think we'll ever actually reach this point. */
|
/* Don't think we'll ever actually reach this point. */
|
||||||
elapsed_seconds = 0;
|
elapsed_seconds = 0;
|
||||||
Request_Invoke_ID = 0;
|
Request_Invoke_ID = 0;
|
||||||
if (myState == GET_HEADING_RESPONSE)
|
if (myState == GET_HEADING_RESPONSE) {
|
||||||
myState = PRINT_HEADING;
|
myState = PRINT_HEADING;
|
||||||
/* just press ahead without the data */
|
/* just press ahead without the data */
|
||||||
else
|
} else {
|
||||||
myState = NEXT_OBJECT; /* Give up and move on to the
|
myState = NEXT_OBJECT;
|
||||||
|
}/* Give up and move on to the
|
||||||
next. */
|
next. */
|
||||||
Error_Count++;
|
Error_Count++;
|
||||||
}
|
}
|
||||||
@@ -1668,8 +1693,9 @@ int main(int argc, char *argv[])
|
|||||||
if (Request_Invoke_ID == 0) {
|
if (Request_Invoke_ID == 0) {
|
||||||
/* Reached the end of the list. */
|
/* Reached the end of the list. */
|
||||||
myState = NEXT_OBJECT; /* Move on to the next. */
|
myState = NEXT_OBJECT; /* Move on to the next. */
|
||||||
} else
|
} else {
|
||||||
myState = GET_PROPERTY_RESPONSE;
|
myState = GET_PROPERTY_RESPONSE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GET_PROPERTY_RESPONSE:
|
case GET_PROPERTY_RESPONSE:
|
||||||
@@ -1784,8 +1810,9 @@ int main(int argc, char *argv[])
|
|||||||
myObject.type = KEY_DECODE_TYPE(nextKey);
|
myObject.type = KEY_DECODE_TYPE(nextKey);
|
||||||
myObject.instance = KEY_DECODE_ID(nextKey);
|
myObject.instance = KEY_DECODE_ID(nextKey);
|
||||||
/* Don't re-list the Device Object among its objects */
|
/* Don't re-list the Device Object among its objects */
|
||||||
if (myObject.type == OBJECT_DEVICE)
|
if (myObject.type == OBJECT_DEVICE) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
/* Closing brace for the previous Object */
|
/* Closing brace for the previous Object */
|
||||||
printf(" }, \n");
|
printf(" }, \n");
|
||||||
/* Opening brace for the new Object */
|
/* Opening brace for the new Object */
|
||||||
@@ -1802,9 +1829,9 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
myObject.type = MAX_BACNET_OBJECT_TYPE;
|
myObject.type = MAX_BACNET_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
if (Has_RPM)
|
if (Has_RPM) {
|
||||||
myState = GET_ALL_REQUEST;
|
myState = GET_ALL_REQUEST;
|
||||||
else {
|
} else {
|
||||||
myState = GET_PROPERTY_REQUEST;
|
myState = GET_PROPERTY_REQUEST;
|
||||||
StartNextObject(rpm_object, &myObject);
|
StartNextObject(rpm_object, &myObject);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -585,8 +585,9 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
|
|||||||
@@ -125,8 +125,9 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
|
|||||||
int len = 0;
|
int len = 0;
|
||||||
int i;
|
int i;
|
||||||
BACNET_GET_EVENT_INFORMATION_DATA data[MAX_OBJ_IDS_IN_GE_ACK];
|
BACNET_GET_EVENT_INFORMATION_DATA data[MAX_OBJ_IDS_IN_GE_ACK];
|
||||||
for (i = 0; i < MAX_OBJ_IDS_IN_GE_ACK - 1; i++)
|
for (i = 0; i < MAX_OBJ_IDS_IN_GE_ACK - 1; i++) {
|
||||||
data[i].next = &data[i + 1];
|
data[i].next = &data[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
printf("Recieved Ack. Saved invoke ID was %i, service returned %i\n",
|
printf("Recieved Ack. Saved invoke ID was %i, service returned %i\n",
|
||||||
Request_Invoke_ID, service_data->invoke_id);
|
Request_Invoke_ID, service_data->invoke_id);
|
||||||
@@ -140,8 +141,9 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
|
|||||||
ge_ack_print_data(&(data[0]), Target_Device_Object_Instance);
|
ge_ack_print_data(&(data[0]), Target_Device_Object_Instance);
|
||||||
if (More_Events) {
|
if (More_Events) {
|
||||||
BACNET_GET_EVENT_INFORMATION_DATA *lastData = &(data[0]);
|
BACNET_GET_EVENT_INFORMATION_DATA *lastData = &(data[0]);
|
||||||
while (lastData->next)
|
while (lastData->next) {
|
||||||
lastData = lastData->next;
|
lastData = lastData->next;
|
||||||
|
}
|
||||||
LastReceivedObjectIdentifier = lastData->objectIdentifier;
|
LastReceivedObjectIdentifier = lastData->objectIdentifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,7 +285,8 @@ int main(int argc, char *argv[])
|
|||||||
/* keep track of time for next check */
|
/* keep track of time for next check */
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,8 +363,9 @@ int main(int argc, char *argv[])
|
|||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
My_NPDU_Handler(&src, &Rx_Buf[0], pdu_len);
|
My_NPDU_Handler(&src, &Rx_Buf[0], pdu_len);
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds = current_seconds - last_seconds;
|
elapsed_seconds = current_seconds - last_seconds;
|
||||||
if (elapsed_seconds) {
|
if (elapsed_seconds) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ static void MyAbortHandler(
|
|||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
char msg[MAX_ERROR_STRING];
|
char msg[MAX_ERROR_STRING];
|
||||||
sprintf(msg, "BACnet Abort: %s",
|
sprintf(msg, "BACnet Abort: %d",
|
||||||
bactext_abort_reason_name((int)abort_reason));
|
bactext_abort_reason_name((int)abort_reason));
|
||||||
LogError(msg);
|
LogError(msg);
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ static void MyRejectHandler(
|
|||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
char msg[MAX_ERROR_STRING];
|
char msg[MAX_ERROR_STRING];
|
||||||
sprintf(msg, "BACnet Reject: %s",
|
sprintf(msg, "BACnet Reject: %d",
|
||||||
bactext_reject_reason_name((int)reject_reason));
|
bactext_reject_reason_name((int)reject_reason));
|
||||||
LogError(msg);
|
LogError(msg);
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ static void My_Error_Handler(BACNET_ADDRESS *src,
|
|||||||
if (address_match(&Target_Address, src) &&
|
if (address_match(&Target_Address, src) &&
|
||||||
(invoke_id == Request_Invoke_ID)) {
|
(invoke_id == Request_Invoke_ID)) {
|
||||||
char msg[MAX_ERROR_STRING];
|
char msg[MAX_ERROR_STRING];
|
||||||
sprintf(msg, "BACnet Error: %s: %s",
|
sprintf(msg, "BACnet Error: %d: %d",
|
||||||
bactext_error_class_name((int)error_class),
|
bactext_error_class_name((int)error_class),
|
||||||
bactext_error_code_name((int)error_code));
|
bactext_error_code_name((int)error_code));
|
||||||
LogError(msg);
|
LogError(msg);
|
||||||
@@ -209,7 +209,7 @@ void rpm_ack_extract_data(BACNET_READ_ACCESS_DATA *rpm_data)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* AccessError */
|
/* AccessError */
|
||||||
sprintf(ackString, "BACnet Error: %s: %s",
|
sprintf(ackString, "BACnet Error: %d: %d",
|
||||||
bactext_error_class_name(
|
bactext_error_class_name(
|
||||||
(int)listOfProperties->error.error_class),
|
(int)listOfProperties->error.error_class),
|
||||||
bactext_error_code_name(
|
bactext_error_code_name(
|
||||||
|
|||||||
@@ -376,8 +376,9 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
|
|||||||
/* Make the change and update the database revision */
|
/* Make the change and update the database revision */
|
||||||
Object_Instance_Number = object_id;
|
Object_Instance_Number = object_id;
|
||||||
Device_Inc_Database_Revision();
|
Device_Inc_Database_Revision();
|
||||||
} else
|
} else {
|
||||||
status = false;
|
status = false;
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -981,13 +982,13 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
|||||||
case PROP_OBJECT_LIST:
|
case PROP_OBJECT_LIST:
|
||||||
count = Device_Object_List_Count();
|
count = Device_Object_List_Count();
|
||||||
/* Array element zero is the number of objects in the list */
|
/* Array element zero is the number of objects in the list */
|
||||||
if (rpdata->array_index == 0)
|
if (rpdata->array_index == 0) {
|
||||||
apdu_len = encode_application_unsigned(&apdu[0], count);
|
apdu_len = encode_application_unsigned(&apdu[0], count);
|
||||||
/* if no index was specified, then try to encode the entire list */
|
/* if no index was specified, then try to encode the entire list */
|
||||||
/* into one packet. Note that more than likely you will have */
|
/* into one packet. Note that more than likely you will have */
|
||||||
/* to return an error if the number of encoded objects exceeds */
|
/* to return an error if the number of encoded objects exceeds */
|
||||||
/* your maximum APDU size. */
|
/* your maximum APDU size. */
|
||||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||||
for (i = 1; i <= count; i++) {
|
for (i = 1; i <= count; i++) {
|
||||||
found = Device_Object_List_Identifier(
|
found = Device_Object_List_Identifier(
|
||||||
i, &object_type, &instance);
|
i, &object_type, &instance);
|
||||||
@@ -1192,7 +1193,7 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_OBJECT_NAME:
|
case PROP_OBJECT_NAME:
|
||||||
status = write_property_string_valid(&wp_data, &value,
|
status = write_property_string_valid(wp_data, &value,
|
||||||
characterstring_capacity(&My_Object_Name));
|
characterstring_capacity(&My_Object_Name));
|
||||||
if (status) {
|
if (status) {
|
||||||
/* All the object names in a device must be unique */
|
/* All the object names in a device must be unique */
|
||||||
@@ -1213,7 +1214,7 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
status = write_property_empty_string_valid(&wp_data, &value,
|
status = write_property_empty_string_valid(wp_data, &value,
|
||||||
MAX_DEV_LOC_LEN);
|
MAX_DEV_LOC_LEN);
|
||||||
if (status) {
|
if (status) {
|
||||||
Device_Set_Location(
|
Device_Set_Location(
|
||||||
@@ -1223,7 +1224,7 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DESCRIPTION:
|
case PROP_DESCRIPTION:
|
||||||
status = write_property_empty_string_valid(&wp_data, &value,
|
status = write_property_empty_string_valid(wp_data, &value,
|
||||||
MAX_DEV_DESC_LEN);
|
MAX_DEV_DESC_LEN);
|
||||||
if (status) {
|
if (status) {
|
||||||
Device_Set_Description(
|
Device_Set_Description(
|
||||||
@@ -1232,7 +1233,7 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_MODEL_NAME:
|
case PROP_MODEL_NAME:
|
||||||
status = write_property_empty_string_valid(&wp_data, &value,
|
status = write_property_empty_string_valid(wp_data, &value,
|
||||||
MAX_DEV_MOD_LEN);
|
MAX_DEV_MOD_LEN);
|
||||||
if (status) {
|
if (status) {
|
||||||
Device_Set_Model_Name(
|
Device_Set_Model_Name(
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
|||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
||||||
iLen += tag_len;
|
iLen += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT)
|
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
|
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
|
||||||
Response.cMyByte1 = (char)ulTemp;
|
Response.cMyByte1 = (char)ulTemp;
|
||||||
@@ -69,8 +70,9 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
|||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
||||||
iLen += tag_len;
|
iLen += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT)
|
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
|
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
|
||||||
Response.cMyByte2 = (char)ulTemp;
|
Response.cMyByte2 = (char)ulTemp;
|
||||||
@@ -78,16 +80,18 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
|||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
||||||
iLen += tag_len;
|
iLen += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_REAL)
|
if (tag_number != BACNET_APPLICATION_TAG_REAL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
iLen += decode_real(&pData[iLen], &Response.fMyReal);
|
iLen += decode_real(&pData[iLen], &Response.fMyReal);
|
||||||
|
|
||||||
tag_len =
|
tag_len =
|
||||||
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
decode_tag_number_and_value(&pData[iLen], &tag_number, &len_value_type);
|
||||||
iLen += tag_len;
|
iLen += tag_len;
|
||||||
if (tag_number != BACNET_APPLICATION_TAG_CHARACTER_STRING)
|
if (tag_number != BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
||||||
strncpy(
|
strncpy(
|
||||||
|
|||||||
@@ -299,12 +299,14 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
((current_seconds - last_seconds) * 1000));
|
((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found)
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
Target_Device_Object_Instance, &max_apdu, &Target_Address);
|
Target_Device_Object_Instance, &max_apdu, &Target_Address);
|
||||||
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
if (invoke_id == 0) { /* Safe to send a new request */
|
if (invoke_id == 0) { /* Safe to send a new request */
|
||||||
switch (iType) {
|
switch (iType) {
|
||||||
@@ -394,7 +396,8 @@ int main(int argc, char *argv[])
|
|||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,9 @@ uint8_t Send_Private_Transfer_Request(uint32_t device_id,
|
|||||||
/* is the device bound? */
|
/* is the device bound? */
|
||||||
status = address_get_by_device(device_id, &max_apdu, &dest);
|
status = address_get_by_device(device_id, &max_apdu, &dest);
|
||||||
/* is there a tsm available? */
|
/* is there a tsm available? */
|
||||||
if (status)
|
if (status) {
|
||||||
invoke_id = tsm_next_free_invokeID();
|
invoke_id = tsm_next_free_invokeID();
|
||||||
|
}
|
||||||
if (invoke_id) {
|
if (invoke_id) {
|
||||||
/* encode the NPDU portion of the packet */
|
/* encode the NPDU portion of the packet */
|
||||||
datalink_get_my_address(&my_address);
|
datalink_get_my_address(&my_address);
|
||||||
|
|||||||
+2
-1
@@ -171,8 +171,9 @@ int main(int argc, char *argv[])
|
|||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds = current_seconds - last_seconds;
|
elapsed_seconds = current_seconds - last_seconds;
|
||||||
if (elapsed_seconds) {
|
if (elapsed_seconds) {
|
||||||
|
|||||||
+2
-1
@@ -170,8 +170,9 @@ int main(int argc, char *argv[])
|
|||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds = current_seconds - last_seconds;
|
elapsed_seconds = current_seconds - last_seconds;
|
||||||
if (elapsed_seconds) {
|
if (elapsed_seconds) {
|
||||||
|
|||||||
@@ -397,8 +397,9 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -441,7 +442,8 @@ int main(int argc, char *argv[])
|
|||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,8 +457,9 @@ int main(int argc, char *argv[])
|
|||||||
if (current_seconds != last_seconds) {
|
if (current_seconds != last_seconds) {
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -500,7 +501,8 @@ int main(int argc, char *argv[])
|
|||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -355,8 +355,9 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -397,7 +398,8 @@ int main(int argc, char *argv[])
|
|||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -206,8 +206,9 @@ int main(int argc, char *argv[])
|
|||||||
if (current_seconds != last_seconds) {
|
if (current_seconds != last_seconds) {
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -240,7 +241,8 @@ int main(int argc, char *argv[])
|
|||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,8 +307,9 @@ int dl_ip_recv(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* the signature of a BACnet/IP packet */
|
/* the signature of a BACnet/IP packet */
|
||||||
if (data->buff[0] != BVLL_TYPE_BACNET_IP)
|
if (data->buff[0] != BVLL_TYPE_BACNET_IP) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
switch (data->buff[1]) {
|
switch (data->buff[1]) {
|
||||||
case BVLC_ORIGINAL_UNICAST_NPDU:
|
case BVLC_ORIGINAL_UNICAST_NPDU:
|
||||||
|
|||||||
+4
-2
@@ -566,9 +566,10 @@ bool parse_cmd(int argc, char *argv[])
|
|||||||
current->params.mstp_params.max_master =
|
current->params.mstp_params.max_master =
|
||||||
(uint8_t)atoi(argv[optind]);
|
(uint8_t)atoi(argv[optind]);
|
||||||
if (current->params.mstp_params.max_master <
|
if (current->params.mstp_params.max_master <
|
||||||
current->route_info.mac[0])
|
current->route_info.mac[0]) {
|
||||||
current->params.mstp_params.max_master =
|
current->params.mstp_params.max_master =
|
||||||
current->route_info.mac[0];
|
current->route_info.mac[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (argv[optind + 1][0] != '-') {
|
if (argv[optind + 1][0] != '-') {
|
||||||
current->params.mstp_params.max_frames =
|
current->params.mstp_params.max_frames =
|
||||||
@@ -778,8 +779,9 @@ uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
|||||||
/* if received from another router save real source address (not other
|
/* if received from another router save real source address (not other
|
||||||
* router source address) */
|
* router source address) */
|
||||||
if (addr.net > 0 && addr.net < BACNET_BROADCAST_NETWORK &&
|
if (addr.net > 0 && addr.net < BACNET_BROADCAST_NETWORK &&
|
||||||
data->src.net != addr.net)
|
data->src.net != addr.net) {
|
||||||
memmove(&data->src, &addr, sizeof(BACNET_ADDRESS));
|
memmove(&data->src, &addr, sizeof(BACNET_ADDRESS));
|
||||||
|
}
|
||||||
|
|
||||||
/* encode both source and destination for broadcast and router-to-router
|
/* encode both source and destination for broadcast and router-to-router
|
||||||
* communication */
|
* communication */
|
||||||
|
|||||||
@@ -83,16 +83,18 @@ void *dl_mstp_thread(void *pArgs)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port->params.mstp_params.stopbits == 2)
|
if (port->params.mstp_params.stopbits == 2) {
|
||||||
shared_port_data.RS485MOD |= CSTOPB;
|
shared_port_data.RS485MOD |= CSTOPB;
|
||||||
|
}
|
||||||
|
|
||||||
mstp_port.UserData = (void *)&shared_port_data;
|
mstp_port.UserData = (void *)&shared_port_data;
|
||||||
dlmstp_set_baud_rate(&mstp_port, port->params.mstp_params.baudrate);
|
dlmstp_set_baud_rate(&mstp_port, port->params.mstp_params.baudrate);
|
||||||
dlmstp_set_mac_address(&mstp_port, port->route_info.mac[0]);
|
dlmstp_set_mac_address(&mstp_port, port->route_info.mac[0]);
|
||||||
dlmstp_set_max_info_frames(&mstp_port, port->params.mstp_params.max_frames);
|
dlmstp_set_max_info_frames(&mstp_port, port->params.mstp_params.max_frames);
|
||||||
dlmstp_set_max_master(&mstp_port, port->params.mstp_params.max_master);
|
dlmstp_set_max_master(&mstp_port, port->params.mstp_params.max_master);
|
||||||
if (!dlmstp_init(&mstp_port, port->iface))
|
if (!dlmstp_init(&mstp_port, port->iface)) {
|
||||||
printf("MSTP %s init failed. Stop.\n", port->iface);
|
printf("MSTP %s init failed. Stop.\n", port->iface);
|
||||||
|
}
|
||||||
|
|
||||||
port->port_id = create_msgbox();
|
port->port_id = create_msgbox();
|
||||||
if (port->port_id == INVALID_MSGBOX_ID) {
|
if (port->port_id == INVALID_MSGBOX_ID) {
|
||||||
|
|||||||
@@ -129,16 +129,18 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
|||||||
add_dnet(&srcport->route_info, net,
|
add_dnet(&srcport->route_info, net,
|
||||||
data->src); /* and update routing table */
|
data->src); /* and update routing table */
|
||||||
if (data->pdu[apdu_offset + i + 3] >
|
if (data->pdu[apdu_offset + i + 3] >
|
||||||
0) /* find next NET value */
|
0) { /* find next NET value */
|
||||||
i = data->pdu[apdu_offset + i + 3] + 4;
|
i = data->pdu[apdu_offset + i + 3] + 4;
|
||||||
else
|
} else {
|
||||||
i = i + 4;
|
i = i + 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buff_len = create_network_message(
|
buff_len = create_network_message(
|
||||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, NULL);
|
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, NULL);
|
||||||
} else
|
} else {
|
||||||
buff_len = create_network_message(
|
buff_len = create_network_message(
|
||||||
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, &buff);
|
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, &buff);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
|
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
|
||||||
@@ -152,10 +154,11 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
|||||||
add_dnet(&srcport->route_info, net,
|
add_dnet(&srcport->route_info, net,
|
||||||
data->src); /* and update routing table */
|
data->src); /* and update routing table */
|
||||||
if (data->pdu[apdu_offset + i + 3] >
|
if (data->pdu[apdu_offset + i + 3] >
|
||||||
0) /* find next NET value */
|
0) { /* find next NET value */
|
||||||
i = data->pdu[apdu_offset + i + 3] + 4;
|
i = data->pdu[apdu_offset + i + 3] + 4;
|
||||||
else
|
} else {
|
||||||
i = i + 4;
|
i = i + 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -202,8 +205,9 @@ uint16_t create_network_message(
|
|||||||
bool data_expecting_reply = false;
|
bool data_expecting_reply = false;
|
||||||
BACNET_NPDU_DATA npdu_data;
|
BACNET_NPDU_DATA npdu_data;
|
||||||
|
|
||||||
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE)
|
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE) {
|
||||||
data_expecting_reply = true;
|
data_expecting_reply = true;
|
||||||
|
}
|
||||||
init_npdu(&npdu_data, network_message_type, data_expecting_reply);
|
init_npdu(&npdu_data, network_message_type, data_expecting_reply);
|
||||||
|
|
||||||
*buff = (uint8_t *)malloc(128); /* resolve different length */
|
*buff = (uint8_t *)malloc(128); /* resolve different length */
|
||||||
@@ -276,8 +280,9 @@ uint16_t create_network_message(
|
|||||||
port = port->next;
|
port = port->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
(*buff)[buff_len++] = (uint8_t)0;
|
(*buff)[buff_len++] = (uint8_t)0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NETWORK_MESSAGE_INVALID:
|
case NETWORK_MESSAGE_INVALID:
|
||||||
|
|||||||
@@ -51,16 +51,17 @@ ROUTER_PORT *find_dnet(uint16_t net, BACNET_ADDRESS *addr)
|
|||||||
DNET *dnet;
|
DNET *dnet;
|
||||||
|
|
||||||
/* for broadcast messages no search is needed */
|
/* for broadcast messages no search is needed */
|
||||||
if (net == BACNET_BROADCAST_NETWORK)
|
if (net == BACNET_BROADCAST_NETWORK) {
|
||||||
return port;
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
while (port != NULL) {
|
while (port != NULL) {
|
||||||
/* check if DNET is directly connected to the router */
|
/* check if DNET is directly connected to the router */
|
||||||
if (net == port->route_info.net)
|
if (net == port->route_info.net) {
|
||||||
return port;
|
return port;
|
||||||
|
|
||||||
/* else search router ports DNET list */
|
/* else search router ports DNET list */
|
||||||
else if (port->route_info.dnets) {
|
} else if (port->route_info.dnets) {
|
||||||
dnet = port->route_info.dnets;
|
dnet = port->route_info.dnets;
|
||||||
while (dnet != NULL) {
|
while (dnet != NULL) {
|
||||||
if (net == dnet->net) {
|
if (net == dnet->net) {
|
||||||
|
|||||||
+2
-1
@@ -418,7 +418,8 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -267,8 +267,9 @@ int main(int argc, char *argv[])
|
|||||||
ucix_cleanup(ctx);
|
ucix_cleanup(ctx);
|
||||||
#endif /* defined(BAC_UCI) */
|
#endif /* defined(BAC_UCI) */
|
||||||
BACNET_CHARACTER_STRING DeviceName;
|
BACNET_CHARACTER_STRING DeviceName;
|
||||||
if (Device_Object_Name(Device_Object_Instance_Number(),&DeviceName))
|
if (Device_Object_Name(Device_Object_Instance_Number(),&DeviceName)) {
|
||||||
printf("BACnet Device Name: %s\n", DeviceName.value);
|
printf("BACnet Device Name: %s\n", DeviceName.value);
|
||||||
|
}
|
||||||
|
|
||||||
dlenv_init();
|
dlenv_init();
|
||||||
atexit(datalink_cleanup);
|
atexit(datalink_cleanup);
|
||||||
|
|||||||
+6
-4
@@ -190,15 +190,17 @@ int main(int argc, char *argv[])
|
|||||||
tag = strtol(argv[7], NULL, 0);
|
tag = strtol(argv[7], NULL, 0);
|
||||||
value_string = argv[8];
|
value_string = argv[8];
|
||||||
/* optional priority */
|
/* optional priority */
|
||||||
if (argc > 9)
|
if (argc > 9) {
|
||||||
value_list.priority = strtol(argv[9], NULL, 0);
|
value_list.priority = strtol(argv[9], NULL, 0);
|
||||||
else
|
} else {
|
||||||
value_list.priority = BACNET_NO_PRIORITY;
|
value_list.priority = BACNET_NO_PRIORITY;
|
||||||
|
}
|
||||||
/* optional index */
|
/* optional index */
|
||||||
if (argc > 10)
|
if (argc > 10) {
|
||||||
value_list.propertyArrayIndex = strtol(argv[10], NULL, 0);
|
value_list.propertyArrayIndex = strtol(argv[10], NULL, 0);
|
||||||
else
|
} else {
|
||||||
value_list.propertyArrayIndex = BACNET_ARRAY_ALL;
|
value_list.propertyArrayIndex = BACNET_ARRAY_ALL;
|
||||||
|
}
|
||||||
|
|
||||||
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
|
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
|
||||||
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
|
||||||
|
|||||||
@@ -315,8 +315,9 @@ int main(int argc, char *argv[])
|
|||||||
elapsed_seconds += delta_seconds;
|
elapsed_seconds += delta_seconds;
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -364,7 +365,8 @@ int main(int argc, char *argv[])
|
|||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -241,8 +241,9 @@ int main(int argc, char *argv[])
|
|||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds += (current_seconds - last_seconds);
|
elapsed_seconds += (current_seconds - last_seconds);
|
||||||
if (elapsed_seconds > timeout_seconds) {
|
if (elapsed_seconds > timeout_seconds) {
|
||||||
|
|||||||
@@ -291,8 +291,9 @@ int main(int argc, char *argv[])
|
|||||||
if (pdu_len) {
|
if (pdu_len) {
|
||||||
My_NPDU_Handler(&src, &Rx_Buf[0], pdu_len);
|
My_NPDU_Handler(&src, &Rx_Buf[0], pdu_len);
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* increment timer - exit if timed out */
|
/* increment timer - exit if timed out */
|
||||||
elapsed_seconds = current_seconds - last_seconds;
|
elapsed_seconds = current_seconds - last_seconds;
|
||||||
if (elapsed_seconds) {
|
if (elapsed_seconds) {
|
||||||
|
|||||||
@@ -286,8 +286,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
Target_Object_Property_Priority = (uint8_t)strtol(argv[5], NULL, 0);
|
Target_Object_Property_Priority = (uint8_t)strtol(argv[5], NULL, 0);
|
||||||
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
|
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
|
||||||
if (Target_Object_Property_Index == -1)
|
if (Target_Object_Property_Index == -1) {
|
||||||
Target_Object_Property_Index = BACNET_ARRAY_ALL;
|
Target_Object_Property_Index = BACNET_ARRAY_ALL;
|
||||||
|
}
|
||||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||||
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
|
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
|
||||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE + 1);
|
Target_Device_Object_Instance, BACNET_MAX_INSTANCE + 1);
|
||||||
@@ -386,8 +387,9 @@ int main(int argc, char *argv[])
|
|||||||
tsm_timer_milliseconds(
|
tsm_timer_milliseconds(
|
||||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -431,7 +433,8 @@ int main(int argc, char *argv[])
|
|||||||
/* keep track of time for next check */
|
/* keep track of time for next check */
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,8 +466,9 @@ int main(int argc, char *argv[])
|
|||||||
if (current_seconds != last_seconds) {
|
if (current_seconds != last_seconds) {
|
||||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||||
}
|
}
|
||||||
if (Error_Detected)
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
|
|||||||
+18
-9
@@ -1693,8 +1693,9 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
|||||||
if ((value == NULL) || (test_value == NULL)) {
|
if ((value == NULL) || (test_value == NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (test_value->tag == value->tag)
|
if (test_value->tag == value->tag) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
/* second test for same-ness */
|
/* second test for same-ness */
|
||||||
status = false;
|
status = false;
|
||||||
@@ -1707,52 +1708,60 @@ bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE *value,
|
|||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_BOOLEAN)
|
#if defined(BACAPP_BOOLEAN)
|
||||||
case BACNET_APPLICATION_TAG_BOOLEAN:
|
case BACNET_APPLICATION_TAG_BOOLEAN:
|
||||||
if (test_value->type.Boolean == value->type.Boolean)
|
if (test_value->type.Boolean == value->type.Boolean) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_UNSIGNED)
|
#if defined(BACAPP_UNSIGNED)
|
||||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||||
if (test_value->type.Unsigned_Int == value->type.Unsigned_Int)
|
if (test_value->type.Unsigned_Int == value->type.Unsigned_Int) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_SIGNED)
|
#if defined(BACAPP_SIGNED)
|
||||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||||
if (test_value->type.Signed_Int == value->type.Signed_Int)
|
if (test_value->type.Signed_Int == value->type.Signed_Int) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_REAL)
|
#if defined(BACAPP_REAL)
|
||||||
case BACNET_APPLICATION_TAG_REAL:
|
case BACNET_APPLICATION_TAG_REAL:
|
||||||
if (test_value->type.Real == value->type.Real)
|
if (test_value->type.Real == value->type.Real) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_DOUBLE)
|
#if defined(BACAPP_DOUBLE)
|
||||||
case BACNET_APPLICATION_TAG_DOUBLE:
|
case BACNET_APPLICATION_TAG_DOUBLE:
|
||||||
if (test_value->type.Double == value->type.Double)
|
if (test_value->type.Double == value->type.Double) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_ENUMERATED)
|
#if defined(BACAPP_ENUMERATED)
|
||||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||||
if (test_value->type.Enumerated == value->type.Enumerated)
|
if (test_value->type.Enumerated == value->type.Enumerated) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_DATE)
|
#if defined(BACAPP_DATE)
|
||||||
case BACNET_APPLICATION_TAG_DATE:
|
case BACNET_APPLICATION_TAG_DATE:
|
||||||
if (datetime_compare_date(
|
if (datetime_compare_date(
|
||||||
&test_value->type.Date, &value->type.Date) == 0)
|
&test_value->type.Date, &value->type.Date) == 0) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_TIME)
|
#if defined(BACAPP_TIME)
|
||||||
case BACNET_APPLICATION_TAG_TIME:
|
case BACNET_APPLICATION_TAG_TIME:
|
||||||
if (datetime_compare_time(
|
if (datetime_compare_time(
|
||||||
&test_value->type.Time, &value->type.Time) == 0)
|
&test_value->type.Time, &value->type.Time) == 0) {
|
||||||
status = true;
|
status = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#if defined(BACAPP_OBJECT_ID)
|
#if defined(BACAPP_OBJECT_ID)
|
||||||
|
|||||||
@@ -22,8 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
bool days_is_leap_year(uint16_t year)
|
bool days_is_leap_year(uint16_t year)
|
||||||
{
|
{
|
||||||
if ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0))
|
if ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
@@ -42,10 +43,11 @@ uint8_t days_per_month(uint16_t year, uint8_t month)
|
|||||||
uint8_t month_days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
|
uint8_t month_days[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
|
||||||
31 };
|
31 };
|
||||||
|
|
||||||
if ((month == 2) && days_is_leap_year(year))
|
if ((month == 2) && days_is_leap_year(year)) {
|
||||||
return (29);
|
return (29);
|
||||||
else if (month >= 1 && month <= 12)
|
} else if (month >= 1 && month <= 12) {
|
||||||
return (month_days[month]);
|
return (month_days[month]);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user