去掉LOG日志打印 zsxfly20250228

This commit is contained in:
zsx 2025-02-28 01:06:37 +08:00
parent c54390661c
commit a603926c44
7 changed files with 56 additions and 43 deletions

View File

@ -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

View File

@ -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);

View File

@ -6,14 +6,16 @@
#include <stdlib.h>
#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

View File

@ -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");

View File

@ -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;

View File

@ -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; // 服务器端口

View File

@ -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);
}