Add client (connect) mode for passive instruments / serial-to-LAN gateways#61
Open
xispa wants to merge 2 commits into
Open
Add client (connect) mode for passive instruments / serial-to-LAN gateways#61xispa wants to merge 2 commits into
xispa wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the issue/feature this PR addresses
senaite.astmcurrently runs only as a TCP server (server.pyis built onloop.create_server(...)), so it always waits for the instrument — or its serial-to-LAN gateway — to connect in.Some gateways are configured as passive TCP servers themselves (they only accept connections, they never dial out) and therefore expect the LIS to initiate the connection. A real-world example: an Abbott ARCHITECT ci4100 behind a Lantronix UDS1100 with
Accept Incoming = Yes/Active Connect = None. In that topology both ends are passive listeners, no socket is ever established, and not a single byte (not even<ENQ>) reaches the server.This PR adds a client (connect) mode so
senaite.astmcan actively open the outbound connection to such a device, while reusing the exact sameASTMProtocolreceiver logic.What changed
server.py: new--connect HOST:PORTmode (mutually exclusive with--listen/--port) that connects out to the instrument/gateway vialoop.create_connection(...), plus--reconnect-delay(default5s) for automatic reconnection when the link drops. Server (listen) mode is unchanged and remains the default.protocol.py:ASTMProtocolgains an optionalon_connection_lostfuture (defaults toNone) thatconnection_lostresolves, letting the connect loop detect drops and reconnect. In server mode it staysNone— no behavior change.tests/test_astm_client.py: covers message reception and reconnect-after-drop by standing up a passive fake instrument that the client connects to.Current behavior before PR
senaite.astmcan only listen for incoming connections. It cannot integrate with an instrument or gateway that is itself passive and requires the LIS to initiate the connection.Desired behavior after PR is merged
senaite.astm --connect HOST:PORTactively connects out to the instrument / gateway and processes messages with the same protocol/queue/wrapper pipeline as server mode, reconnecting automatically if the connection is lost.--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.