Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisRBe
Copy link

@ChrisRBe ChrisRBe commented Jan 8, 2021

This is hopefully a fitting implementation for #9.

Adds a config item to specify if payload args should be separated or not; defaults to false.
Slight interface change required imho to support this payload separation.

Please note: I haven't installed a local build environment, so .. it could work. Probably not. First time typescripting...

@mbehr1
Copy link
Owner

mbehr1 commented Jan 9, 2021

Thx! :-)
I'll review the PR. Need to be extremely careful with any performance or memory impacts on processing huge dlt files.
I like the config switch but I'd prefer if with the new switch the output is 1:1 compliant with dltviewer. I guess there are more differences than just the missing space, or?
Does dltviewer add a space between all args?
Does it add a space after each arg or only if some more args are following?
Does it add a space even after string args?
...?

@@ -95,6 +95,7 @@ This extension contributes the following settings:
* `dlt-logs.fileExtensions`: Specifies the file extensions to use for file open dialog. Defaults to .dlt|.DLT.
* `dlt-logs.maxNumberLogs`: Specified the maximum number of DLT logs that get displayed in one page. If more logs exist - considering the active filters - a paging mechanism is in place that starts rendering a new page at 4/5th of the page boundary. Searching is limited to the visible page. Defaults to 0.4mio logs. Depending on your machines performance/RAM you might reduce/increase this. Best case is to find a limit/config where all logs fit into that range (use filter!).
* `dlt-logs.reReadTimeout`: Specified the timeout in ms after opening the file before starting to parse the dlt file. If the file doesn't open, increase this to e.g. 5s.
* `dlt-logs.separatePayloadArgs`: Separate payload arguments with a space (' ') character. Default is false to not break existing filters.
Copy link
Owner

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?

Copy link
Author

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?

Copy link
Owner

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.

@@ -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;
Copy link
Owner

Choose a reason for hiding this comment

The 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?
And: does dltviewer add a space at the end?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to tell.
Do you have an easy to use DLT example that uses all different DLT_LOG functions to write messages? Plus, I'm not really that good at reading the dltviewer code to answer that clearly.

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.

Copy link
Owner

Choose a reason for hiding this comment

The 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.
I might have some code to remove whitespace at end ;-) (will take a look)
I can check the dltviewer code and try to understand the rules implemented there.

Copy link
Owner

@mbehr1 mbehr1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see inline comments.

@mbehr1
Copy link
Owner

mbehr1 commented Jan 9, 2021

btw: I could configure the GitHub workflow to build a .vsix install package for PRs as well (to avoid the need to build locally)?

@ChrisRBe
Copy link
Author

ChrisRBe commented Jan 9, 2021

Thx! :-)
I'll review the PR. Need to be extremely careful with any performance or memory impacts on processing huge dlt files.
I like the config switch but I'd prefer if with the new switch the output is 1:1 compliant with dltviewer. I guess there are more differences than just the missing space, or?

uff. good question. You don't really see the formatting in dltviewer easily and I'm not good at reading the dltviewer source code to easily point to any possible differences.

Does dltviewer add a space between all args?

Going out on a limb here: Yes, it does. Having an example dlt file using all possible argument combinations would be easier.

Does it add a space after each arg or only if some more args are following?
Does it add a space even after string args?

In the cases that I have seen there is a space after each arg with the last arg probably not being ended with a space.

...?

One thing comes to mind: byte representation. In the current extension version, payload containing bytes are not split on byte size (0000 vs. 00 00). Apart from that... good question.

@ChrisRBe ChrisRBe force-pushed the feature/separatePayloadArgs branch from 533a73c to 79cbc04 Compare January 9, 2021 11:37
@@ -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;
Copy link
Author

@ChrisRBe ChrisRBe Jan 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly payloadArgSeparator: string;
static payloadArgSeparator = vscode.workspace.getConfiguration().get<boolean>('dlt-logs.legacyPayloadDecoding') ? "" : " "; // default behaviour of legacyPayloadDecoding is false, add a space character in that case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this work?

@@ -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;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this._payloadText += rawd.toString("hex") + this.payloadArgSeparator;
this._payloadText += rawd.toString("hex") + DltMsg.payloadArgSeparator;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the consequence?

@mbehr1 mbehr1 force-pushed the master branch 13 times, most recently from 260cfc9 to b6cf392 Compare April 23, 2022 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants