log_note log_error log_warning

测试操作与日志记录
本文介绍了使用testop.tcl脚本进行初始化和操作的方法,包括设置状态、记录日志等关键步骤。

testop.tcl

=========

proc testop_initialize { } {

}

proc testop_start { state} {  

  variable testopsp  

  set testopsp $state  

  log_note "set test_shutter to $testopsp"        

  log_error "error information"        

  log_warning "warning information"

}

=========

in device db

testop

11

self testop

0 1 1 1 1

0 1 1 1 1

 

 

 

转载于:https://www.cnblogs.com/greencolor/archive/2012/02/13/2350218.html

代码段1:u8 gmp108l_initialization(void) { u8 rc, u8Data; /***** check sensor version *****/ rc = gmp108l_burst_read(GMP108L_REG_REV_ID, &u8Data, 1); if (rc != 0) return (rc); GMP108L_LOG_DEBUG("Sensor Value = 0x%02X", u8Data); /***** check sensor ID *****/ rc = gmp108l_burst_read(GMP108L_REG_CHIP_ID, &u8Data, 1); if (rc != 0) return (rc); GMP108L_LOG_DEBUG("Sensor Value = 0x%02X", u8Data); /***** (Reg)FIFO_CONFIG_1, enable filtered data, subsampling interval: 0, *****/ u8Data = 0x00; rc = gmp108l_burst_write(GMP108L_REG_FIFO_CONFIG_1, &u8Data, 1); if (rc != 0) return (rc); /***** (Reg)INT_CTRL, enable data ready interrupt, *****/ u8Data = 0x40; rc = gmp108l_burst_write(GMP108L_REG_INT_CTRL, &u8Data, 1); if (rc != 0) return (rc); /***** (Reg)OSR, oversampling ratio (P & T) *****/ u8Data = 0x35; // OSR_T: x8, OSR_P: x32 rc = gmp108l_burst_write(GMP108L_REG_OSR, &u8Data, 1); if (rc != 0) return (rc); /***** (Reg)ODR, output data rate) *****/ u8Data = 0x16; // ODR: 6.4Hz rc = gmp108l_burst_write(GMP108L_REG_ODR, &u8Data, 1); if (rc != 0) return (rc); /***** (Reg)FILTER, IIR-filter_coe_P, IIR-filter_coe_T, *****/ // u8Data = 0x00; // filter-coes: 0 u8Data = 0x33; // filter-coes: 7 rc = gmp108l_burst_write(GMP108L_REG_FILTER, &u8Data, 1); if (rc != 0) return (rc); return (rc); } 代码段2:// 定义日志级别(可根据需求调整) #define GMP108L_LOG_LEVEL_NONE 0 // 关闭所有日志 #define GMP108L_LOG_LEVEL_ERROR 1 // 仅错误 #define GMP108L_LOG_LEVEL_WARN 2 // 错误+警告 #define GMP108L_LOG_LEVEL_INFO 3 // 错误+警告+信息 #define GMP108L_LOG_LEVEL_DEBUG 4 // 全部日志(调试用) // 设置当前日志级别(发布版本可改为 GMP108L_LOG_LEVEL_NONE 或 GMP108L_LOG_LEVEL_ERROR) #ifndef GMP108L_LOG_LEVEL #define GMP108L_LOG_LEVEL GMP108L_LOG_LEVEL_DEBUG #endif // 平台输出函数(替换为实际平台的打印函数,如 hal_uart_printf) #ifndef PLATFORM_LOG_PRINT #define PLATFORM_LOG_PRINT(...) printf(__VA_ARGS__) // 默认使用标准 printf #endif // 日志宏定义(包含文件、行号、函数名) #define GMP108L_LOG(level, fmt, ...) do { \ if ((level) <= GMP108L_LOG_LEVEL) { \ PLATFORM_LOG_PRINT("[GMP108L][%s][%s:%d] ", \ #level, __func__, __LINE__); \ PLATFORM_LOG_PRINT(fmt, ##__VA_ARGS__); \ PLATFORM_LOG_PRINT("\n"); \ } \ } while(0) // 简化不同级别调用的宏 #define GMP108L_LOG_ERROR(fmt, ...) GMP108L_LOG(GMP108L_LOG_LEVEL_ERROR, "ERROR", fmt, ##__VA_ARGS__) #define GMP108L_LOG_WARN(fmt, ...) GMP108L_LOG(GMP108L_LOG_LEVEL_WARN, "WARN", fmt, ##__VA_ARGS__) #define GMP108L_LOG_INFO(fmt, ...) GMP108L_LOG(GMP108L_LOG_LEVEL_INFO, "INFO", fmt, ##__VA_ARGS__) #define GMP108L_LOG_DEBUG(fmt, ...) GMP108L_LOG(GMP108L_LOG_LEVEL_DEBUG, "DEBUG", fmt, ##__VA_ARGS__) #define gmp108l_get_bitslice(regvar, bitname) \ ((regvar & bitname##__MSK) >> bitname##__POS) #define gmp108l_set_bitslice(regvar, bitname, val) \ ((regvar & ~bitname##__MSK) | ((val<<bitname##__POS) & bitname##__MSK)) 报错:../../platform/huaqin_drivers/src/sensor/GMP108L/GMP108L.c: In function 'gmp108l_initialization': ../../platform/huaqin_drivers/src/sensor/GMP108L/GMP108L.h:307:75: warning: too many arguments for format [-Wformat-extra-args] 307 | #define GMP108L_LOG_DEBUG(fmt, ...) GMP108L_LOG(GMP108L_LOG_LEVEL_DEBUG, "DEBUG", fmt, ##__VA_ARGS__) | ^~~~~~~ ../../platform/huaqin_drivers/src/sensor/GMP108L/GMP108L.h:290:40: note: in definition of macro 'PLATFORM_LOG_PRINT' 290 | #define PLATFORM_LOG_PRINT(...) printf(__VA_ARGS__) // 默认使用标准 printf | ^~~~~~~~~~~ ../../platform/huaqin_drivers/src/sensor/GMP108L/GMP108L.h:307:38: note: in expansion of macro 'GMP108L_LOG' 307 | #define GMP108L_LOG_DEBUG(fmt, ...) GMP108L_LOG(GMP108L_LOG_LEVEL_DEBUG, "DEBUG", fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ ../../platform/huaqin_drivers/src/sensor/GMP108L/GMP108L.c:206:3: note: in expansion of macro 'GMP108L_LOG_DEBUG' 206 | GMP108L_LOG_DEBUG("Sensor Value = 0x%02X", u8Data);怎么改
06-21
OS-Kernel/include/freertos/portable.h:59, from D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/freertos/FreeRTOS-Kernel/include/freertos/FreeRTOS.h:71, from D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.h:4, from D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:1: D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:141:58: error: expected ')' before numeric constant 141 | #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) | ^~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:6:7: note: in expansion of macro 'portTICK_PERIOD_MS' 6 | float portTICK_PERIOD_MS = 1.0f; // 榛樿鍊硷紝瀹為檯浣跨敤鍓嶅簲鏍″噯 | ^~~~~~~~~~~~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c: In function 'timer_calibrate': D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:19:24: error: lvalue required as left operand of assignment 19 | portTICK_PERIOD_MS = (real_duration_us / 1000.0f) / elapsed_ticks; | ^ In file included from D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:2: D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:265:27: warning: format '%f' expects argument of type 'double', but argument 6 has type 'long unsigned int' [-Wformat=] 265 | #define LOG_COLOR(COLOR) "\033[0;" COLOR "m" | ^~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:268:27: note: in expansion of macro 'LOG_COLOR' 268 | #define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED) | ^~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:282:37: note: in expansion of macro 'LOG_COLOR_E' 282 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:410:86: note: in expansion of macro 'LOG_FORMAT' 410 | if (level==ESP_LOG_ERROR ) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:432:41: note: in expansion of macro 'ESP_LOG_LEVEL' 432 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:342:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 342 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:5: note: in expansion of macro 'ESP_LOGI' 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:265:27: warning: format '%f' expects argument of type 'double', but argument 6 has type 'long unsigned int' [-Wformat=] 265 | #define LOG_COLOR(COLOR) "\033[0;" COLOR "m" | ^~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:269:27: note: in expansion of macro 'LOG_COLOR' 269 | #define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN) | ^~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:282:37: note: in expansion of macro 'LOG_COLOR_W' 282 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:411:86: note: in expansion of macro 'LOG_FORMAT' 411 | else if (level==ESP_LOG_WARN ) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:432:41: note: in expansion of macro 'ESP_LOG_LEVEL' 432 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:342:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 342 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:5: note: in expansion of macro 'ESP_LOGI' 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:1: warning: format '%f' expects argument of type 'double', but argument 6 has type 'long unsigned int' [-Wformat=] 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^ ~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:282:59: note: in definition of macro 'LOG_FORMAT' 282 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:432:41: note: in expansion of macro 'ESP_LOG_LEVEL' 432 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:342:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 342 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:5: note: in expansion of macro 'ESP_LOGI' 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:1: warning: format '%f' expects argument of type 'double', but argument 6 has type 'long unsigned int' [-Wformat=] 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^ ~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:282:59: note: in definition of macro 'LOG_FORMAT' 282 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:432:41: note: in expansion of macro 'ESP_LOG_LEVEL' 432 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:342:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 342 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:5: note: in expansion of macro 'ESP_LOGI' 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:265:27: warning: format '%f' expects argument of type 'double', but argument 6 has type 'long unsigned int' [-Wformat=] 265 | #define LOG_COLOR(COLOR) "\033[0;" COLOR "m" | ^~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:270:27: note: in expansion of macro 'LOG_COLOR' 270 | #define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN) | ^~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:282:37: note: in expansion of macro 'LOG_COLOR_I' 282 | #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") %s: " format LOG_RESET_COLOR "\n" | ^~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:414:86: note: in expansion of macro 'LOG_FORMAT' 414 | else { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } \ | ^~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:432:41: note: in expansion of macro 'ESP_LOG_LEVEL' 432 | if ( LOG_LOCAL_LEVEL >= level ) ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~ D:/CxhData/EspData/esp/v5.1.5/esp-idf/components/log/include/esp_log.h:342:38: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL' 342 | #define ESP_LOGI( tag, format, ... ) ESP_LOG_LEVEL_LOCAL(ESP_LOG_INFO, tag, format, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~ D:/CxhData/test/2/24_0222_RGBMatrix/LedRGBMatrix/LedRGBMatrix_Single/main/Fun/countdown_timer.c:20:5: note: in expansion of macro 'ESP_LOGI' 20 | ESP_LOGI("TIMER_CAL", "鏍″噯tick鍛ㄦ湡: %.6f ms", portTICK_PERIOD_MS); | ^~~~~~~~ ninja: build stopped: subcommand failed. * 终端进程“d:\CxhData\EspData\.espressif\tools\ninja\1.12.1\ninja.EXE”已终止,退出代码: 1。
07-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值