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

add a method to RawMaster to send and receive PDUs token-less #12

Open
jimy-byerley opened this issue Jul 14, 2023 · 0 comments
Open

add a method to RawMaster to send and receive PDUs token-less #12

jimy-byerley opened this issue Jul 14, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@jimy-byerley
Copy link
Owner

jimy-byerley commented Jul 14, 2023

At the moment, it is only possible to send PDUs by reserving a token on the master side, and this token ensures that the answer is exclusively received by the async task that sent the PDU. This is great for purposed exchanges like configurations or imperative commands.
This is less relevant however for cyclic communication, where we might want to send hundreds of PDUs in a sending loop without bothering about reserving free tokens and receive any incoming PDUs in an other without care of the order.

There is two implementation options:

1. add send and receive functions

  • the tokenized (current) way: RawMaster::pdu(request) -> answer
  • the untokenized send: RawMaster::send(request)
    will send with null token and not wait for the answer
  • the untokenized receive: RawMaster::receive(request) -> answer
    will not send any request but wait for an answer matching that request

2. add any receive function and allow breaking PDU awaiting

  • the tokenized (new) way: RawMaster::pdu(request, wait: bool) -> Option<answer>
    will have an option for awaiting or not
  • the untokenized receive: RawMaster::any(request) -> answer

Option 1 seems better but duplicates some code

use case

Since an ethercat segment can contains up to 2**16 slaves, there can be a delay between sending a PDU and receiving an answer larger than the operation cycle period (1ms or less). So we need to send updates of logical memory at the desired cycle period and use the answer only when it comes back, possibly hundreds of cycle latter.

// realtime exchange loop
(
  async { loop {
    cycle.tick().await;
    group.send()  // sending a LRW but not waiting for the anwser and not tokenized
  }},
  async { loop {
    group.receive().await;  // awaiting the next incoming LRW, without care of when the request was sent
    // do stuff with it
  }},
).join().await;
@jimy-byerley jimy-byerley added the enhancement New feature or request label Jul 14, 2023
@jimy-byerley jimy-byerley added this to the v1 milestone Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant