Skip to content

Conversation

@sou1hacker
Copy link
Contributor

@sou1hacker sou1hacker commented Apr 27, 2020

Changes

  • Added support for new formats for CAN remote frames
  • Reworked and cleaned existing implementation
  • Some minor fixes (e.g. dlc != len(data) for FD frames)
  • Added parsing ASCII header parsing

Time analysis for both new & old implementations

We tested with an ASCII logs file with ~ 7 million messages (both classic CAN & FD) across 8 channels.
Old implementation: Took an average of 128 seconds across 3 runs
New implementation: Took an average of 117 seconds across 3 runs

@sou1hacker sou1hacker mentioned this pull request Apr 27, 2020
Co-Authored-By: pierreluctg <pierreluctg@gmail.com>
@codecov
Copy link

codecov bot commented Apr 27, 2020

Codecov Report

Merging #820 into develop will increase coverage by 0.13%.
The diff coverage is 96.80%.

@@             Coverage Diff             @@
##           develop     #820      +/-   ##
===========================================
+ Coverage    69.81%   69.95%   +0.13%     
===========================================
  Files           70       70              
  Lines         6603     6640      +37     
===========================================
+ Hits          4610     4645      +35     
- Misses        1993     1995       +2     

@sou1hacker sou1hacker marked this pull request as ready for review April 27, 2020 17:12
@sou1hacker sou1hacker requested a review from pierreluctg April 27, 2020 18:21
sou1hacker and others added 7 commits April 27, 2020 14:44
Co-Authored-By: pierreluctg <pierreluctg@gmail.com>
Co-Authored-By: pierreluctg <pierreluctg@gmail.com>
Co-Authored-By: pierreluctg <pierreluctg@gmail.com>
@pierreluctg pierreluctg added enhancement file-io about reading & writing to files labels Apr 28, 2020
self._converted_base = self._check_base(base)
self.date = None
self.timestamps_format = None
self.internal_events_logged = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem to be used anywhere. It seems to just indicate the presence of the following line:

internal events logged

Can you help me understand why this needs to be exposed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@karlding The line can be either "internal events logged" or "no internal events logged". It may be useful in the future as we add support for more kinds of frames/events in the AscReader.

_, base, _, timestamp_format = line.split()
except ValueError:
raise Exception("Unsupported header string format: {}".format(line))
self.base = base
Copy link
Collaborator

Choose a reason for hiding this comment

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

The __init__ takes a given base, whereas here right after that we're potentially overwriting it. What happens if the constructor specified hex, but the file is dec?

If you were intending to use this value from the .asc to validate, I don't think you should've overwritten self.base on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@karlding In both the current and previous implementations, we were ignoring the base passed on to the constructor and using the base defined in the ASCII logs file to parse all the messages. It seems accurate to set base to the value actually used during parsing so I think overwriting it is fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, if the idea is for the ASCReader to parse the value from the file, then we should probably just deprecate those parameters in __init__ and raise a DeprecationWarning or something.

I don't have access to Vector's tools so I can't check, but are there cases where an ASC file is considered valid but it doesn't specify a base?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps the only use case I can think of is when we have a logs file split across two ASCII files. Not completely sure if the header is present in files other than the first file. If the intention is perhaps to read only the second file, then having a manually specified base can be useful. Your call.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's just leave this for now then. If someone has a use case for this, we can revisit it at that point.

@karlding
Copy link
Collaborator

Out of curiosity, do you have a sample file with some of the missing functionality that the current samples don't have? For example, I don't think the current ASC has any examples of error frames (and I think RTR frames? not sure if there's anything else). If so, could you include them?

It would be nice to have specific tests for each type of frame using "golden files" to test parsing 🙂

Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

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

Looks good to me. I didn't test against an actual file though.

@sou1hacker
Copy link
Contributor Author

@karlding Added some examples for CAN / CANFD error, remote frames, etc to the current ASC logs file.

@karlding
Copy link
Collaborator

karlding commented May 2, 2020

Thanks for adding the additional frames!

I think it might make test-writing easier if we split out the different frames into their own separate files, similar to what exists for the BLF format? That way we can also write tests that check that the parser is working by asserting on the type of frame that is converted to a Message, instead of one giant file (ie. is_remote_frame, is_fd). What do you think?

@sou1hacker
Copy link
Contributor Author

Thanks for adding the additional frames!

I think it might make test-writing easier if we split out the different frames into their own separate files, similar to what exists for the BLF format? That way we can also write tests that check that the parser is working by asserting on the type of frame that is converted to a Message, instead of one giant file (ie. is_remote_frame, is_fd). What do you think?

Will look at BLF and replicate here.

Copy link
Collaborator

@karlding karlding left a comment

Choose a reason for hiding this comment

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

Thanks for adding the extra tests!

@hardbyte hardbyte merged commit 30ef0c3 into hardbyte:develop May 12, 2020
@hardbyte hardbyte added this to the 4.0 Release milestone May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement file-io about reading & writing to files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants