goToMain / libosdp

Implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol); provides a C library with support for C++, Rust and Python3
https://libosdp.sidcha.dev
Apache License 2.0
128 stars 69 forks source link

Fix issue#110: Communications go offline and are not restored #149

Closed Aalawfi closed 7 months ago

Aalawfi commented 7 months ago

First described in https://github.com/goToMain/libosdp/issues/110, there is case where CP detects a timeout after 200 ms so it resets communication. However, before that PD still send a reply to CP after CP already timeout, this created a problem with sequence mismatch errors.

This PR solves the reported issue by making PD check if it has been more than OSDP_RESP_TOUT_MS before sending a reply. Also, added a unit test for this case.

sidcha commented 7 months ago

Thank you for the PR and the testing efforts involved. But this change is only fixing one of the symptoms and not the underlying issue itself.

The issue is this: one side is mistreating a response while the other side thinks it responded within the time frame it's allowed to respond. To fix this, we need to make packet handling more robust on either side and then expect them to play nice when they come together.

I'm aware of this issue (and it's been on my TODO list for a while) and currently not looking at it because it's not causing any immediate problem. For the time being, I'm spending all the time I have assigned to this project in the rust language support; but if you think issue is blocking, I can take a look at it sooner.

sidcha commented 7 months ago

Closing this PR for now.