Open isidroas opened 4 months ago
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
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.
The default timeout is 10 seconds, but it will wait forever