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

HDLC Timeout does not take effect #93

Open
isidroas opened this issue Feb 27, 2024 · 2 comments
Open

HDLC Timeout does not take effect #93

isidroas opened this issue Feb 27, 2024 · 2 comments
Assignees

Comments

@isidroas
Copy link

The default timeout is 10 seconds, but it will wait forever

@isidroas
Copy link
Author

Investigation

The pyserial.Serial instance has the timeout attribute set correctly, and is working fine. The problem is that the execution never exits from the following while loop:

# dlms_cosem/io.py:HdlcTransport.next_event
def next_event(self):
        """
        Will read the serial line until a proper response event is read.
        :return:
        """

        while True:
            # If we already have a complete event buffered internally, just
            # return that. Otherwise, read some data, add it to the internal
            # buffer, and then try again.
            event = self.hdlc_connection.next_event()
            if event is state.NEED_DATA:
                self.hdlc_connection.receive_data(self.recv_frame())
                # ^ recv_frame is actually returning empty bytes: b'' after the Serial timeout, but receive_data doesn't do anything with it, and next_event just continues execution indefinitely
                continue
            return event

Investigation done by @markopesevski

@Krolken
Copy link
Contributor

Krolken commented Mar 6, 2024

Thanks fort the troubleshooting. The timeout is actually redundant as we now are using compostion of the IO-layer and the transport layer.

Instead this timeout should handle the transport and should be in the next_event method. But we then would want maybe 30 seconds as default so we get a couple of tries on the IO-layer first.

I will look into it.

@Krolken Krolken self-assigned this Mar 6, 2024
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

No branches or pull requests

2 participants