-
-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Hi,
When using the isotp layer with large packest the timeout takes into account all the processing and reception of the isotp packet.
This means that if the timeout is too small a timeout might reach although isotp frames are still ariving.
Is there an option to hold the timeout in case the packet building is in progress?
I'm using the isotp with CanStack, for example:
import isotp
LONG_RESPONSE_REQUEST = ... # a request which it's response takes 1.5 sec to receive
can_stack: isotp.CanStack
can_stack.set_address(address=isotp.Address(rxid=0x123, txid=0x321, addressing_mode=isotp.AddressingMode.Normal_29bits))
can_stack.send(LONG_RESPONSE_REQUEST)
can_stack.recv(block=True, timeout=1) # return with None
In that cas I do not want to put the timeout too high because it will affect the performance of the rest of my code.
I would expect something like that once timeout is reached the recv method will still block until the receive state return to IDLE (not in the middle of receiving isotp packet).
Something like this for example:
...
class TransportLayerLogic
...
def recv(self, block: bool = False, timeout: Optional[float] = None) -> Optional[bytearray]:
"""
Dequeue an IsoTP frame from the reception queue if available.
:param block: Tells if the read should be blocking or not
:type block: bool
:param timeout: Timeout value used for blocking read only
:type timeout: float
:return: The next available IsoTP frame
:rtype: bytearray or None
"""
try:
return self.rx_queue.get(block=block, timeout=timeout)
except queue.Empty:
################### Added code ##################
if block:
with self.processing:
self.processing.wait()
return self.rx_queue.get(block=False)
################### Added code ##################
return None
...
where processing will be updated will wait if a packet is in progress of creation