1. 增加日志等级
This commit is contained in:
parent
7201a8629a
commit
808e05cd07
@ -68,6 +68,8 @@
|
|||||||
#define LogHexData(data, len)
|
#define LogHexData(data, len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define LogTVHex(data, len) HDLogHexType((const uint8_t *)data, len, 1, NULL, kLogLevelTVHex)
|
||||||
|
|
||||||
// 仅用于兼容旧版, 实际不输出数据
|
// 仅用于兼容旧版, 实际不输出数据
|
||||||
#define qDebugWin(A, B)
|
#define qDebugWin(A, B)
|
||||||
#define OutputFunInfo
|
#define OutputFunInfo
|
||||||
@ -95,6 +97,7 @@ typedef enum eLogLevel {
|
|||||||
kLogLevelStack, ///< 打印栈大小信息
|
kLogLevelStack, ///< 打印栈大小信息
|
||||||
kLogLevelHeap, ///< 打印堆大小信息
|
kLogLevelHeap, ///< 打印堆大小信息
|
||||||
kLogLevelTrace, ///< trace级别日志
|
kLogLevelTrace, ///< trace级别日志
|
||||||
|
kLogLevelTVHex, ///< TV Hex 日志
|
||||||
kLogLevelMax,
|
kLogLevelMax,
|
||||||
} eLogLevel;
|
} eLogLevel;
|
||||||
|
|
||||||
@ -146,6 +149,7 @@ uint8_t HDLogCheckFpgaHeader(const uint8_t *data, int len);
|
|||||||
* @param offset 打印偏移, 一般传递 NULL 即可
|
* @param offset 打印偏移, 一般传递 NULL 即可
|
||||||
**/
|
**/
|
||||||
void HDLogHex(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset);
|
void HDLogHex(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset);
|
||||||
|
void HDLogHexType(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset, uint8_t logLevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 无格式以16进制打印数据, 打印16个换行
|
* @brief 无格式以16进制打印数据, 打印16个换行
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#define __HDRPC_H__
|
#define __HDRPC_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
// 设置超时时间
|
// 设置超时时间
|
||||||
#ifndef HDRPC_TIMEOUT
|
#ifndef HDRPC_TIMEOUT
|
||||||
@ -293,7 +294,7 @@ void HDRPCReadCallData(void *data, uint16_t len);
|
|||||||
* @param timeout 超时回调
|
* @param timeout 超时回调
|
||||||
* @return int16_t id索引(返回-1则无存储返回回调)
|
* @return int16_t id索引(返回-1则无存储返回回调)
|
||||||
*/
|
*/
|
||||||
int16_t _HDRPCSendData(HDRPCSession *session, uint16_t funcCode, HDRPCCallback callBack, const char *funcName, uint8_t nameLen, HDRPCTimeoutCall timeout);
|
HDRPCIndexId_t _HDRPCSendData(HDRPCSession *session, uint16_t funcCode, HDRPCCallback callBack, const char *funcName, uint8_t nameLen, HDRPCTimeoutCall timeout);
|
||||||
#define HDRPCSendData(session, code, func) _HDRPCSendData(session, code, func, #func, sizeof(#func) - 1, NULL)
|
#define HDRPCSendData(session, code, func) _HDRPCSendData(session, code, func, #func, sizeof(#func) - 1, NULL)
|
||||||
#define HDRPCSendDataNotCall(session, code) _HDRPCSendData(session, code, NULL, NULL, 0, NULL)
|
#define HDRPCSendDataNotCall(session, code) _HDRPCSendData(session, code, NULL, NULL, 0, NULL)
|
||||||
#define HDRPCSendDataTimeout(session, code, func, timeout) _HDRPCSendData(session, code, func, #func, sizeof(#func) - 1, timeout)
|
#define HDRPCSendDataTimeout(session, code, func, timeout) _HDRPCSendData(session, code, func, #func, sizeof(#func) - 1, timeout)
|
||||||
@ -312,20 +313,20 @@ uint16_t HDRPCConvSendData(HDRPCSession *session, uint8_t *data, uint16_t len);
|
|||||||
* @brief idIndex 发送返回的id索引
|
* @brief idIndex 发送返回的id索引
|
||||||
* @brief delayMs 超时时间(ms)
|
* @brief delayMs 超时时间(ms)
|
||||||
*/
|
*/
|
||||||
void HDRPCSetDelayTime(int16_t idIndex, uint16_t delayMs);
|
void HDRPCSetDelayTime(HDRPCIndexId_t idIndex, uint16_t delayMs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 移除任务
|
* @brief 移除任务
|
||||||
* @brief idIndex 发送返回的id索引
|
* @brief idIndex 发送返回的id索引
|
||||||
*/
|
*/
|
||||||
void HDRPCRemoveTask(int16_t idIndex);
|
void HDRPCRemoveTask(HDRPCIndexId_t idIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 获取对于任务的回调函数
|
* @brief 获取对于任务的回调函数
|
||||||
* @param idIndex 发送返回的id索引
|
* @param idIndex 发送返回的id索引
|
||||||
* @return 无效返回NULL
|
* @return 无效返回NULL
|
||||||
*/
|
*/
|
||||||
HDRPCCallback HDRPCGetCallBack(int16_t idIndex);
|
HDRPCCallback HDRPCGetCallBack(HDRPCIndexId_t idIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 运转RPC, 主要用于处理超时
|
* @brief 运转RPC, 主要用于处理超时
|
||||||
|
|||||||
14
src/HDLog.c
14
src/HDLog.c
@ -45,6 +45,7 @@ static HShellMatch sLogMatch[] = {
|
|||||||
HSHELL_MATCH_ITEM(kLogLevelDebug, "logDebug"),
|
HSHELL_MATCH_ITEM(kLogLevelDebug, "logDebug"),
|
||||||
HSHELL_MATCH_ITEM(kLogLevelError, "logError"),
|
HSHELL_MATCH_ITEM(kLogLevelError, "logError"),
|
||||||
HSHELL_MATCH_ITEM(kLogLevelHex, "logHex"),
|
HSHELL_MATCH_ITEM(kLogLevelHex, "logHex"),
|
||||||
|
HSHELL_MATCH_ITEM(kLogLevelTVHex, "logTVHex"),
|
||||||
HSHELL_MATCH_ITEM(kLogLevelStack, "logStack"),
|
HSHELL_MATCH_ITEM(kLogLevelStack, "logStack"),
|
||||||
HSHELL_MATCH_ITEM(kLogLevelHeap, "logHeap"),
|
HSHELL_MATCH_ITEM(kLogLevelHeap, "logHeap"),
|
||||||
#if USE_HD_FPGA_CHECK
|
#if USE_HD_FPGA_CHECK
|
||||||
@ -101,9 +102,9 @@ static uint32_t *GetFpgaType(uint8_t type, uint8_t isWrite)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void LogHex(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset, uint8_t lock)
|
static void LogHex(const uint8_t *data, int len, uint8_t checkPrint, uint8_t logLevel, uint32_t *offset, uint8_t lock)
|
||||||
{
|
{
|
||||||
if (checkPrint && HBitGet(sLogItem, kLogLevelHex) == 0)
|
if (checkPrint && HBitGet(sLogItem, logLevel) == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -461,7 +462,7 @@ uint8_t HDLogPrintFpga(const uint8_t *data, int len, uint8_t isWrite, uint8_t ch
|
|||||||
const char *opt = isWrite ? "write" : "read";
|
const char *opt = isWrite ? "write" : "read";
|
||||||
printf("%s[%u], typeCount[%u] - type[%02X], sendCard[%d], netPort[%d], cardNumber[%d], subFunc[%04X], group[%04X], effectLen[%d]\r\n", opt, count, typeCount, type, sendCard, port, recvCardNumber, subFunc, group, effectLen);
|
printf("%s[%u], typeCount[%u] - type[%02X], sendCard[%d], netPort[%d], cardNumber[%d], subFunc[%04X], group[%04X], effectLen[%d]\r\n", opt, count, typeCount, type, sendCard, port, recvCardNumber, subFunc, group, effectLen);
|
||||||
|
|
||||||
LogHex((const uint8_t *)(data) + 17, (len) - 21, 1, NULL, 0);
|
LogHex((const uint8_t *)(data) + 17, (len) - 21, 1, kLogLevelHex, NULL, 0);
|
||||||
LOG_UNLOCK();
|
LOG_UNLOCK();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -469,7 +470,12 @@ uint8_t HDLogPrintFpga(const uint8_t *data, int len, uint8_t isWrite, uint8_t ch
|
|||||||
|
|
||||||
void HDLogHex(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset)
|
void HDLogHex(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset)
|
||||||
{
|
{
|
||||||
LogHex(data, len, checkPrint, offset, 1);
|
LogHex(data, len, checkPrint, kLogLevelHex, offset, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HDLogHexType(const uint8_t *data, int len, uint8_t checkPrint, uint32_t *offset, uint8_t logLevel)
|
||||||
|
{
|
||||||
|
LogHex(data, len, checkPrint, logLevel, offset, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDLogData(const uint8_t *data, int len, uint8_t checkPrint)
|
void HDLogData(const uint8_t *data, int len, uint8_t checkPrint)
|
||||||
|
|||||||
14
src/HDRPC.c
14
src/HDRPC.c
@ -157,8 +157,8 @@ static void Call(HDRPCSession *session, uint16_t exception) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t AddCall(HDRPCSession *session, HDRPCCallback callBack, const char *funcName, uint8_t nameLen, HDRPCTimeoutCall timeout) {
|
static HDRPCIndexId_t AddCall(HDRPCSession *session, HDRPCCallback callBack, const char *funcName, uint8_t nameLen, HDRPCTimeoutCall timeout) {
|
||||||
int16_t result = -1;
|
HDRPCIndexId_t result = -1;
|
||||||
if (session == NULL || callBack == NULL || nameLen == 0) {
|
if (session == NULL || callBack == NULL || nameLen == 0) {
|
||||||
LogD("funcName[%s], len[%d] add Faild", funcName, nameLen);
|
LogD("funcName[%s], len[%d] add Faild", funcName, nameLen);
|
||||||
return result;
|
return result;
|
||||||
@ -693,9 +693,9 @@ void HDRPCReadCallData(void *data, uint16_t len)
|
|||||||
ParseReadDataCall(session, data, len);
|
ParseReadDataCall(session, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t _HDRPCSendData(HDRPCSession *session, uint16_t funcCode, HDRPCCallback callBack, const char *funcName, uint8_t nameLen, HDRPCTimeoutCall timeout)
|
HDRPCIndexId_t _HDRPCSendData(HDRPCSession *session, uint16_t funcCode, HDRPCCallback callBack, const char *funcName, uint8_t nameLen, HDRPCTimeoutCall timeout)
|
||||||
{
|
{
|
||||||
int16_t result = -1;
|
HDRPCIndexId_t result = -1;
|
||||||
if (sInfo.writeCall == NULL) {
|
if (sInfo.writeCall == NULL) {
|
||||||
LogD("Write Call is nullptr");
|
LogD("Write Call is nullptr");
|
||||||
return result;
|
return result;
|
||||||
@ -750,7 +750,7 @@ uint16_t HDRPCConvSendData(HDRPCSession *session, uint8_t *data, uint16_t len)
|
|||||||
return useLen;
|
return useLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDRPCSetDelayTime(int16_t idIndex, uint16_t delayMs)
|
void HDRPCSetDelayTime(HDRPCIndexId_t idIndex, uint16_t delayMs)
|
||||||
{
|
{
|
||||||
if (idIndex < 0 || idIndex >= sInfo.callLen) {
|
if (idIndex < 0 || idIndex >= sInfo.callLen) {
|
||||||
LogD("Invalid idIndex[%d]", idIndex);
|
LogD("Invalid idIndex[%d]", idIndex);
|
||||||
@ -760,7 +760,7 @@ void HDRPCSetDelayTime(int16_t idIndex, uint16_t delayMs)
|
|||||||
sInfo.localCallBuffer[idIndex].delayMs = delayMs;
|
sInfo.localCallBuffer[idIndex].delayMs = delayMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
HDRPCCallback HDRPCGetCallBack(int16_t idIndex)
|
HDRPCCallback HDRPCGetCallBack(HDRPCIndexId_t idIndex)
|
||||||
{
|
{
|
||||||
if (idIndex < 0 || idIndex >= sInfo.callLen) {
|
if (idIndex < 0 || idIndex >= sInfo.callLen) {
|
||||||
LogD("Invalid idIndex[%d], len[%d]", idIndex, sInfo.callLen);
|
LogD("Invalid idIndex[%d], len[%d]", idIndex, sInfo.callLen);
|
||||||
@ -770,7 +770,7 @@ HDRPCCallback HDRPCGetCallBack(int16_t idIndex)
|
|||||||
return sInfo.localCallBuffer[idIndex].callback;
|
return sInfo.localCallBuffer[idIndex].callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HDRPCRemoveTask(int16_t idIndex)
|
void HDRPCRemoveTask(HDRPCIndexId_t idIndex)
|
||||||
{
|
{
|
||||||
if (idIndex < 0 || idIndex >= sInfo.callLen) {
|
if (idIndex < 0 || idIndex >= sInfo.callLen) {
|
||||||
LogD("Invalid idIndex[%d]", idIndex);
|
LogD("Invalid idIndex[%d]", idIndex);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user