Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Implement support for container and CAN-FD frames #151

Closed
wants to merge 4 commits into from

Conversation

AlexMicWalz
Copy link

  • implement support for container-frames,
  • implement support for CAN-FD frames,
  • adapt output message for loading files.

Alexander Walz <[email protected]>, on behalf of MBition GmbH.
Provider Information

Signed-off-by: Alexander Walz <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Alexander Walz <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
Signed-off-by: Alexander Walz <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
@AlexMicWalz
Copy link
Author

Hello, meanwhile I've also signed the Eclipse Contributor Agreement, hope this helps.
Kind regards, Alex

@lukasmittag
Copy link
Contributor

to get the CI clear you maybe need to rebase and force push or add another commit

@andlaus
Copy link

andlaus commented Nov 3, 2023

is there a way to fix these pesky formatting errors automatically? (something like ruff --fix, but flake8 does not seem to have such a feature...)

@SebastianSchildt
Copy link
Contributor

SebastianSchildt commented Nov 3, 2023

is there a way to fix these pesky formatting errors automatically? (something like ruff --fix, but flake8 does not seem to have such a feature...)

yes there is!

You do pip install pre-commit  in the working directory, so then when you commit, it will check, and fail if something is wrong. You can also run pre-commit manually in the terminal in your working directory. it will then modify the files so they match style. Then you just need to git add them to accept that, and commit will work, and also the CI check after push.

@andlaus
Copy link

andlaus commented Nov 3, 2023

I did this for the HEAD of this PR, but flake8 still complains:

kuksa.val.feeders/dbc2val|7a0f8a2... > pre-commit && flake8 .
Trim Trailing Whitespace.............................(no files to check)Skipped
Fix End of Files.....................................(no files to check)Skipped
Check Yaml...........................................(no files to check)Skipped
Check for added large files..........................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
./dbcfeederlib/canreader.py:35:110: E231 missing whitespace after ':'
./dbcfeederlib/canreader.py:35:115: E252 missing whitespace around parameter equals
./dbcfeederlib/canreader.py:35:116: E252 missing whitespace around parameter equals
./dbcfeederlib/canreader.py:35:121: E501 line too long (122 > 120 characters)
./dbcfeederlib/canreader.py:47:121: E501 line too long (132 > 120 characters)
./dbcfeederlib/canreader.py:90:13: F841 local variable 'e' is assigned to but never used
./dbcfeederlib/canreader.py:103:41: E231 missing whitespace after ','
./dbcfeederlib/canreader.py:108:5: E303 too many blank lines (2)
./dbcfeederlib/dbcparser.py:121:1: W293 blank line contains whitespace
./dbcfeederlib/dbcreader.py:35:121: E501 line too long (131 > 120 characters)

the various sub-commands for pre-commit (e.g., pre-commit run) also do not seem to make a difference. what am I missing?

@andlaus
Copy link

andlaus commented Nov 3, 2023

(note: runninng black makes flake8 happy, bit it leads to a ton of irrelevant formatting changes. I suppose you're not fond of these?)

@SebastianSchildt
Copy link
Contributor

Ahh, I think the issue is, you committed already, hence when you run pe-commit it always determines (no files to check)Skipped.

I guess @erikbosch knows more about the pre-commit hook, but as an ugly way try this

  • Touch you files again, i.e. add a space somehwere
  • git add them
  • run pre-commit
  • it should have modified your files, check whether you like it
  • git add again
  • commit

@andlaus
Copy link

andlaus commented Nov 3, 2023

okay, tried that: unfortunately, it didn't change anything. That said, what formatter tool is pre-commit supposed to call in order to fix the coding style? (it could be any of yapf, black, autopep8, ...)

@SebastianSchildt
Copy link
Contributor

For the config see https://github.com/eclipse/kuksa.val.feeders/blob/main/.pre-commit-config.yaml and https://github.com/eclipse/kuksa.val.feeders/blob/main/.flake8

I am currently not sure whether the pre-commit flake part will also modify the source. The whitespace checker definitely does. If in doubt I think @erikbosch might support by adding a commit on top of your work

Apart from "style and beauty", functionality wise @erikbosch might have a say and @sophokles73 as your are an active user of this provider, you might want to check if this still work for your use cases

else:
# handle container frame
for tmp in decode:
if isinstance(tmp[1],bytes):
Copy link
Contributor

Choose a reason for hiding this comment

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

FMPOV a comment regarding the underlying condition that you are checking here would make this easier to understand
Also, there is a space character missing after the comma ...

@@ -451,6 +452,11 @@ def _get_command_line_args_parser() -> argparse.ArgumentParser:
action="store_true",
help="Use SocketCAN (overriding any use of --dumpfile)",
)
parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

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

