From 18c31b363cc0b525bfa632b4551aecd0a91b0446 Mon Sep 17 00:00:00 2001 From: yuliang Date: Wed, 25 Jun 2025 16:02:48 +0800 Subject: [PATCH] =?UTF-8?q?FIX=20|=20=E5=8E=BB=E6=8E=89=E6=97=A0=E6=95=88?= =?UTF-8?q?=E4=BB=A3=E7=A0=81,=20=E5=8E=BB=E6=8E=89=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E4=BF=A1=E6=81=AF.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/include/hwgpio.h | 3 - app/include/pd_dau.h | 2 +- app/lib/a_process/main.c | 96 +------------------------------ app/lib/a_process/pd_dau.c | 8 +-- app/lib/a_process/pd_main.c | 20 ------- app/lib/m_management/better_log.c | 4 +- app/lib/m_management/memory.c | 2 +- app/lib/z_hardware/hwgpio.c | 24 +------- build/Makefile | 13 +++-- build/config.mk | 2 +- 10 files changed, 18 insertions(+), 156 deletions(-) diff --git a/app/include/hwgpio.h b/app/include/hwgpio.h index 97d4db9..9847498 100644 --- a/app/include/hwgpio.h +++ b/app/include/hwgpio.h @@ -57,10 +57,8 @@ typedef struct } gpio_node_t; /* Exported macro ------------------------------------------------------------*/ -#define GPIO_WATCHDOG(_v_) gpio_val_set(gpio_watcdog_idx, _v_) /* Extern global variables ---------------------------------------------------*/ -extern int32_t gpio_watcdog_idx; /* Extern functions ----------------------------------------------------------*/ extern int32_t gpio_val_set(uint16_t gpio, uint8_t value); @@ -68,7 +66,6 @@ extern int32_t gpio_val_get(uint16_t gpio, uint8_t *value); extern int32_t gpio_dir_set(uint16_t gpio, uint8_t dir); extern int32_t gpio_export(uint16_t gpio); extern int32_t gpio_init(void); -extern void feed_dog(void); #endif /************************ (C) COPYRIGHT LandPower ***** END OF FILE ****************/ diff --git a/app/include/pd_dau.h b/app/include/pd_dau.h index 837467c..6950179 100755 --- a/app/include/pd_dau.h +++ b/app/include/pd_dau.h @@ -207,7 +207,7 @@ extern dau_t daus[MAX_SLOTS]; /* Extern functions ----------------------------------------------------------*/ extern int32_t dau_handle_init(void); extern int32_t dau_handle_init_after(void); -extern int _dau_response(int slot, char *buf, int len); +extern void _dau_response(int slot, char *buf, int len); #endif #endif /************************ (C) COPYRIGHT LandPower ***** END OF FILE ****/ diff --git a/app/lib/a_process/main.c b/app/lib/a_process/main.c index 2e46ced..a3746bd 100755 --- a/app/lib/a_process/main.c +++ b/app/lib/a_process/main.c @@ -56,9 +56,7 @@ #include "main.h" #include "hwgpio.h" #include "fifo.h" - #include "pd_main.h" -#include "hwgpio.h" /* Private typedef -----------------------------------------------------------*/ @@ -133,7 +131,7 @@ void reboot_system(int module, REBOOT_MSG type) if (pmsg) { - log_out(module, LOG_LVL_WARN, pmsg); + log_out(module, LOG_LVL_WARN, "%s", pmsg); system("sync"); } @@ -141,75 +139,6 @@ void reboot_system(int module, REBOOT_MSG type) system("reboot -f"); } -//通过RTC-pcf8563系统驱动读写寄存器 - -int32_t rtc_time_set(struct tm tm) -{ - int rtc_fd; - struct tm rtc_tm = tm; - - // 打开 RTC 设备 - rtc_fd = open("/dev/rtc0", O_RDWR); - if (rtc_fd == -1) { - DBG(DBG_M_DBG, "Unable to open RTC device\n"); - return -1; - } - if (ioctl(rtc_fd, RTC_SET_TIME, &rtc_tm) == -1) { - DBG(DBG_M_DBG, "Unable to set RTC time\n"); - close(rtc_fd); - return -1; - } - - DBG(DBG_M_DBG, "RTC time set successfully\n"); - - close(rtc_fd); - return 0; -} - -int32_t rtc_time_get(struct tm tm) -{ - time_t timestamp; - // 定义存储时间的结构体 - struct tm rtc_tm; - memset(&rtc_tm, 0, sizeof(struct rtc_time)); - - //DBG(DBG_M_DBG, "rtc_time_get start!!!!!!!!\r\n"); - int fd = open("/dev/rtc0", O_RDONLY); - if (fd == -1) { - DBG(DBG_M_DBG, "打开设备文件失败 errno: %d\r\n", errno); - char * mesg = strerror(errno); - printf("Mesg:%s\n",mesg); - return -1; - } - // 使用 ioctl 调用 RTC_RD_TIME 命令读取时间 - if (ioctl(fd, RTC_RD_TIME, &rtc_tm) == -1) { - DBG(DBG_M_DBG, "读取时间失败errno: %d\r\n", errno); - char * mesg = strerror(errno); - printf("Mesg:%s\n",mesg); - close(fd); - return -1; - } else { - memcpy(&tm, &rtc_tm, sizeof(rtc_tm)); - // 转换为 Unix 时间戳 - timestamp = mktime(&rtc_tm); - if (timestamp == -1) { - DBG(DBG_M_DBG, "make Unix time failed\n"); - } - - // 输出读取到的时间 - #if 0 - DBG(DBG_M_DBG, "当前时间: %04d-%02d-%02d %02d:%02d:%02d\n", - rtc_tm.tm_year + 1900, rtc_tm.tm_mon + 1, rtc_tm.tm_mday, - rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); - //DBG(DBG_M_DBG, "Unix timestamp: %ld\n", timestamp); - #endif - } - // 关闭设备文件 - close(fd); - - return 0; -} - /* description: 数据处理预初始化. param: return: (E_NONE)成功,(其他)失败 */ @@ -266,10 +195,6 @@ int32_t main(int32_t argc, char **argv) log_open(); log_out(LOG_DEFAULT, LOG_LVL_WARN, "System start!"); -#if 0 - system("/etc/ppp/peers/quectel-ppp-kill"); - sleep(2); -#endif /* 设置信号处理的回调函数 */ act.sa_handler = _signal_handler; @@ -306,19 +231,6 @@ int32_t main(int32_t argc, char **argv) /* 初始化完成 */ version_hex = version_str_to_int(); is_system_init = TRUE; - -#if 1 - struct tm rtc_tm; - // 设置当前时间(设置为2025年2月24日 12:00:00) - rtc_tm.tm_year = 2025 - 1900; // 年份需要减去1900 - rtc_tm.tm_mon = 1; // 2月 - rtc_tm.tm_mday = 24; // 24号 - rtc_tm.tm_wday = 1; //星期一 - rtc_tm.tm_hour = 12; - rtc_tm.tm_min = 5; - rtc_tm.tm_sec = 30; - rtc_time_set(rtc_tm); -#endif /* 主循环, 点灯喂狗. */ for(;;) @@ -326,12 +238,6 @@ int32_t main(int32_t argc, char **argv) sleep(1); start_time++; cnt++; - /* 喂狗. */ - if (0 == (cnt & 0x1F)) - { - feed_dog(); - //rtc_time_get(rtc_tm); - } } return 0; diff --git a/app/lib/a_process/pd_dau.c b/app/lib/a_process/pd_dau.c index ca5fa04..9fe428e 100755 --- a/app/lib/a_process/pd_dau.c +++ b/app/lib/a_process/pd_dau.c @@ -39,7 +39,7 @@ typedef void (*UploadCallback)(int slot, const void *data, size_t len); /* Private function prototypes -----------------------------------------------*/ int _dau_insert(int slot, DauType type); -int _dau_remove(int slot); +void _dau_remove(int slot); extern void _print_sockaddr_in(const struct sockaddr_in *addr); /* Internal functions --------------------------------------------------------*/ @@ -322,7 +322,7 @@ void* _dau_alloc_private_data(DauType type, int slot) memset(data, 0, sizeof(rs485_device_data)); // 根据槽位分配串口设备 - const char *device = (slot == 4) ? "/dev/ttyS0" : "/dev/ttyS1"; + //const char *device = (slot == 4) ? "/dev/ttyS0" : "/dev/ttyS1"; //data->fd = init_rs485(device); data->address = (slot == 4) ? 0x01 : 0x02; @@ -533,7 +533,7 @@ int _dau_insert(int slot, DauType type) return E_NONE; } -int _dau_remove(int slot) +void _dau_remove(int slot) { pthread_mutex_lock(&board_mutex); @@ -556,7 +556,7 @@ int _dau_remove(int slot) printf("Board removed from slot %d\n", slot); } -int _dau_response(int slot, char *buf, int len) +void _dau_response(int slot, char *buf, int len) { printf("_dau_response: slot=%d len=%d\n", slot, len); diff --git a/app/lib/a_process/pd_main.c b/app/lib/a_process/pd_main.c index a6deddf..cd4996e 100755 --- a/app/lib/a_process/pd_main.c +++ b/app/lib/a_process/pd_main.c @@ -73,24 +73,6 @@ cmd_node_t pd_port_node = NULL, }; -/* DAU 端口类型分类. */ -static const char *pd_sen_type_str[PD_SEN_TYPE_COUNT] = -{ - "", - "sig", - "noise", - "sig-noise" -}; - -/* DAU 端口降噪类型分类. */ -static const char *pd_noise_type_str[PD_DENOISE_TYPE_COUNT] = -{ - "none", - "auto", - "manual", - "variance" -}; - /* Private function prototypes -----------------------------------------------*/ extern int32_t _pd_port_str_to_unit_port(const char *port_str, uint8_t *unit, uint8_t *port); @@ -546,8 +528,6 @@ int32_t _pd_main_init_after(void) { struct sockaddr_in addr; thread_param_t param = {0}; - uint8_t i = 0; - uint8_t j = 0; char cmd[256]; /* 初始化基本参数 */ diff --git a/app/lib/m_management/better_log.c b/app/lib/m_management/better_log.c index 4962480..6285173 100755 --- a/app/lib/m_management/better_log.c +++ b/app/lib/m_management/better_log.c @@ -248,7 +248,7 @@ void _log_fifo_out(LOG_MODULE_E module, LOG_LVL_E priority, const char *va_str) log_data->module = module; log_data->lvl = priority; - snprintf(log_data->log_out_str, LOG_STR_LEN, va_str); + snprintf(log_data->log_out_str, LOG_STR_LEN, "%s", va_str); _log_msg_send(LOG_OUT, log_data); } @@ -354,7 +354,7 @@ void log_show(int32_t show_cnt, LOG_LVL_E priority, const char *key_word) { log_data->type = LOG_SHOW_KEYWORD; log_data->param = show_cnt; - snprintf(log_data->log_show_str, LOG_STR_LEN, key_word); + snprintf(log_data->log_show_str, LOG_STR_LEN, "%s", key_word); } else if (show_cnt > 0) // 按数量打印日志 { diff --git a/app/lib/m_management/memory.c b/app/lib/m_management/memory.c index e2c926e..ed2efa2 100644 --- a/app/lib/m_management/memory.c +++ b/app/lib/m_management/memory.c @@ -274,7 +274,7 @@ static const char *_x_mtype_memstr(char *buf, size_t len, uint32_t bytes) /* 打印内存使用情况根据系统调用. */ static int32_t _x_show_memory_mallinfo(vty_t *vty) { - struct mallinfo minfo = mallinfo(); + struct mallinfo2 minfo = mallinfo2(); char buf[MTYPE_MEMSTR_LEN] = {0}; vty_out(vty, "System allocator statistics:%s", VTY_NEWLINE); diff --git a/app/lib/z_hardware/hwgpio.c b/app/lib/z_hardware/hwgpio.c index 8853732..2a3906e 100644 --- a/app/lib/z_hardware/hwgpio.c +++ b/app/lib/z_hardware/hwgpio.c @@ -55,12 +55,10 @@ /* Private variables ---------------------------------------------------------*/ static array_t *gpios = NULL; -int32_t gpio_dog_idx; - /* Private function prototypes -----------------------------------------------*/ /* Internal functions --------------------------------------------------------*/ -int32_t _gpio_name_get(uint8_t gpio, char *name) +static int32_t _gpio_name_get(uint16_t gpio, char *name) { if (!name) { @@ -329,27 +327,7 @@ int32_t gpio_export(uint16_t gpio) int32_t gpio_init(void) { gpios = array_init(ARRAY_MIN_SIZE, MTYPE_GPIO); - gpio_dog_idx = gpio_export(GPIO_WATCHDONG); - if (gpio_dog_idx < 0) - { - DBG(DBG_M_GPIO, "ERROR return %d!\r\n", gpio_dog_idx); - return E_BAD_PARAM; - } - LD_E_RETURN(DBG_M_GPIO, gpio_dir_set(gpio_dog_idx, GPIO_DIR_OUT)); return E_NONE; } - -void feed_dog(void) -{ - static char dog = 1; - dog = (dog == 1)? 0 : 1; - int ret = gpio_val_set(gpio_dog_idx, dog); - if (ret != E_NONE) { - DBG(DBG_M_DBG, "Failed to feed dog, error %d\r\n", ret); - } else { - //DBG(DBG_M_DBG, "feed_dog %d\r\n", dog); - } -} - /************************ (C) COPYRIGHT LandPower ***** END OF FILE ****************/ diff --git a/build/Makefile b/build/Makefile index c542cf6..211e79a 100755 --- a/build/Makefile +++ b/build/Makefile @@ -15,7 +15,7 @@ define make-library $1: $(call source-to-object,$2) $(QUIET)$(AR) $(ARFLAGS) $$@ $$^ $(ENULL) - @echo -e "$$(INFO_C)AR $$@ done";echo + @echo "$$(INFO_C)AR $$@ done";echo endef # 产生依赖文件. @@ -49,18 +49,19 @@ ifeq ($(DEFARCH), PC) CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar CFLAGS = -g -Wall -funwind-tables -rdynamic -DHAVE_CONFIG_H + LDLIB := -lreadline -lncurses -pthread -lrt -lsqlite3 -lm -lssh -lssl -lcrypto -lz else ifeq ($(DEFARCH), MYiR) CROSS_COMPILE = aarch64-buildroot-linux-gnu- CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar CFLAGS += -g -Wall -funwind-tables -rdynamic -DHAVE_CONFIG_H + LDLIB := -L./libother -lreadline -lncurses -pthread -lrt -lsqlite3 -lm -lssh -lssl -lcrypto -lz endif -#LDLIB := -L./libother -lreadline -lncurses -pthread -lrt -lsqlite3 -lm -lssl -lcrypto -lz -LDLIB := -L./libother -lreadline -lncurses -pthread -lrt -lsqlite3 -lm -lssh -lssl -lcrypto -lz + # 这里如果是‘@’则隐藏具体的编译命令 -#QUIET := @ +QUIET := @ ENULL := > /dev/null INFO_C := "\\033[31mInfo\\033[0m " ERROR_C := "\\033[31mInfo\\033[0m " @@ -115,12 +116,12 @@ $(VERSION_LIB): $(CONFIG_FILE) $(libraries) version.c @echo "COMPILE version.o" $(QUIET)$(COMPILE.c) -o version.o version.c $(QUIET)$(AR) $(ARFLAGS) $(VERSION_LIB) version.o $(ENULL) - @echo -e "$(INFO_C)AR $@ done";echo + @echo "$(INFO_C)AR $@ done";echo PDMonitor: $(CONFIG_FILE) $(libraries) $(VERSION_LIB) # 使用两次$(libraries)避免库文件之间的交叉引用问题. $(QUIET)$(LINK.o) -rdynamic $(libraries) $(libraries) $(VERSION_LIB) $(LDLIB) -o $@ - @echo -e "$(INFO_C)LINK $@ done";echo + @echo "$(INFO_C)LINK $@ done";echo # $(QUIET)cp $@ //home//embed//LandPower// .PHONY: libraries diff --git a/build/config.mk b/build/config.mk index b99b9b4..aaa7eb0 100644 --- a/build/config.mk +++ b/build/config.mk @@ -35,6 +35,6 @@ endif @echo "" >> $(CONFIG_FILE) @echo "#endif" >> $(CONFIG_FILE) @echo "/* WARNING: Don't modify this file anywhere!!! */" >> $(CONFIG_FILE) - @echo -e "$(INFO_C)Create $@ done";echo + @echo "$(INFO_C)Create $@ done";echo $(VERSION_FILE): $(PRODUCT).cfg \ No newline at end of file