Change prints to debug (#1168)

This commit is contained in:
Ryan Mulder
2025-12-03 11:59:30 -05:00
committed by GitHub
parent b1c9d013ef
commit 0fd814867d
10 changed files with 59 additions and 60 deletions
+15 -15
View File
@@ -67,7 +67,7 @@ static void debug_print_ipv4(
const unsigned int count)
{
if (BIP_Debug) {
fprintf(
debug_fprintf(
stderr, "BIP: %s %s:%hu (%u bytes)\n", str, inet_ntoa(*addr),
ntohs(port), count);
fflush(stderr);
@@ -301,7 +301,7 @@ int bip_send_mpdu(
/* assumes that the driver has already been initialized */
if (BIP_Socket < 0) {
if (BIP_Debug) {
fprintf(stderr, "BIP: driver not initialized!\n");
debug_fprintf(stderr, "BIP: driver not initialized!\n");
fflush(stderr);
}
return BIP_Socket;
@@ -423,7 +423,7 @@ uint16_t bip_receive(
}
} else {
if (BIP_Debug) {
fprintf(stderr, "BIP: NPDU dropped!\n");
debug_fprintf(stderr, "BIP: NPDU dropped!\n");
fflush(stderr);
}
npdu_len = 0;
@@ -613,20 +613,20 @@ static void printRoute(struct route_info *rtInfo)
{
if (BIP_Debug) {
/* Print Destination address */
fprintf(
debug_fprintf(
stderr, "%s\t",
rtInfo->dstAddr ? ntoa(rtInfo->dstAddr) : "0.0.0.0 ");
/* Print Gateway address */
fprintf(
debug_fprintf(
stderr, "%s\t",
rtInfo->gateWay ? ntoa(rtInfo->gateWay) : "*.*.*.*");
/* Print Interface Name */
fprintf(stderr, "%s\t", rtInfo->ifName);
debug_fprintf(stderr, "%s\t", rtInfo->ifName);
/* Print Source address */
fprintf(
debug_fprintf(
stderr, "%s\n",
rtInfo->srcAddr ? ntoa(rtInfo->srcAddr) : "*.*.*.*");
}
@@ -707,19 +707,19 @@ static char *ifname_default(void)
/* Send the request */
if (send(sock, nlMsg, nlMsg->nlmsg_len, 0) < 0) {
fprintf(stderr, "BIP: Write To Socket Failed...\n");
debug_fprintf(stderr, "BIP: Write To Socket Failed...\n");
return BIP_Interface_Name;
}
/* Read the response */
if ((len = readNlSock(sock, msgBuf, sizeof(msgBuf), msgSeq, getpid())) <
0) {
fprintf(stderr, "BIP: Read From Socket Failed...\n");
debug_fprintf(stderr, "BIP: Read From Socket Failed...\n");
return BIP_Interface_Name;
}
/* Parse and print the response */
rtInfo = (struct route_info *)malloc(sizeof(struct route_info));
if (BIP_Debug) {
fprintf(stderr, "Destination\tGateway\tInterface\tSource\n");
debug_fprintf(stderr, "Destination\tGateway\tInterface\tSource\n");
}
for (; NLMSG_OK(nlMsg, len); nlMsg = NLMSG_NEXT(nlMsg, len)) {
memset(rtInfo, 0, sizeof(struct route_info));
@@ -790,8 +790,8 @@ void bip_set_interface(const char *ifname)
}
BIP_Address.s_addr = local_address.s_addr;
if (BIP_Debug) {
fprintf(stderr, "BIP: Interface: %s\n", ifname);
fprintf(stderr, "BIP: Address: %s\n", inet_ntoa(local_address));
debug_fprintf(stderr, "BIP: Interface: %s\n", ifname);
debug_fprintf(stderr, "BIP: Address: %s\n", inet_ntoa(local_address));
fflush(stderr);
}
/* cache interface netmask */
@@ -833,10 +833,10 @@ void bip_set_interface(const char *ifname)
}
#endif
if (BIP_Debug) {
fprintf(
debug_fprintf(
stderr, "BIP: Broadcast Address: %s\n",
inet_ntoa(BIP_Broadcast_Addr));
fprintf(
debug_fprintf(
stderr, "BIP: UDP Port: 0x%04X [%hu]\n", ntohs(BIP_Port),
ntohs(BIP_Port));
fflush(stderr);
@@ -926,7 +926,7 @@ bool bip_init(char *ifname)
bip_set_interface(ifname_default());
}
if (BIP_Address.s_addr == 0) {
fprintf(
debug_fprintf(
stderr, "BIP: Failed to get an IP address from %s!\n",
BIP_Interface_Name);
fflush(stderr);
+1 -1
View File
@@ -17,7 +17,7 @@
#undef DEBUG_PRINTF
#if DEBUG_BSC_EVENT
#define DEBUG_PRINTF printf
#define DEBUG_PRINTF debug_printf
#else
#undef DEBUG_ENABLED
#define DEBUG_PRINTF debug_printf_disabled
+2 -1
View File
@@ -15,6 +15,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#include "bacnet/basic/sys/debug.h"
#include "bacport.h"
#include "bacnet/datetime.h"
@@ -61,7 +62,7 @@ void datetime_timesync(BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
Time_Offset = time_difference(tv_inp, tv_sys);
}
#if PRINT_ENABLED
printf("Time offset = %d\n", Time_Offset);
debug_printf("Time offset = %d\n", Time_Offset);
#endif
}
return;
+7 -7
View File
@@ -982,26 +982,26 @@ bool dlmstp_init(char *ifname)
MSTP_Port.BaudRateSet = dlmstp_set_baud_rate;
MSTP_Init(&MSTP_Port);
#if PRINT_ENABLED
fprintf(stderr, "MS/TP MAC: %02X\n", MSTP_Port.This_Station);
fprintf(stderr, "MS/TP Max_Master: %02X\n", MSTP_Port.Nmax_master);
fprintf(
debug_fprintf(stderr, "MS/TP MAC: %02X\n", MSTP_Port.This_Station);
debug_fprintf(stderr, "MS/TP Max_Master: %02X\n", MSTP_Port.Nmax_master);
debug_fprintf(
stderr, "MS/TP Max_Info_Frames: %u\n",
(unsigned)MSTP_Port.Nmax_info_frames);
fprintf(
debug_fprintf(
stderr, "MS/TP RxBuf[%u] TxBuf[%u]\n",
(unsigned)MSTP_Port.InputBufferSize,
(unsigned)MSTP_Port.OutputBufferSize);
fprintf(
debug_fprintf(
stderr,
"MS/TP SlaveModeEnabled"
": %s\n",
(MSTP_Port.SlaveNodeEnabled ? "true" : "false"));
fprintf(
debug_fprintf(
stderr,
"MS/TP ZeroConfigEnabled"
": %s\n",
(MSTP_Port.ZeroConfigEnabled ? "true" : "false"));
fprintf(
debug_fprintf(
stderr,
"MS/TP CheckAutoBaud"
": %s\n",
+3 -2
View File
@@ -35,6 +35,7 @@
#include "bacnet/datalink/mstp.h"
#include "rs485.h"
#include "bacnet/basic/sys/fifo.h"
#include "bacnet/basic/sys/debug.h"
#include <sys/select.h>
#include <sys/time.h>
@@ -156,7 +157,7 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
termios2_tcsetattr(RS485_Handle, TCSAFLUSH, &newtio);
#if PRINT_ENABLED
fprintf(stdout, "RS485 Baud Rate %u\n", RS485_Baud);
debug_fprintf(stdout, "RS485 Baud Rate %u\n", RS485_Baud);
fflush(stdout);
#endif
}
@@ -296,7 +297,7 @@ void RS485_Cleanup(void)
void RS485_Initialize(void)
{
#if PRINT_ENABLED
fprintf(stdout, "RS485 Interface: %s\n", RS485_Port_Name);
debug_printf("RS485 Interface: %s\n", RS485_Port_Name);
#endif
/*
Open device for reading and writing.
+9 -9
View File
@@ -51,13 +51,13 @@ static volatile int websocket_dispatch_mutex_cnt = 0;
void bsc_websocket_global_lock_dbg(char *f, int line)
{
printf(
debug_printf(
"bsc_websocket_global_lock_dbg() >>> %s:%d lock_cnt %d tid = %ld\n", f,
line, websocket_mutex_cnt, pthread_self());
websocket_mutex_cnt++;
fflush(stdout);
pthread_mutex_lock(&websocket_mutex);
printf(
debug_printf(
"bsc_websocket_global_lock_dbg() <<< lock_cnt %d tid = %ld\n",
websocket_mutex_cnt, pthread_self());
fflush(stdout);
@@ -65,13 +65,13 @@ void bsc_websocket_global_lock_dbg(char *f, int line)
void bsc_websocket_global_unlock_dbg(char *f, int line)
{
printf(
debug_printf(
"bsc_websocket_global_unlock_dbg() >>> %s:%d lock_cnt %d tid = %ld\n",
f, line, websocket_mutex_cnt, pthread_self());
websocket_mutex_cnt--;
fflush(stdout);
pthread_mutex_unlock(&websocket_mutex);
printf(
debug_printf(
"bsc_websocket_global_unlock_dbg() <<< lock_cnt %d tid = %ld\n",
websocket_mutex_cnt, pthread_self());
fflush(stdout);
@@ -79,13 +79,13 @@ void bsc_websocket_global_unlock_dbg(char *f, int line)
void bws_dispatch_lock_dbg(char *f, int line)
{
printf(
debug_printf(
"bws_dispatch_lock_dbg() >>> %s:%d lock_cnt %d tid = %ld\n", f, line,
websocket_dispatch_mutex_cnt, pthread_self());
websocket_dispatch_mutex_cnt++;
fflush(stdout);
pthread_mutex_lock(&websocket_dispatch_mutex);
printf(
debug_printf(
"bws_dispatch_lock_dbg() <<< lock_cnt %d tid = %ld\n",
websocket_dispatch_mutex_cnt, pthread_self());
fflush(stdout);
@@ -93,13 +93,13 @@ void bws_dispatch_lock_dbg(char *f, int line)
void bws_dispatch_unlock_dbg(char *f, int line)
{
printf(
debug_printf(
"bws_dispatch_unlock_dbg() >>> %s:%d lock_cnt %d tid = %ld\n", f, line,
websocket_dispatch_mutex_cnt, pthread_self());
websocket_dispatch_mutex_cnt--;
fflush(stdout);
pthread_mutex_unlock(&websocket_dispatch_mutex);
printf(
debug_printf(
"bws_dispatch_unlock_dbg() <<< lock_cnt %d tid = %ld\n",
websocket_dispatch_mutex_cnt, pthread_self());
fflush(stdout);
@@ -115,7 +115,7 @@ void bsc_websocket_init_log(void)
if (!bsc_websocket_log_initialized) {
bsc_websocket_log_initialized = true;
#if DEBUG_LIBWEBSOCKETS_ENABLED == 1
printf("LWS_MAX_SMP = %d", LWS_MAX_SMP);
debug_printf("LWS_MAX_SMP = %d", LWS_MAX_SMP);
lws_set_log_level(
LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_INFO | LLL_DEBUG |
LLL_PARSER | LLL_HEADER | LLL_EXT | LLL_CLIENT | LLL_LATENCY |