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

Get spns of a pgn? #26

Open
abalmos opened this issue Mar 20, 2021 · 1 comment
Open

Get spns of a pgn? #26

abalmos opened this issue Mar 20, 2021 · 1 comment

Comments

@abalmos
Copy link

abalmos commented Mar 20, 2021

I am working on a tool that parses a can stream based on a dbc file in real time. I don't really have specific messages of interests (like the example), but rather, I want to parse all can frames that match to DBC.

Something like:

let lib = PgnLibrary::from_dbc_file("./j1939.dbc");

loop {
  let msg = s.recv()?;

  let Some(pgnDef) = lib.get_pgn(msg.pgn) {
    let d = pgnDef.spns.iter().map(|(s, def)| (s, def.parse_message(msg.data)?));
  }
  
  // Export `d` to database

}

Currently this does not compile because spns is a private member. Do you intend to support this? If so, I would be willing to offer a PR based on how you want to approach it.

@jmagnuson
Copy link
Owner

Hey, thanks for the interest and good idea! I eventually wanted to get to #17 to speed up SPN lookups, but that would probably entail breaking the internal PGN/SPN model. That said, do you see needing any other functionality beyond iterating the SPN map? Otherwise, I like the idea of exposing an API to do this, maybe something like:

impl PgnDefinition {
    ...
    pub fn spns() -> impl Iterator<Item = (&String, &SpnDefinition)> { ... }

which is basically just a proxy for pgnDef.spns.iter(), but should be pretty semver-resilient, I think.

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

No branches or pull requests

2 participants