Add more header info output
This commit is contained in:
parent
8f01578411
commit
274e1ca9b0
@ -26,6 +26,11 @@ DLT_File::~DLT_File()
|
||||
// 清理请求的存储并恢复初始状态
|
||||
void DLT_File::clear(void)
|
||||
{
|
||||
if (this->p_file != nullptr)
|
||||
{
|
||||
fclose(this->p_file);
|
||||
this->p_file = nullptr;
|
||||
}
|
||||
|
||||
if (this->Msg_List_Head == nullptr)
|
||||
return;
|
||||
@ -288,11 +293,9 @@ DLT_Type::DLT_Err DLT_File::export_to_csv(const char *file_name_str)
|
||||
if (p_file == nullptr)
|
||||
return DLT_Type::DLT_ERROR_FILE_CREATE_FAILED;
|
||||
|
||||
DLT_Type::DLT_Msg_Node *p_msg = this->Msg_List_Head;
|
||||
|
||||
// 打印首行
|
||||
{
|
||||
fprintf(p_file, "Index,Date,Time,Timestamp,Count,ECU ID,Application ID,Context ID ,Session ID,Type,Sub Type,Mode,#Args,Payload,");
|
||||
fprintf(p_file, "Index,Date&Time(Local),Timestamp,Count,ECU ID,Application ID,Context ID ,Session ID,Type,Sub Type,Mode,#Args,Payload,");
|
||||
|
||||
for (size_t count = 0; count < this->payload_max_len; count++)
|
||||
fprintf(p_file, "B%d,", count);
|
||||
@ -301,6 +304,7 @@ DLT_Type::DLT_Err DLT_File::export_to_csv(const char *file_name_str)
|
||||
}
|
||||
|
||||
// 遍历每行数据
|
||||
DLT_Type::DLT_Msg_Node *p_msg = this->Msg_List_Head;
|
||||
for (size_t line_count = 0; line_count < this->msg_count; line_count++)
|
||||
{
|
||||
|
||||
@ -312,13 +316,9 @@ DLT_Type::DLT_Err DLT_File::export_to_csv(const char *file_name_str)
|
||||
time_t timestamp = (time_t)p_msg->Msg.storage_header.seconds;
|
||||
struct tm *time_struct = localtime(×tamp);
|
||||
char time_str[100] = {'\0'};
|
||||
// 格式化为 "YY/MM/DD 时区"
|
||||
strftime(time_str, sizeof(time_str), "%Y/%m/%d UTC%z", time_struct);
|
||||
fprintf(p_file, "%s,", time_str);
|
||||
|
||||
// 格式化为 "HH:MM:SS"
|
||||
strftime(time_str, sizeof(time_str), "%H:%M:%S", time_struct);
|
||||
fprintf(p_file, "T-%s.%d,", time_str, p_msg->Msg.storage_header.microseconds);
|
||||
// 格式化为 "YY/MM/DD HH:MM:SS"
|
||||
strftime(time_str, sizeof(time_str), "%Y/%m/%d %H:%M:%S", time_struct);
|
||||
fprintf(p_file, "%s.%d,", time_str, p_msg->Msg.storage_header.microseconds);
|
||||
}
|
||||
|
||||
// 输出头附加信息
|
||||
@ -349,25 +349,60 @@ DLT_Type::DLT_Err DLT_File::export_to_csv(const char *file_name_str)
|
||||
else
|
||||
fprintf(p_file, "%.4s,", p_msg->Msg.storage_header.ecu);
|
||||
|
||||
// 存在扩展头
|
||||
// 输出 Apid 和 Ctid
|
||||
if (p_msg->Msg.standard_header.htyp.UEH)
|
||||
{
|
||||
fprintf(p_file, "%.4s,", p_msg->Msg.extendedheader.apid);
|
||||
fprintf(p_file, "%.4s,", p_msg->Msg.extendedheader.ctid);
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip apid && ctid
|
||||
fprintf(p_file, "N/A,N/A,");
|
||||
}
|
||||
|
||||
// 存在 Session ID
|
||||
if (p_msg->Msg.standard_header.htyp.WSID)
|
||||
fprintf(p_file, "%d,", p_msg->Msg.standard_header_extra.seid);
|
||||
else
|
||||
fprintf(p_file, "N/A,");
|
||||
|
||||
// 输出 Type 、Subtype 、Mode 、#Args
|
||||
if (p_msg->Msg.standard_header.htyp.UEH)
|
||||
{
|
||||
const char *Type_str[] = {"log", "trace", "network", "control"};
|
||||
const char *SubType_Str[][0xF] = {
|
||||
// LOG
|
||||
{"fatal", "error", "warn", "info", "debug", "verbose", nullptr},
|
||||
// Trace
|
||||
{"variable", "function in", "function out", "state", "vbf", nullptr},
|
||||
// Network
|
||||
{"IPC", "CAN", "FlexRay", "Most", "Ethernet", "SOME/IP", "0x7", "0x8", "0x9", "0xA", "0xB", "0xC", "0xD", "0xE", "0xF"},
|
||||
// Control
|
||||
{"Request", "response", nullptr},
|
||||
};
|
||||
|
||||
// Type && Subtype
|
||||
fprintf(p_file, "%s,", Type_str[p_msg->Msg.extendedheader.msin.MSTP]);
|
||||
fprintf(p_file, "%s,", SubType_Str[p_msg->Msg.extendedheader.msin.MSTP][(p_msg->Msg.extendedheader.msin.MTIN - 1) % 0xF]);
|
||||
|
||||
// Mode ** #Args
|
||||
fprintf(p_file, "%s,", p_msg->Msg.extendedheader.msin.VERB ? "verbose" : "non-verbose");
|
||||
fprintf(p_file, "%d,", p_msg->Msg.extendedheader.noar);
|
||||
}
|
||||
}
|
||||
|
||||
// Payload概览行
|
||||
fprintf(p_file, ",");
|
||||
|
||||
// 逐个打印 Payload
|
||||
for (size_t count = 0; count < p_msg->Msg.payload_length; count++)
|
||||
fprintf(p_file, "%0X,", p_msg->Msg.payload_buffer[count]);
|
||||
|
||||
p_msg = p_msg->p_next;
|
||||
fseek(p_file, -1, SEEK_CUR);
|
||||
fprintf(p_file, "\r\n");
|
||||
|
||||
p_msg = p_msg->p_next;
|
||||
}
|
||||
|
||||
return DLT_Type::DLT_ERROR_NONE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user