-
Notifications
You must be signed in to change notification settings - Fork 31
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
Memory Config Timeout Support (Datagrams) #809
base: master
Are you sure you want to change the base?
Conversation
bakerstu
commented
Jan 16, 2025
•
edited
Loading
edited
- Added support on the server side.
- Added support on the client side.
- Added unit test coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, will do some testing over this weekend.
@bobjacobsen can you confirm if JMRI is similarly handling timeout hints on datagram responses so I can test through that as well?
@atanisoft I'm away from my setup at the moment, but I don't think JMRI (OpenLCB_Java) is doing this correctly. Will check, but it might be a day or two. If not, that needs to be fixed. There are some other things in the handling of the memory configuration protocol that need fixing too, so I'll try to do them all at the same time. |
With the latest code I'm seeing the following warning/deprecation notice:
Not sure how best we should handle this other than using casting to an integer and then back to ResponseFlag. |
@atanisoft This is a good find. We should fix this. I can think of three possible solutions:
I very much would like to cleanup these enumerated types. I think they are not very well laid out, and could have been better designed. That said, I think it is too much of a change at this point. Therefore, I prefer solution 1. It is brute force, but at least self documenting in what the operation is doing. WDYT? |
I'm fine with opting for static_cast for now and seeing what we can do outside this PR as a better fit. I know C++20 has a bit better handling of enums, which may rely on extending standard variable types like uint8_t or similar.
|
"src/openlcb/MemoryConfig.hxx:1011:43: warning: bitwise operation between different enumeration types ‘openlcb::DatagramClient::ResponseFlag’ and ‘openlcb::DatagramDefs::Flag’ is deprecated [-Wdeprecated-enum-enum-conversion] 1011 | DatagramClient::REPLY_PENDING | space->get_write_timeout());"
I added the static_cast for both read and write timeout cases. |
src/openlcb/MemoryConfigClient.hxx
Outdated
@@ -402,7 +405,8 @@ private: | |||
|
|||
Action read_response_timeout() | |||
{ | |||
if (responseCode_ & DatagramClient::OPERATION_PENDING) | |||
if (responseCode_ & DatagramClient::OPERATION_PENDING || | |||
!timer_.is_triggered()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the read finishes upon the first attempt, the timer is never started.
If this code is really needed, then we have to call timer_.set_triggered() on that path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is definitely required. Unit testing proves that. I think modifying the statement to (isWaitingForTimer_ == true && !timer_.is_triggered()") is an adequate fix though.
…ay replay and no pending flag.