Hi,<br><br>I have been working with etherlab recently and got ethercat working up and everything is fine.<br><br>There is a delay issue however that I'm concerned about. As seen in the examples, the way you read from the network is like this (imagine you are interested in reading sensor values):<br>
<br>while (running)<br>{<br> master receive<br> domain process<br><br> read data<br><br> domain queue<br> master send<br><br> rt wait period<br>}<br><br>in which case you assume that the task period is long enough to be sure that the packet sent in the bottom of the loop has returned when the loop starts again and so you can receive the data.<br>
<br>However, I was wondering if it is possible to, instead of taking an upper bound of the time, simply check to see whether the data has arrived or not. After some research, I got to this code:<br><br>while (running)<br>
{<br>
domain queue<br>
master send<br>
<br> do<br> {<br> sleep a little<br><br> master receive<br> domain process<br><br> ecrt_domain_state(domain, &state);<br><br> } while (state.wc_state != EC_WC_COMPLETE && !timeout)<br>
<br>
read data<br>
<br>
rt wait period<br>
}<br>
<br>
This way, after sending the packet, you would read the data as soon as they arrive.<br><br>The problem with this was that, besides the fact that early calls to master_receive (or domain_process) generated a huge amount of warning about working counter changing to 0/1 and back to 1/1 again, the kernel started to at some point keep crashing.<br>
<br>I would like to know, how can I detect when the packet has arrived without knowing an upper bound about it and wait blindly by that much?<br><br>Note: This is most useful for me for this reason:<br><br>I may have different threads requesting data from a domain which includes different sensors. Each type of sensor produces data at a different rate and I would like to read the data at different rates to. I don't want to (and I don't think is even possible) to have different threads requesting data from the same domain (because they may send the packet while the one for the previous thread hasn't yet arrived). So what I want to is this:<br>
<br>ethercat coordinator:<br><br>domain_updating = no<br><br>send_request_for_domain<br>{<br> if (domain_updating == no)<br> {<br> domain_updating = yes<br> domain queue<br> master send<br>
}<br> // else, do nothing, it is being updated!<br>}<br><br>receive_from_domain()<br>{<br> while (ecrt_domain_data_not_yet_received) // this is the function I need<br> wait<br> domain_updating = no<br> // data available<br>
}<br><br>and then, each thread that wants something from the domain would look like this:<br><br>thread:<br> send_request_for_domain<br> receive_from_domain<br> read data<br><br>This way, if two threads call send_request_for_domain at the same time, only one of them would actually do the<br>
<br>domain queue<br>master send<br><br>and both of them use the result.<br><br>I would appreciate it if you could shed some light on this matter.<br>Shahbaz<br>