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

Memory Config Timeout Support (Datagrams) #809

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

bakerstu
Copy link
Owner

@bakerstu bakerstu commented Jan 16, 2025

  • Added support on the server side.
  • Added support on the client side.
  • Added unit test coverage.

@bakerstu bakerstu requested a review from atanisoft January 16, 2025 23:31
Copy link
Collaborator

@atanisoft atanisoft left a 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?

src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfigClient.hxx Outdated Show resolved Hide resolved
@bobjacobsen
Copy link
Collaborator

bobjacobsen commented Jan 17, 2025

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.

@bakerstu bakerstu changed the title [WIP] Memory Config Timeout Support (Datagrams) Memory Config Timeout Support (Datagrams) Jan 18, 2025
@bakerstu bakerstu requested a review from balazsracz January 18, 2025 20:29
@atanisoft
Copy link
Collaborator

With the latest code I'm seeing the following warning/deprecation notice:

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());

Not sure how best we should handle this other than using casting to an integer and then back to ResponseFlag.

@bakerstu
Copy link
Owner Author

With the latest code I'm seeing the following warning/deprecation notice:

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());

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:

  1. Static cast the operation.
  2. Create a custom operator override.
  3. Rework the enumerated types to be a bit more consistent and compatible, maybe even built off each other a bit. Possibly consider structs with bitfields.
    1. This would still likely require some custom operator overrides.
    2. One problem with bitfields is that there is no standard bit ordering enforced by the C/C++ standards. It happens that pretty much everyone uses the same order though, so maybe this is not so much an issue.

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?

@atanisoft
Copy link
Collaborator

atanisoft commented Jan 20, 2025 via email

"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());"
@bakerstu
Copy link
Owner Author

I added the static_cast for both read and write timeout cases.

src/openlcb/DatagramImpl.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfig.hxx Outdated Show resolved Hide resolved
src/openlcb/MemoryConfigClient.cxxtest Outdated Show resolved Hide resolved
src/openlcb/MemoryConfigClient.cxxtest Outdated Show resolved Hide resolved
src/openlcb/MemoryConfigClient.cxxtest Show resolved Hide resolved
src/openlcb/MemoryConfigClient.cxxtest Outdated Show resolved Hide resolved
@@ -402,7 +405,8 @@ private:

Action read_response_timeout()
{
if (responseCode_ & DatagramClient::OPERATION_PENDING)
if (responseCode_ & DatagramClient::OPERATION_PENDING ||
!timer_.is_triggered())
Copy link
Collaborator

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.

Copy link
Owner Author

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.

@bakerstu bakerstu requested a review from balazsracz January 27, 2025 04:10
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.

4 participants