Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
+57
-40
@@ -59,14 +59,16 @@ BACNET_SUBSCRIBE_COV_DATA *COV_Subscribe_Data = NULL;
|
||||
static bool Simple_Ack_Detected = false;
|
||||
static bool Cancel_Requested = false;
|
||||
|
||||
static void MyErrorHandler(BACNET_ADDRESS *src,
|
||||
static void MyErrorHandler(
|
||||
BACNET_ADDRESS *src,
|
||||
uint8_t invoke_id,
|
||||
BACNET_ERROR_CLASS error_class,
|
||||
BACNET_ERROR_CODE error_code)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Error: %s: %s\n",
|
||||
printf(
|
||||
"BACnet Error: %s: %s\n",
|
||||
bactext_error_class_name((int)error_class),
|
||||
bactext_error_code_name((int)error_code));
|
||||
Error_Detected = true;
|
||||
@@ -79,18 +81,19 @@ static void MyAbortHandler(
|
||||
(void)server;
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Abort: %s\n",
|
||||
bactext_abort_reason_name((int)abort_reason));
|
||||
printf(
|
||||
"BACnet Abort: %s\n", bactext_abort_reason_name((int)abort_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void MyRejectHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
|
||||
static void
|
||||
MyRejectHandler(BACNET_ADDRESS *src, uint8_t invoke_id, uint8_t reject_reason)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
printf("BACnet Reject: %s\n",
|
||||
printf(
|
||||
"BACnet Reject: %s\n",
|
||||
bactext_reject_reason_name((int)reject_reason));
|
||||
Error_Detected = true;
|
||||
}
|
||||
@@ -102,7 +105,8 @@ static void My_Unconfirmed_COV_Notification_Handler(
|
||||
handler_ucov_notification(service_request, service_len, src);
|
||||
}
|
||||
|
||||
static void My_Confirmed_COV_Notification_Handler(uint8_t *service_request,
|
||||
static void My_Confirmed_COV_Notification_Handler(
|
||||
uint8_t *service_request,
|
||||
uint16_t service_len,
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_CONFIRMED_SERVICE_DATA *service_data)
|
||||
@@ -110,8 +114,8 @@ static void My_Confirmed_COV_Notification_Handler(uint8_t *service_request,
|
||||
handler_ccov_notification(service_request, service_len, src, service_data);
|
||||
}
|
||||
|
||||
static void MyWritePropertySimpleAckHandler(
|
||||
BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
static void
|
||||
MyWritePropertySimpleAckHandler(BACNET_ADDRESS *src, uint8_t invoke_id)
|
||||
{
|
||||
if (address_match(&Target_Address, src) &&
|
||||
(invoke_id == Request_Invoke_ID)) {
|
||||
@@ -135,9 +139,11 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
|
||||
/* handle the data coming back from COV subscriptions */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_COV_NOTIFICATION,
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_COV_NOTIFICATION,
|
||||
My_Confirmed_COV_Notification_Handler);
|
||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_COV_NOTIFICATION,
|
||||
apdu_set_unconfirmed_handler(
|
||||
SERVICE_UNCONFIRMED_COV_NOTIFICATION,
|
||||
My_Unconfirmed_COV_Notification_Handler);
|
||||
/* handle the Simple ack coming back from SubscribeCOV */
|
||||
apdu_set_confirmed_simple_ack_handler(
|
||||
@@ -163,55 +169,62 @@ static void cleanup(void)
|
||||
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-id object-type object-instance "
|
||||
"process-id <[un]confirmed lifetime|cancel>\n",
|
||||
printf(
|
||||
"Usage: %s device-id object-type object-instance "
|
||||
"process-id <[un]confirmed lifetime|cancel>\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Subscribe to a BACnet object for Change-of-Value notifications\n"
|
||||
"in a BACnet device and print the Change-of-Value notifications.\n");
|
||||
"in a BACnet device and print the Change-of-Value notifications.\n");
|
||||
printf("\n");
|
||||
printf("device-id:\n"
|
||||
"The subscriber BACnet Device Object Instance number.\n");
|
||||
"The subscriber BACnet Device Object Instance number.\n");
|
||||
printf("\n");
|
||||
printf("object-type:\n"
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
"The object type is object that you are reading. It\n"
|
||||
"can be defined either as the object-type name string\n"
|
||||
"as defined in the BACnet specification, or as the\n"
|
||||
"integer value of the enumeration BACNET_OBJECT_TYPE\n"
|
||||
"in bacenum.h. For example if you were reading Analog\n"
|
||||
"Output 2, the object-type would be analog-output or 1.\n");
|
||||
printf("\n");
|
||||
printf("object-instance:\n"
|
||||
"The monitored object instance number.\n");
|
||||
"The monitored object instance number.\n");
|
||||
printf("\n");
|
||||
printf("process-id:\n"
|
||||
"Process Identifier for this COV subscription.\n");
|
||||
"Process Identifier for this COV subscription.\n");
|
||||
printf("\n");
|
||||
printf("confirmed:\n"
|
||||
"Optional flag to subscribe using Confirmed notifications.\n"
|
||||
"Use the word \'confirmed\' or \'unconfirmed\'.\n");
|
||||
"Optional flag to subscribe using Confirmed notifications.\n"
|
||||
"Use the word \'confirmed\' or \'unconfirmed\'.\n");
|
||||
printf("\n");
|
||||
printf("lifetime:\n"
|
||||
"Optional subscription lifetime is conveyed in seconds.\n");
|
||||
"Optional subscription lifetime is conveyed in seconds.\n");
|
||||
printf("\n");
|
||||
printf("cancel:\n"
|
||||
"Use the word \'cancel\' instead of confirm and lifetime.\n"
|
||||
"This shall indicate a cancellation request.\n");
|
||||
"Use the word \'cancel\' instead of confirm and lifetime.\n"
|
||||
"This shall indicate a cancellation request.\n");
|
||||
printf("\n");
|
||||
printf("Examples:\n");
|
||||
printf("If you want subscribe to Device 123 Analog Input 9 object\n"
|
||||
printf(
|
||||
"If you want subscribe to Device 123 Analog Input 9 object\n"
|
||||
"using confirmed COV notifications for 5 minutes,\n"
|
||||
"you could send the following command:\n"
|
||||
"%s 123 0 9 1 confirmed 600\n", filename);
|
||||
printf("To send the same COV subscription request for unconfirmed\n"
|
||||
"%s 123 0 9 1 confirmed 600\n",
|
||||
filename);
|
||||
printf(
|
||||
"To send the same COV subscription request for unconfirmed\n"
|
||||
"notifications, send the following command:\n"
|
||||
"%s 123 0 9 1 unconfirmed 600\n", filename);
|
||||
printf("To cancel the same COV subscription request,\n"
|
||||
"%s 123 0 9 1 unconfirmed 600\n",
|
||||
filename);
|
||||
printf(
|
||||
"To cancel the same COV subscription request,\n"
|
||||
"send the following command:\n"
|
||||
"%s 123 0 9 1 cancel\n", filename);
|
||||
"%s 123 0 9 1 cancel\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -255,7 +268,8 @@ int main(int argc, char *argv[])
|
||||
/* decode the command line parameters */
|
||||
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "device-instance=%u - not greater than %u\n",
|
||||
fprintf(
|
||||
stderr, "device-instance=%u - not greater than %u\n",
|
||||
Target_Device_Object_Instance, BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
}
|
||||
@@ -271,7 +285,8 @@ int main(int argc, char *argv[])
|
||||
cov_data->monitoredObjectIdentifier.type = (uint16_t)uint;
|
||||
if (cov_data->monitoredObjectIdentifier.type >=
|
||||
MAX_BACNET_OBJECT_TYPE) {
|
||||
fprintf(stderr, "object-type=%u - it must be less than %u\n",
|
||||
fprintf(
|
||||
stderr, "object-type=%u - it must be less than %u\n",
|
||||
cov_data->monitoredObjectIdentifier.type,
|
||||
MAX_BACNET_OBJECT_TYPE);
|
||||
return 1;
|
||||
@@ -281,7 +296,8 @@ int main(int argc, char *argv[])
|
||||
strtol(argv[argi], NULL, 0);
|
||||
if (cov_data->monitoredObjectIdentifier.instance >
|
||||
BACNET_MAX_INSTANCE) {
|
||||
fprintf(stderr, "object-instance=%u - not greater than %u\n",
|
||||
fprintf(
|
||||
stderr, "object-instance=%u - not greater than %u\n",
|
||||
cov_data->monitoredObjectIdentifier.instance,
|
||||
BACNET_MAX_INSTANCE);
|
||||
return 1;
|
||||
@@ -376,8 +392,9 @@ int main(int argc, char *argv[])
|
||||
/* increase the timeout to the longest lifetime */
|
||||
timeout_seconds = cov_data->lifetime;
|
||||
}
|
||||
printf("Sent SubscribeCOV request. "
|
||||
" Waiting up to %u seconds....\n",
|
||||
printf(
|
||||
"Sent SubscribeCOV request. "
|
||||
" Waiting up to %u seconds....\n",
|
||||
(unsigned)(timeout_seconds - elapsed_seconds));
|
||||
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||
if (cov_data->next) {
|
||||
|
||||
Reference in New Issue
Block a user