-
Notifications
You must be signed in to change notification settings - Fork 77
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
SerialCommunicationHub always waits for timeout before returning the result #550
Comments
The original implementation returned immediately when the expected number of bytes were received, it only waited for the timeout if bytes were missing. Not sure if that broke with a recent commit or so |
I believe this check: everest-core/modules/SerialCommHub/tiny_modbus_rtu.cpp Lines 301 to 305 in c144d56
should be done after this block, not before: everest-core/modules/SerialCommHub/tiny_modbus_rtu.cpp Lines 307 to 310 in c144d56
Because, in the current code, if you have reached the buffer space limit, you wait one more select timeout to break out of the loop, instead of breaking out immediately (since no more data is being read anyway). This is just a visual review, untested. |
As far as I see we always request the response of the maximum possible size everest-core/modules/SerialCommHub/tiny_modbus_rtu.cpp Lines 443 to 444 in c144d56
So we always will wait for time out if we want shorter response. |
The read_reply function will not always fill the buffer, it is just the maximum size |
Correct, this should be fixed. It should however only occur on transfers with 261 bytes, everything smaller will always have the "within_message_timeval" message timeout |
The default is configurable with a default of 100ms. In many implementations this can probably be reduced quite a bit, but I do not have enough hardware to find a good value. It is the inter character timeout once the peer started to send the reply message. It should be really quick. So for now I'd suggest to just reduce the 100ms timeout in your config if that is too long. You should be able to keep the initial timeout on a larger value. My guess is your power meter takes a long time to respond, but once it has sent the first bytes it will be quick sending the remaining bytes right? In this case, it should not always wait for the first timeout: The select should return whenever there is at least one byte available for reading, then the reading should not block and return some bytes (let's assume it was the complete reply). So there is always the "within_message_timeout_ms" timeout at the end, but it is not very easy to get rid of this one, as the read_reply does not know how many bytes to read. But since this is short, I do not think it is an issue. @golovasteek Did you find another solution in the mean time? Would that resolve your issue? |
I was investigating why reading the values from the meter always take a while. And it looks like the tiny_modbus_rtu is implemented in the way, that we always return when the response timeout is reached and not earlier.
This maybe not a problem with quick devices, but some devices like Bauer Meter, may have long response time sometimes. So we need to keep the timeout large.
Expected behaviour:
The text was updated successfully, but these errors were encountered: