接上层:
/**
* @brief 控制台强制打印
* @param info:打印的信息
*/
void log_print_force(char *info)
{
T_Time time;
char log_out[256] = {0};
time = get_time();
sprintf(log_out,"%05d:%03d:%03d %s\r\n",time.s,time.ms,time.us,info);
console_tx((uint8_t *)log_out,strlen(log_out));
}
/**
* @brief 接收处理
* @param rx:接收数据
*/
void log_deal_rx(struct _Console_Rx rx)
{
uint8_t i = 0;
int num = 0;
char str_temp[5] = {0};
//判断是否是输出本地日志
if (rx.len == 1 && rx.buf[0] == 'I')
{
print_log();
return;
}
//判断是否是输出本地日志
if (rx.len == 1 && rx.buf[0] == 'C')
{
log_clear();
return;
}
//判断是否是暂停输出
if (rx.len == 1 && rx.buf[0] == 'P')
{
Flag_Pause = 1;
return;
}
//判断是否是打开输出
if (rx.len == 1 && rx.buf[0] == 'S')
{
Flag_Pause = 0;
return;
}
//判断是否是帮助
if (rx.len == 1 && rx.buf[0] == 'H')
{
help();
return;
}
//判断是否是过滤规则
if (rx.len <= 3 && rx.buf[0] == 'F')
{
if (rx.len == 1)
{
//全部过滤
for (i = 0;i < NUM_LOG;i++)
{
Filter = 1;
}
return;
}
memset(str_temp,sizeof(str_temp),0);
memcpy(str_temp,rx.buf,rx.len);
sscanf(str_temp,"F%d",&num);
Filter[num] = 1;
return;
}
//判断是否是打开模块
if (rx.len <= 3 && rx.buf[0] == 'O')
{
if (rx.len == 1)
{
//清除过滤规则
for (i = 0;i < NUM_LOG;i++)
{
Filter = 0;
}
return;
}
memset(str_temp,sizeof(str_temp),0);
memcpy(str_temp,rx.buf,rx.len);
sscanf(str_temp,"O%d",&num);
Filter[num] = 0;
return;
}
//判断是否是打开模块
if (rx.len > 1 && rx.len <= 3 && rx.buf[0] == 'A')
{
memset(str_temp,sizeof(str_temp),0);
memcpy(str_temp,rx.buf,rx.len);
sscanf(str_temp,"A%d",&num);
deal_action(num);
return;
}
}
/**
* @brief 帮助界面
*/
static void help(void)
{
char log_out[100] = {0};
strcpy(log_out,"*******************************************\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out," UWB基站日志帮助界面 \r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"硬件版本:%d 软件版本:%d\r\n",VERSION_HARD,VERSION_SOFT);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"总线通信协议版本:%s\r\n",VERSION_NAME_BUS);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"空口通信协议版本:%s\r\n",VERSION_NAME_UWB);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"CSSN:0x%06x ID:0x%04x\r\n",para_manage_read_cssn(), para_manage_read_id());
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键I(INFO)输出本地日志\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键C(CLEAR)清除本地日志\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键P(PAUSE)暂停输出\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键S(START)开始输出\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键A(ACTION)动作\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"A1:读取1号dw1000状态寄存器\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"A2:清除1号dw1000状态寄存器\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"A3:打开1号dw1000接收\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键H(HELP)打开帮助\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键F(FILTER)过滤输出\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"例:过滤1号模块:F1\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"例:全部过滤:F\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"快捷键O(OPEN)打开模块\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"例:打开1号模块:O1\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"例:全部打开:O\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"包含的模块:\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"TEST:%d 过滤:%d \r\n",LOG_TEST,Filter[LOG_TEST]);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"CLOCK:%d 过滤:%d \r\n",LOG_CLOCK,Filter[LOG_CLOCK]);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"DW1000:%d 过滤:%d \r\n",LOG_DW1000,Filter[LOG_DW1000]);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"DW1000_STATUS:%d 过滤:%d \r\n",LOG_DW1000_STATUS,Filter[LOG_DW1000_STATUS]);
console_tx((uint8_t *)log_out,strlen(log_out));
sprintf(log_out,"DW1000_DEAL_BUS:%d 过滤:%d \r\n",LOG_DEAL_BUS,Filter[LOG_DEAL_BUS]);
console_tx((uint8_t *)log_out,strlen(log_out));
strcpy(log_out,"*******************************************\r\n");
console_tx((uint8_t *)log_out,strlen(log_out));
}
|