Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stargieg committed Oct 27, 2024
1 parent 608295e commit 2f3feb8
Show file tree
Hide file tree
Showing 130 changed files with 49,868 additions and 9,254 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ option(
BACDL_BSC
"compile with secure-connect support"
OFF)

if(NOT (BACDL_ETHERNET OR
BACDL_MSTP OR
BACDL_ARCNET OR
Expand Down Expand Up @@ -1080,6 +1080,12 @@ if(BACDL_BSC)
endif()
endif()

add_subdirectory(test/bacnet/datalink/bsc-datalink)
add_subdirectory(test/bacnet/datalink/bsc-node)
add_subdirectory(test/bacnet/datalink/bsc-socket)
add_subdirectory(test/bacnet/datalink/bvlc-sc)
add_subdirectory(test/bacnet/datalink/hub-sc)
add_subdirectory(test/bacnet/datalink/websockets)
#
# install
#
Expand Down
45 changes: 28 additions & 17 deletions apps/sc-hub/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,30 @@ static void print_usage(const char *filename)

static void print_help(const char *filename)
{
printf("Simulate a BACnet/SC HUB device\n"
printf(
"Simulate a BACnet/SC HUB device\n"
"device-instance: BACnet Device Object Instance number that you are\n"
"trying simulate.\n"
"device-name: The Device name in ASCII for this device.\n"
"\n");
printf("Other parameters are passing over environment variables:\n"
"- BACNET_SC_ISSUER_1_CERTIFICATE_FILE: Filename of CA certificate\n"
"- BACNET_SC_OPERATIONAL_CERTIFICATE_FILE: Filename of device certificate\n"
"- BACNET_SC_OPERATIONAL_CERTIFICATE_PRIVATE_KEY_FILE: Filename of device certificate key\n"
"- BACNET_SC_HUB_FUNCTION_BINDING: Local port or pair \"interface name:port number\"\n"
"For additional information see file bin/bsc-server.sh\n");
printf("\nExample:\n"
"- BACNET_SC_ISSUER_1_CERTIFICATE_FILE: Filename of CA certificate\n"
"- BACNET_SC_OPERATIONAL_CERTIFICATE_FILE: Filename of device "
"certificate\n"
"- BACNET_SC_OPERATIONAL_CERTIFICATE_PRIVATE_KEY_FILE: Filename of "
"device certificate key\n"
"- BACNET_SC_HUB_FUNCTION_BINDING: Local port or pair \"interface "
"name:port number\"\n"
"For additional information see file bin/bsc-server.sh\n");
printf(
"\nExample:\n"
"To simulate Device 111, use following command:\n"
"%s 111\n", filename);
printf("To simulate Device 111 named NoFred, use following command:\n"
"%s 111 NoFred\n", filename);
"%s 111\n",
filename);
printf(
"To simulate Device 111 named NoFred, use following command:\n"
"%s 111 NoFred\n",
filename);
}

/** Main function of server demo.
Expand Down Expand Up @@ -157,8 +165,9 @@ int main(int argc, char *argv[])

#if defined(BAC_UCI)
ctx = ucix_init("bacnet_dev");
if (!ctx)
if (!ctx) {
fprintf(stderr, "Failed to load config file bacnet_dev\n");
}
uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0);
if (uciId != 0) {
Device_Set_Object_Instance_Number(uciId);
Expand All @@ -174,10 +183,11 @@ int main(int argc, char *argv[])
ucix_cleanup(ctx);
#endif /* defined(BAC_UCI) */

printf("BACnet SC Hub Demo\n"
"BACnet Stack Version %s\n"
"BACnet Device ID: %u\n"
"Max APDU: %d\n",
printf(
"BACnet SC Hub Demo\n"
"BACnet Stack Version %s\n"
"BACnet Device ID: %u\n"
"Max APDU: %d\n",
BACnet_Version, Device_Object_Instance_Number(), MAX_APDU);
/* load any static address bindings to show up
in our device bindings list */
Expand All @@ -186,8 +196,9 @@ int main(int argc, char *argv[])
#if defined(BAC_UCI)
const char *uciname;
ctx = ucix_init("bacnet_dev");
if (!ctx)
if (!ctx) {
fprintf(stderr, "Failed to load config file bacnet_dev\n");
}
uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name");
if (uciname != 0) {
Device_Object_Name_ANSI_Init(uciname);
Expand All @@ -200,7 +211,7 @@ int main(int argc, char *argv[])
}
ucix_cleanup(ctx);
#endif /* defined(BAC_UCI) */
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);
}
dlenv_init();
Expand Down
1 change: 0 additions & 1 deletion ports/bsd/websocket-global.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,3 @@ void bsc_websocket_init_log(void)
}
bsc_websocket_global_unlock();
}

4 changes: 2 additions & 2 deletions ports/bsd/websocket-global.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file
* @file
* @brief Global websocket functions
* @author Kirill Neznamov
* @date May 2022
* @section LICENSE
*
* Copyright (C) 2022 Legrand North America, LLC
* Copyright (C) 2022 Legrand North America, LLC
* as an unpublished work.
*
* SPDX-License-Identifier: MIT
Expand Down
26 changes: 12 additions & 14 deletions ports/linux/bsc-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ void bsc_event_wait(BSC_EVENT *ev)
if (!ev->counter) {
ev->v = false;
DEBUG_PRINTF("bsc_event_wait() reset ev\n");
}
else {
DEBUG_PRINTF("bsc_event_wait() wake up other waiting threads\n");
pthread_cond_broadcast(&ev->cond);
} else {
DEBUG_PRINTF("bsc_event_wait() wake up other waiting threads\n");
pthread_cond_broadcast(&ev->cond);
}
DEBUG_PRINTF("bsc_event_wait() <<< ev = %p\n", ev);
pthread_mutex_unlock(&ev->mutex);
Expand All @@ -120,8 +119,9 @@ bool bsc_event_timedwait(BSC_EVENT *ev, unsigned int ms_timeout)
to.tv_sec += to.tv_nsec / 1000000000;
to.tv_nsec %= 1000000000;

DEBUG_PRINTF("bsc_event_timedwait() >>> before lock ev = %p ev->v = %d\n",
ev, ev->v);
DEBUG_PRINTF(
"bsc_event_timedwait() >>> before lock ev = %p ev->v = %d\n", ev,
ev->v);

pthread_mutex_lock(&ev->mutex);

Expand All @@ -138,8 +138,8 @@ bool bsc_event_timedwait(BSC_EVENT *ev, unsigned int ms_timeout)
}
}

if(ev->v) {
if(r!=0) {
if (ev->v) {
if (r != 0) {
DEBUG_PRINTF("Fired!!! r = %d\n", r);
}
r = 0;
Expand All @@ -149,13 +149,11 @@ bool bsc_event_timedwait(BSC_EVENT *ev, unsigned int ms_timeout)
DEBUG_PRINTF("bsc_event_timedwait() counter %zu\n", ev->counter);

if (!ev->counter) {
DEBUG_PRINTF(
"bsc_event_timedwait() event is reset, err = %d\n", r);
DEBUG_PRINTF("bsc_event_timedwait() event is reset, err = %d\n", r);
ev->v = false;
}
else {
DEBUG_PRINTF("bsc_event_timedwait() wake up other waiting threads\n");
pthread_cond_broadcast(&ev->cond);
} else {
DEBUG_PRINTF("bsc_event_timedwait() wake up other waiting threads\n");
pthread_cond_broadcast(&ev->cond);
}

DEBUG_PRINTF(
Expand Down
Loading

0 comments on commit 2f3feb8

Please sign in to comment.