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

Add FlushSocket before reading input #36

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ejorritsma
Copy link
Contributor

@ejorritsma ejorritsma commented Sep 11, 2024

When reading input from the socket, often you will read leftover data from it.
This results in static noise, because you're reading previously scanned RFID's.

The FlushSocket function will flush the socket by reading the buffer size from the socket and discarding it. This will have tests succeed in the PDS codebase.

Please take a look and see if this is the proper solution, I feel it might not be an industry standard way of solving this probably quite common problem. The reason I picked this solutoin, instead of filtering out the noise, is because the RFID scanner sends its RFID's over the socket without delimiters, making parsing impossible.

Comment on lines +91 to +95
var bufferSize = 48;

FlushSocket(_socket, bufferSize);

var buffer = new byte[bufferSize];
Copy link
Collaborator

@tluijken tluijken Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wat als we de buffer definieren vlak voor gebruik. Zeg, op regel 105? Krijg je dan niet hetzelfde effect? Dan kan de hele flush methode eruit. Voelt nu alsof we 2 keer hetzelfde doen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goed punt, ik heb het verwerkt en opnieuw getest. Het lijkt erop dat het toch niet helemaal hetzelfde is...

+> info: [PDMS.Dispatcher.Tests.Mocks.SickRfidScannerMock] Sending response :\x02sAN MIStartIn\x03
+> info: [PDMS.Dispatcher.Tests.Mocks.SickRfidScannerMock] Sending response :\x02sAN MIStopIn\x03
+> info: [PDMS.Dispatcher.Tests.Mocks.SickRfidScannerMock] Sending RFID 91456789415679
+> warn: [PDMS.Dispatcher.Core.Implementation.BinService] Could not find bin in repository for bin tag 914567894156789145678941567891456789415678914567

Ik heb ook de code met de flush methode nog even gerund als sanity check, en die werkt wel. (Met deze test "Dispatch VS22-0009 plates are all in 3 different trays, but one tray has all the plates" )

🤔

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.

2 participants