this new parameter should probably also be documented in the README

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, and we should better discuss if we think this one need to be controllable by environment variable and config file as well, similar to how canport is managed.

if args.canport:
        canport = args.canport
    elif os.environ.get("CAN_PORT"):
        canport = os.environ.get("CAN_PORT")
    else:
        canport = config.get(CONFIG_SECTION_CAN, CONFIG_OPTION_PORT, fallback=None)

@sophokles73
Copy link
Contributor

@AlexMicWalz this looks good to me :-) It would be great if you could also add a unit test checking the FD frame parsing/handling ...

@erikbosch
Copy link
Contributor

erikbosch commented Nov 6, 2023

The current status of the pre-commit checks is that we have not prescribed/proposed any tool to fix the findings. Any suggestion on a good candidate is welcome, as we then could discuss if we should make that one the "recommended" formatting tool. But that I assume would include work on agreeing/defining settings for formatting, preferably in a standardized format understandable by multiple IDEs/tools.

Until now I have fixed findings manually in my PRs. As long as you change files that have been touched recently that is typically not too cumbersome as it only concerns the lines you have changed. If you touch files that has not been modified since pre-commit was introduced it may mean more work, as we have used a lazy approach for the pre-commit checks and have not checked/fixed all files, but instead do it when touching files.

@erikbosch
Copy link
Contributor

I did some smoketest using the same logfile as we use for release testing and did not observe anything odd. I think we shall add support for defining this in at least config file as we have said in VSS_project that all settings should be available in config file, but command line arg shall have precedence.

@andlaus
Copy link

andlaus commented Nov 7, 2023

I did some smoketest using the same logfile as we use for release testing and did not observe anything odd

testing for container frames is quite a bit of effort because DBC does not support this feature (you need to use an ARXML file). We'll look into providing a unit test...

@andlaus
Copy link

andlaus commented Nov 7, 2023

The current status of the pre-commit checks is that we have not prescribed/proposed any tool to fix the findings. Any suggestion on a good candidate is welcome, as we then could discuss if we should make that one the "recommended" formatting tool.

the approach used by odxtools is to run YAPF as part of the CI and bail out if any discrepancy is detected. To fix such issues a small shell script is provided...

@sophokles73
Copy link
Contributor

testing for container frames is quite a bit of effort because DBC does not support this feature (you need to use an ARXML file). We'll look into providing a unit test...

Maybe you can use a similar approach as in https://github.com/eclipse/kuksa.val.feeders/blob/91c3091a8918eed7d79500892ba8d894930b7a67/dbc2val/test/test_readers/test_readers.py#L72

without the need for a DBC file.

@AlexMicWalz
Copy link
Author

I have fixed the findings of flake8.
Unit-test is in the making.

@erikbosch
Copy link
Contributor

We are migrating CAN Provider (dbcfeeder) to a new repo. Discussion may continue in this PR, but there is no point in updating this PR, if so rather create a new PR in the new repository.

@SebastianSchildt
Copy link
Contributor

@erikbosch what is the state of this, would be a pity to let it rot. Could you or maybe the @andlaus make an effort to create move the PR to the new location? I feel it was already (almost?) good enough content wise

@andlaus
Copy link

andlaus commented Jan 11, 2024

as far as I remember the main showstopper here was the fact that there was no unit test. I promised one, but when I did so, I assumed that there was a unit test for the (non-container aware) DBC feeder. seems like this assumption was not correct and after bouncing my head against making one from scratch I gave up. (the problem is how to check that a given CAN signal gets exposed on the Kuksa side without having to set up a metric ton of servers, databases, etc.)

I came to the conclusion that it is best to tackle the implementation of end to end unit tests for the feeders in another PR sometime in the future. (I'll go over this PR to make it merge-ready tomorrow or early next week.)

@andlaus
Copy link

andlaus commented Jan 12, 2024

transferred the PR to the new repository: eclipse-kuksa/kuksa-can-provider#6

this PR can be closed AFAICS. (I don't have permission to do so...)

@erikbosch erikbosch closed this Jan 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants