Skip to content

Conversation

pd0wm
Copy link
Contributor

@pd0wm pd0wm commented Sep 3, 2024

Before:

    let mut isotp_config = IsoTPConfig::new(0, Identifier::Standard(0x7a1));
    isotp_config.padding = config.padding;
    isotp_config.fd = config.fd;
    isotp_config.ext_address = config.ext_address;
    isotp_config.timeout = std::time::Duration::from_millis(1000);
    isotp_config.max_dlen = config.max_dlen;

After:

  let isotp_config = IsoTPConfig::default()
        .tx(Identifier::Standard(0x7a1))
        .padding(config.padding)
        .fd(config.fd)
        .ext_address(config.ext_address)
        .max_dlen(config.max_dlen);

Maybe use separate builder type containing the offset? This would mean you always have to call .build() to finish the type. Now you could try setting the offset before the tx id, or the rx id before the tx id, and it would't work. E.g. the following fails silently:

  let isotp_config = IsoTPConfig::default()
        .offset(8)
        .tx(Identifier::Standard(0x7a1))

or

  let isotp_config = IsoTPConfig::default()
        .rx(Identifier::Standard(0x123))
        .tx(Identifier::Standard(0x7a1))

Check out how other libraries do this. E.g. https://github.com/seanmonstar/reqwest/blob/master/src/async_impl/client.rs

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.

1 participant