From a603926c44eb93024faf71ae05d1cb7ec96e4916 Mon Sep 17 00:00:00 2001 From: zsx <1543588107@qq.com> Date: Fri, 28 Feb 2025 01:06:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89LOG=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0=20zsxfly20250228?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom/control_out/src/control_out.c | 8 ++-- custom/custom_main/src/custom_main.c | 52 +++++++++++++++----------- custom/jt808/inc/jt808_config.h | 4 +- custom/jt808/src/jt808_msg_parse.c | 4 +- custom/jt808/src/jt808_msg_pkg.c | 4 +- custom/jt808/src/jt808_set_TermParam.c | 19 +++++----- custom/local_tts/src/local_tts.c | 8 ++-- 7 files changed, 56 insertions(+), 43 deletions(-) diff --git a/custom/control_out/src/control_out.c b/custom/control_out/src/control_out.c index 8f65cd0..a68e644 100644 --- a/custom/control_out/src/control_out.c +++ b/custom/control_out/src/control_out.c @@ -7,13 +7,13 @@ #include "local_tts.h" #include "control_out.h" -#define ADC_DAC_DEBUG_ENABLE 1 +#define ADC_DAC_DEBUG_ENABLE 0 #if ADC_DAC_DEBUG_ENABLE #include "app_uart.h" #define DEBUG(fmt, args...) app_printf("[CONTROL_OUT]" fmt, ##args) #else -#define DEBUG(fmt, arg...) +#define DEBUG(fmt, ...) #endif #define PWM0_IOMUX CM_IOMUX_PIN_74, CM_IOMUX_FUNC_FUNCTION1 @@ -157,7 +157,7 @@ void control_out_task(void *argument){ temp_bat_voltage += get_voltage(ADC_power) / 100; Voltage_update_count++; - if(Voltage_update_count >= (1000/_out_UPDETE_TIME)){//1s + if(Voltage_update_count >= (1000/_out_UPDETE_TIME)){ // 1s BAT_Message.Bat_Voltage = temp_bat_voltage / Voltage_update_count; Voltage_update_count=0; temp_bat_voltage = 0; @@ -168,7 +168,7 @@ void control_out_task(void *argument){ BAT_Message.Deep_ACC_Time++; } Voltage_lag_count++; - if(Voltage_lag_count >= (2000/_out_UPDETE_TIME)){//2s + if(Voltage_lag_count >= (2000/_out_UPDETE_TIME)){ // 2s Voltage_lag_count=0; BAT_Message.Bat_Percent = pmu_voltage_to_percent(BAT_Message.Bat_Voltage); } diff --git a/custom/custom_main/src/custom_main.c b/custom/custom_main/src/custom_main.c index 1d96644..179bd63 100644 --- a/custom/custom_main/src/custom_main.c +++ b/custom/custom_main/src/custom_main.c @@ -26,25 +26,33 @@ #include "local_tts.h" +#if 0 +#include "app_uart.h" +#define DEBUG(fmt, args...) app_printf("[main]" fmt, ##args) +#else +#include "app_uart.h" +#define DEBUG(fmt, ...) +#endif + osThreadId_t OC_APP_TaskHandle; void print_network_info(void){ cm_cereg_state_t cereg_state = {0}; if(0 == cm_modem_get_cpin()){ - app_printf("sim card ready!\r\n"); + DEBUG("sim card ready!\r\n"); }else{ - app_printf("sim card not ready!\r\n"); + DEBUG("sim card not ready!\r\n"); } if(0 ==cm_modem_get_cereg_state(&cereg_state)){ // 获取PS网络注册状态 - app_printf("cereg_state:%d\n",cereg_state.state); // 注册状态 + DEBUG("cereg_state:%d\n",cereg_state.state); // 注册状态 }else{ - app_printf("cereg_get_state fail!\n"); + DEBUG("cereg_get_state fail!\n"); } if(cm_modem_get_pdp_state(1) == 1){ //网络就绪 - app_printf("network ready\n"); + DEBUG("network ready\n"); }else{ - app_printf("waiting for network...\n"); + DEBUG("waiting for network...\n"); } } @@ -52,7 +60,7 @@ osEventFlagsId_t LED_EventFlags = NULL; void led_set_event(led_event_t event){ // 支持多线程并发调用 if(NULL == LED_EventFlags){ - app_printf("LED_EventFlags is NULL\n"); + DEBUG("LED_EventFlags is NULL\n"); return; } osEventFlagsSet(LED_EventFlags, event); @@ -65,18 +73,18 @@ void led_task(char *param){ while(1){ led_event = osEventFlagsWait(LED_EventFlags, 0x0000000f, osFlagsWaitAny, 0); //0等待 if (led_event & 0x80000000) { // 错误处理 - // app_printf("led task error\n"); + // DEBUG("led task error\n"); }else if(led_event & EVENT_NETWORK_READY){ // 网络就绪 - app_printf("led network ready\n"); + DEBUG("led network ready\n"); led_status.network_ready = 1; }else if(led_event & EVENT_NETWORK_DISCONNECT){ // 网络断开 - app_printf("led network disconnect\n"); + DEBUG("led network disconnect\n"); led_status.network_ready = 0; }else if(led_event & EVENT_GPS_LOCATE_SUCCESS){ // GPS定位成功 - app_printf("led GPS locate success\n"); + DEBUG("led GPS locate success\n"); led_status.gps_ready = 1; }else if(led_event & EVENT_GPS_NO_LOCATE){ // GPS无定位 - app_printf("led GPS no locate\n"); + DEBUG("led GPS no locate\n"); led_status.gps_ready = 0; } @@ -109,7 +117,7 @@ void led_task(char *param){ void led_task_init(void){ LED_EventFlags =osEventFlagsNew(NULL); if(NULL == LED_EventFlags){ - app_printf("LED_EventFlags create fail\n"); + DEBUG("LED_EventFlags create fail\n"); } cm_gpio_cfg_t cfg = {0}; cfg.direction = CM_GPIO_DIRECTION_OUTPUT; @@ -134,14 +142,14 @@ void my_appimg_enter(char *param){ char buf[CM_VER_LEN] = {0}; cm_fs_system_info_t info = {0, 0}; cm_heap_stats_t stats = {0}; - app_printf("\n\n\n\n\n"); - app_printf("CM OpenCPU Starts\n"); + DEBUG("\n\n\n\n\n"); + DEBUG("CM OpenCPU Starts\n"); cm_sys_get_cm_ver(buf, CM_VER_LEN); - app_printf("SDK VERSION:%s\n", buf); + DEBUG("SDK VERSION:%s\n", buf); cm_fs_getinfo(&info); cm_mem_get_heap_stats(&stats); - app_printf("fs total:%d,remain:%d\n", info.total_size, info.free_size); - app_printf("heap total:%d,remain:%d\n",stats.total_size,stats.free); + DEBUG("fs total:%d,remain:%d\n", info.total_size, info.free_size); + DEBUG("heap total:%d,remain:%d\n",stats.total_size,stats.free); } local_tts_init(); // local_tts_mute(0);// 取消静音 @@ -164,18 +172,18 @@ void my_appimg_enter(char *param){ // // cm_gpio_set_level(CM_GPIO_NUM_0, 1); // cm_gpio_set_pull(CM_GPIO_NUM_0, CM_GPIO_PULL_UP); // cm_gpio_set_direction(CM_GPIO_NUM_0, CM_GPIO_DIRECTION_INPUT); - // // app_printf("set_level 1\r\n"); + // // DEBUG("set_level 1\r\n"); // if(0 ==cm_gpio_get_level(CM_GPIO_NUM_0, &level)){ // 更新状态 - // // app_printf("gpio_get_level:%d\r\n",level); + // // DEBUG("gpio_get_level:%d\r\n",level); // } // osDelay(800/5); // cm_gpio_set_direction(CM_GPIO_NUM_0, CM_GPIO_DIRECTION_OUTPUT); // cm_gpio_set_level(CM_GPIO_NUM_0, 0); // // cm_gpio_set_pull(CM_GPIO_NUM_0, CM_GPIO_PULL_DOWN); - // // app_printf("set_level 0\r\n"); + // // DEBUG("set_level 0\r\n"); // if(0 ==cm_gpio_get_level(CM_GPIO_NUM_0, &level)){ // 更新状态 - // // app_printf("gpio_get_level:%d\r\n",level); + // // DEBUG("gpio_get_level:%d\r\n",level); // } // osDelay(800/5); // local_tts_set(7, 7, CM_LOCAL_TTS_DIGIT_AUTO); diff --git a/custom/jt808/inc/jt808_config.h b/custom/jt808/inc/jt808_config.h index 47f34f3..ab1a578 100644 --- a/custom/jt808/inc/jt808_config.h +++ b/custom/jt808/inc/jt808_config.h @@ -6,14 +6,16 @@ #include #include "jt808_util.h" -#define JT808_DEBUG_ENABLE 1 +#define JT808_DEBUG_ENABLE 0 #if JT808_DEBUG_ENABLE #include "app_uart.h" #define JT808_DEBUG(fmt, args...) app_printf("[JT808]" fmt, ##args) +#define JT808_DEBUG_DATA(fmt, args...) app_printf(fmt, ##args) #else #include "app_uart.h" #define JT808_DEBUG(fmt, ...) +#define JT808_DEBUG_DATA(fmt, ...) #endif diff --git a/custom/jt808/src/jt808_msg_parse.c b/custom/jt808/src/jt808_msg_parse.c index a48e7e2..9ff6e23 100644 --- a/custom/jt808/src/jt808_msg_parse.c +++ b/custom/jt808/src/jt808_msg_parse.c @@ -256,9 +256,9 @@ int jt808_msg_parse(const uint8_t *BufferReceive, uint16_t length, PrsResult_t * JT808_DEBUG("RECV Msg_ID:0x%04X len:%d\r\n", Result->msg_head.msg_id ,para_length); for(uint16_t i = 0; i < para_length; i++){ - app_printf("%02X ", *(para_Buffer + i)); + JT808_DEBUG_DATA("%02X ", *(para_Buffer + i)); } - app_printf("\n"); + JT808_DEBUG_DATA("\n"); // 消息体解析 if(0 != jt808_BodyParse((void *)(para_Buffer + 1 + sizeof(MsgHead_t) - ((para_Buffer[3] & 0x02)==0? 4 : 0)) ,Result)){ JT808_DEBUG("error jt808_BodyParse\r\n"); diff --git a/custom/jt808/src/jt808_msg_pkg.c b/custom/jt808/src/jt808_msg_pkg.c index 427c286..571d328 100644 --- a/custom/jt808/src/jt808_msg_pkg.c +++ b/custom/jt808/src/jt808_msg_pkg.c @@ -297,10 +297,10 @@ int jt808_msg_pkg(MessageID_t Msg_ID, JT808MsgESC_t *msgEscape){ JT808_DEBUG("SEND Msg_ID:0x%04X len:%d\r\n", Msg_ID ,msg_total_len + escape_len); for(uint16_t i = 0; i < msg_total_len + escape_len; i++){ - app_printf("%02X ", *(msgEscape->buf + i)); + JT808_DEBUG_DATA("%02X ", *(msgEscape->buf + i)); } - app_printf("\r\n"); + JT808_DEBUG_DATA("\r\n"); // jt808_free(msgEscape->buf); return 0; diff --git a/custom/jt808/src/jt808_set_TermParam.c b/custom/jt808/src/jt808_set_TermParam.c index 49723de..08fd33d 100644 --- a/custom/jt808/src/jt808_set_TermParam.c +++ b/custom/jt808/src/jt808_set_TermParam.c @@ -35,15 +35,15 @@ int8_t jt808_data_down_SeriaNet(uint8_t type, uint8_t *data, uint16_t len){ if(type == 0x41){ // 串口1下传 JT808_DEBUG("Serial1 data: "); for(uint16_t i = 0; i < len; i++){ - app_printf("%02X ", data[i]); + JT808_DEBUG_DATA("%02X ", data[i]); } - app_printf("\r\n"); + JT808_DEBUG_DATA("\r\n"); }else if(type == 0x42){ // 串口2下传 JT808_DEBUG("Serial2 data: "); for(uint16_t i = 0; i < len; i++){ - app_printf("%02X ", data[i]); + JT808_DEBUG_DATA("%02X ", data[i]); } - app_printf("\r\n"); + JT808_DEBUG_DATA("\r\n"); }else{ JT808_DEBUG("[%s,%s] type error \r\n", __FUNCTION__,__LINE__); return -1; @@ -358,6 +358,7 @@ void Autoreport_param_Task(void *arg){ if(0 == (count_Sec % jt808_term_param_item.set_term_param.HeartBeatInterval)){ if((gps_data.info.fix == 1)||(gps_data.info.sig == 0)){ // 不可用// 未定位时发送心跳包 jt808_pkg_send(ID_Term_HB,0); // 发送心跳包 // 不接收应答 + JT808_DEBUG("Bat_Percent:%d,Bat_Voltage:%d,Bat_STA:%X\r\n",BAT_Message.Bat_Percent,BAT_Message.Bat_Voltage,BAT_Message.Bat_STA); }else{ jt808_pkg_send(ID_LocReport,10000/5); // 发送位置信息上报包 } @@ -423,9 +424,9 @@ void jt808_set_term_param_init(void){ jt808_term_param_item.msg_flow_num =0; JT808_DEBUG("phone_BCDnum:"); for(int i=0;i<6;i++){ - app_printf("%02X ",jt808_term_param_item.phone_BCDnum[i]); + JT808_DEBUG_DATA("%02X ",jt808_term_param_item.phone_BCDnum[i]); } - app_printf("\n"); + JT808_DEBUG_DATA("\n"); }while(0); do{// 注册信息初始化 char read_buf[35] = {0}; @@ -482,10 +483,10 @@ void jt808_set_term_param_init(void){ }while(0); do{// 终端参数初始化 jt808_term_param_item.set_term_param.HeartBeatInterval = 30; // 心跳包间隔(秒) - char ServerAddr[] ="47.99.118.34"; // 服务器地址 - uint32_t ServerPort = 5000; // 服务器端口 - // char ServerAddr[] ="106.14.30.23"; // 服务器地址 + // char ServerAddr[] ="47.99.118.34"; // 测试服务器地址 // uint32_t ServerPort = 5000; // 服务器端口 + char ServerAddr[] ="106.14.30.23"; // 生产服务器地址 + uint32_t ServerPort = 5000; // 服务器端口 // memset(jt808_term_param_item.set_term_param.MainServerAddr, 0, 50); memcpy(jt808_term_param_item.set_term_param.MainServerAddr, ServerAddr, strlen(ServerAddr)+1); // 主服务器地址 jt808_term_param_item.set_term_param.ServerPort = ServerPort; // 服务器端口 diff --git a/custom/local_tts/src/local_tts.c b/custom/local_tts/src/local_tts.c index 9896326..e1ebe4a 100644 --- a/custom/local_tts/src/local_tts.c +++ b/custom/local_tts/src/local_tts.c @@ -13,12 +13,14 @@ #include "local_tts.h" -#if 1 +#if 0 #include "app_uart.h" #define DEBUG(fmt, args...) app_printf("[tts]" fmt, ##args) #else -#define DEBUG(fmt, arg...) +#include "app_uart.h" +#define DEBUG(fmt, ...) #endif + static osMessageQueueId_t local_tts_play_queue = NULL; // static osMessageQueueId_t local_tts_free_sem_queue = NULL; static osSemaphoreId_t local_tts_play_ok_sem = NULL; @@ -185,7 +187,7 @@ static osThreadFunc_t local_tts_play_task(void *arg){ // DEBUG("tts task: 1111111111\n\n"); // if(0 == tts_play_queue.en_interruptible){ // 不允许被打断播放 // DEBUG("tts task: 2222222222\n\n"); - ret =osSemaphoreAcquire(local_tts_play_ok_sem, (0 == tts_play_queue.en_interruptible)?(30000/5):(1000/5));// 等待播放结束 + ret =osSemaphoreAcquire(local_tts_play_ok_sem, (0 == tts_play_queue.en_interruptible)?(30000/5):(2000/5));// 等待播放结束 if(osOK != ret){ DEBUG("local_tts_play_ok_sem:%d\n", ret); }