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

pd_app.py example does not result in a functioning PD by OSDP Spec #173

Closed
KaiAmelung opened this issue Apr 12, 2024 · 1 comment
Closed

Comments

@KaiAmelung
Copy link
Contributor

KaiAmelung commented Apr 12, 2024

Describe the bug
This appears to be an issue to me, but would appreciate insight if it is not:

The example Python pd_app.py includes the following pySerial usage:

class SerialChannel(Channel):
    def __init__(self, device: str, speed: int):
        self.dev = serial.Serial(device, speed, timeout=1)

    def read(self, max: int):
        return self.dev.read(max)

OSDP CPs require a response within 200ms according the OSDP spec. timeout is set to 1 meaning the PD will wait up to 1 second if it does not read the max amount of bytes. max is always set to 64 by libosdp, so if a command comes through which is 32 bytes, for instance, the PD can take up to 1 second to respond.

Expected behavior
When using the example app, a correctly functioning PD should be simulated i.e. it should reply to commands within 200ms.

Observed behavior
The 1 second timeout means that commands which do not sum up to a multiple of 64 bytes can take up to 1 second to read, meaning a sub-200ms response is not always possible.

Notes
Switching the timeout to zero appears to solve the issue as the library will wait for a complete message.

@sidcha
Copy link
Member

sidcha commented Apr 18, 2024

Thanks for reporting the issue. You are right, it should be set to 0.

@sidcha sidcha closed this as completed in 1d25d6a Apr 18, 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