-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support payload argument separation similar to DltViewer #10
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,7 +38,7 @@ export const serviceIds: string[] = ["", "set_log_level", "set_trace_status", "g | |||||
// not covered: | ||||||
/* | ||||||
#define DLT_SERVICE_ID_UNREGISTER_CONTEXT 0xf01 < Service ID: Message unregister context | ||||||
#define DLT_SERVICE_ID_CONNECTION_INFO 0xf02 < Service ID: Message connection info | ||||||
#define DLT_SERVICE_ID_CONNECTION_INFO 0xf02 < Service ID: Message connection info | ||||||
#define DLT_SERVICE_ID_TIMEZONE 0xf03 < Service ID: Timezone | ||||||
#define DLT_SERVICE_ID_MARKER 0xf04 < Service ID: Timezone | ||||||
#define DLT_SERVICE_ID_CALLSW_CINJECTION 0xFFF < Service ID: Message Injection (minimal ID) | ||||||
|
@@ -93,6 +93,7 @@ export class DltMsg { | |||||
readonly timeAsNumber: number; // time in ms. Date uses more memory! | ||||||
get timeAsDate(): Date { return new Date(this.timeAsNumber); } | ||||||
|
||||||
readonly payloadArgSeparator: string; | ||||||
ChrisRBe marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could this work? |
||||||
// parsed from data: | ||||||
readonly mcnt: number; | ||||||
private _htyp: number; | ||||||
|
@@ -114,7 +115,7 @@ export class DltMsg { | |||||
lifecycle: DltLifecycleInfo | undefined = undefined; | ||||||
decorations: Array<[vscode.TextEditorDecorationType, Array<vscode.DecorationOptions>]> = []; | ||||||
|
||||||
constructor(storageHeaderEcu: string, stdHdr: any, index: number, timeAsNumber: number, data: Buffer) { | ||||||
constructor(storageHeaderEcu: string, stdHdr: any, index: number, timeAsNumber: number, data: Buffer, sepPayArgs?: boolean) { | ||||||
this.index = index; | ||||||
this.timeAsNumber = timeAsNumber; | ||||||
|
||||||
|
@@ -173,6 +174,8 @@ export class DltMsg { | |||||
} | ||||||
this._eac = getEACFromIdx(getIdxFromEAC(eac)) || eac; | ||||||
|
||||||
this.payloadArgSeparator = sepPayArgs ? " ": ""; | ||||||
|
||||||
const payloadOffset = DLT_STORAGE_HEADER_SIZE + stdHeaderSize + (useExtHeader ? DLT_EXT_HEADER_SIZE : 0); | ||||||
this._payloadData = data.slice(payloadOffset); | ||||||
assert.equal(this._payloadData.byteLength, stdHdr["len"] - (payloadOffset - DLT_STORAGE_HEADER_SIZE)); | ||||||
|
@@ -292,7 +295,7 @@ export class DltMsg { | |||||
argOffset += 2; | ||||||
const rawd = this._payloadData.slice(argOffset, argOffset + lenRaw); | ||||||
this._payloadArgs.push({ type: Buffer, v: Buffer.from(rawd) }); // we make a copy here to avoid referencing the payloadData that we want to release/gc afterwards | ||||||
this._payloadText += rawd.toString("hex"); | ||||||
this._payloadText += rawd.toString("hex") + this.payloadArgSeparator; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's not the only place where the space is missing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard to tell. What I would say: the current implementation, or rather, simply adding a space at this position did not seem to add additional spaces at the end in vscode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sadly I miss good examples. Could write a small test app that creates those. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as the consequence? |
||||||
argOffset += lenRaw; | ||||||
} else { break; } // todo VARI, FIXP, TRAI, STRU | ||||||
} | ||||||
|
@@ -340,7 +343,7 @@ export class DltMsg { | |||||
case 4: | ||||||
case 5: | ||||||
case 6: | ||||||
case 7: // info about reg. appids and ctids with log level and trace status info and all text. descr. | ||||||
case 7: // info about reg. appids and ctids with log level and trace status info and all text. descr. | ||||||
{ // todo could use few binaryparser here... | ||||||
const hasLogLevel: boolean = (respCode === 4) || (respCode === 6) || (respCode === 7); | ||||||
const hasTraceStatus: boolean = (respCode === 5) || (respCode === 6) || (respCode === 7); | ||||||
|
@@ -571,11 +574,12 @@ function dltWriteExtHeader(buffer: Buffer, offset: number, extH: DltExtHeader) { | |||||
|
||||||
export class DltParser { | ||||||
|
||||||
parseDltFromBuffer(buf: Buffer, startOffset: number, msgs: Array<DltMsg>, posFilters?: DltFilter[], negFilters?: DltFilter[], negBeforePosFilters?: DltFilter[], msgOffsets?: number[], msgLengths?: number[]) { // todo make async | ||||||
parseDltFromBuffer(buf: Buffer, startOffset: number, msgs: Array<DltMsg>, sepPayArgs: boolean, posFilters?: DltFilter[], negFilters?: DltFilter[], negBeforePosFilters?: DltFilter[], msgOffsets?: number[], msgLengths?: number[]) { // todo make async | ||||||
let skipped: number = 0; | ||||||
let remaining: number = buf.byteLength - startOffset; | ||||||
let nrMsgs: number = 0; let offset = startOffset; | ||||||
const startIndex: number = msgs.length ? (msgs[msgs.length - 1].index + 1) : 0; // our first index to use is either prev one +1 or 0 as start value | ||||||
const separatePayloadArgs: boolean = sepPayArgs ? sepPayArgs : false; | ||||||
while (remaining >= MIN_DLT_MSG_SIZE) { | ||||||
const storageHeader = dltParseStorageHeader(buf, offset); | ||||||
if (storageHeader.pattern === DLT_STORAGE_HEADER_PATTERN) { | ||||||
|
@@ -591,7 +595,7 @@ export class DltParser { | |||||
|
||||||
if (len >= MIN_STD_HEADER_SIZE) { | ||||||
try { | ||||||
const newMsg = new DltMsg(storageHeader.ecu, stdHeader, startIndex + nrMsgs, timeAsNumber, buf.slice(msgOffset, offset)); | ||||||
const newMsg = new DltMsg(storageHeader.ecu, stdHeader, startIndex + nrMsgs, timeAsNumber, buf.slice(msgOffset, offset), separatePayloadArgs); | ||||||
// do we need to filter this one? | ||||||
let keepAfterNegBeforePosFilters: boolean = true; | ||||||
if (negBeforePosFilters?.length) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reversing the logic? The target should be same output as dltviewer.
The problem are existing users that have filters with payload. We could introduce the flag as
"legacyPayloadDecoding", default false, at startup check whether there are existing filters with payload and ask/inform user to check his filters or enable the option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In lights of your later comments regarding memory consumption etc. this is probably the better solution.
One question remains: How do you recognize "legacy" filters? It would be complete guesswork as especially the payload filter is in the end only a string regex. What would be the identifier?
Of the top of my head? Add a completely redundant version field to either the filter section or each filter. If the field is not available, show a message stating that there are maybe incompatible filters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, as soon as there is any filter with a payload/payloadregex I'd show the message and ask the user. Filters with ecu/apid/ctid,... are not impacted.