Skip to content

Conversation

@LeeHudsonDLS
Copy link
Contributor

When communicating with a simulated device using an ascii protocol I found that the StreamReader.read() method returns inconsistent number of bytes. Even the documentation alludes to this inconsistency:

If n is positive, this function try to read n bytes, and may return
less or equal bytes than requested, but at least one byte. If EOF was
received before any byte is read, this function returns empty byte
object.

As the majority of devices that communicate using an ascii based protocol rely on a termination character to determine the end of a message I have added this as an optional parameter in the tickit.adapters.io.TcpIo class.

@LeeHudsonDLS LeeHudsonDLS requested a review from abbiemery October 1, 2024 11:15
@abbiemery
Copy link
Collaborator

Have you run the pre-commit linters and checkers on this?

Copy link
Collaborator

@abbiemery abbiemery left a comment

Choose a reason for hiding this comment

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

I've not checked it working with the tests yet but just some formatting things.

LeeHudsonDLS and others added 2 commits October 15, 2024 07:34
Co-authored-by: Abigail Emery <abigail.emery@diamond.ac.uk>
Co-authored-by: Abigail Emery <abigail.emery@diamond.ac.uk>
@LeeHudsonDLS
Copy link
Contributor Author

Sorry no I forgot to do the pre-checks, I have tested you changes though and it all seems to work thanks

@LeeHudsonDLS
Copy link
Contributor Author

@abbiemery Are you OK to approve this so it can be merged and released?

@callumforrester
Copy link
Contributor

Power cycling CI

@callumforrester
Copy link
Contributor

@LeeHudsonDLS Apologies, some of the CI was not running before

image

I have now fixed it.

Copy link
Contributor

@callumforrester callumforrester 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, only a couple of small items.

def __init__(self, host: str, port: int, separator: str = None) -> None:
self.host = host
self.port = port
self.separator = separator
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'm not sure the name separator is completely right, maybe terminator? Or just add a comment explaining what it does, it's not immediately obvious to me from the name (unlike host and port). Not bothered by that enough to block merge though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Callum, i'm not too sure about this name either, the reason I chose separator is because that's the name of the parameter in StreamReader.readUntil. I guess in this context it really is a terminator though. It probably makes sense to change it, i'll do that now

LeeHudsonDLS and others added 2 commits November 22, 2024 09:52
Co-authored-by: Callum Forrester <callum.forrester@diamond.ac.uk>
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