使用 ulog 時發現有
LOG_BIN函數和LOG_BIN_MIX函數,但是不清楚怎麼用。
![]()
兩種使用方式,LOG_BIN 沒有輸出顯示,LOG_BIN_MIX 輸出顯示一些符號、字元。


程式碼
#include "rtthread.h"
#include "bf0_hal.h"
#include "drv_io.h"
#include "stdio.h"
#include "string.h"
#define LOG_TAG "LOG.TEST" /* 本模組的日誌標籤,預設:NO_TAG */
#define LOG_LVL LOG_LVL_DBG /* 本模組的日誌級別,預設:LOG_LVL_Debug */
#include <ulog.h> /* 日誌庫頭文件 */
/**
* @brief Main program
* @param None
* @retval 0 if success, otherwise failure number
*/
int main(void)
{
int count = 0;
uint8_t hex_data[] = {
0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, // "Hello Wo"
0x72, 0x6C, 0x64, 0x21, 0x01, 0x02, 0x03, 0x04 // "rld!..."
};
uint8_t bin_data[] = {0b01001000,0b01100101,0b01101100,0b01101100,0b01101111,0b00100000,0b01010111,0b01101111,
0b01110010,0b01101100,0b01100100,0b00100001,0b00000001,0b00000010,0b00000011,0b00000100};
while (1)
{
LOG_RAW("No_Format\r\n");
LOG_BIN(hex_data, sizeof(hex_data));
rt_kprintf("\r\n");
LOG_BIN_MIX(hex_data, sizeof(hex_data));
rt_kprintf("\r\n");
// Delay for 1000 ms to yield CPU time to other threads
rt_thread_mdelay(1000);
}
return 0;
}