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

Multi Response (Read/Write) Packets #93

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

Conversation

Mudrekh
Copy link
Contributor

@Mudrekh Mudrekh commented Nov 19, 2021

Multi Response (Read/Write) Packets

Description, Motivation, and Context

While running again a PLC with > 250 reads, we noticed that writes were being sent in parallel with the reads. This caused the buffer returned to _handleDataEvent to contain the response for both the read and write, however the parsing only ever parsed the first response in the header and threw away the other one. This change allows the remainder of the buffer to also be processed.

Aditionally, listeners are removed after failed calls and listeners are guranteed to be attached before the new write command is sent. This avoids possible race conditions in where a message could be recieved on the socket before the listener is set up.

An alternative solution to this would be to group read/write/groups in the same queue instead of individual queues so there is only ever 1 outstanding request.

How Has This Been Tested?

Tested against a PLC with > 250 reads and around 2 writes. When ever the writes would be would be executed, the subsequent read would always fail. I believe you can issue a write and read at the same time to reliably reproduce the error.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This is a work in progress, and I want some feedback (If yes, please mark it in the title -> e.g. [WIP] Some awesome PR title)

Related Issue

Mudrekh and others added 6 commits November 18, 2021 19:05
Issue writes after listener has been attached.
Sometimes with high volumes of reads and writes, the values will start swapping around if the queues remain separate
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.

1 participant