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
138 stars 71 forks source link

Manufacturer Specific Reply (osdp_MFGREP) data length is fix 1 bytes #75

Closed laszlopataki closed 2 years ago

laszlopataki commented 2 years ago

Describe the bug osdp.h:struct osdp_event_mfgrep conatins length field and the data length is OSDP_EVENT_MAX_DATALEN(64), Accordingly SIA-OSDP-2.2-FINAL-120720.pdf:7.18 Manufacturer Specific Reply (osdp_MFGREP) the Data field is fixed 1 byte.

Expected behavior osdp.h:struct osdp_event_mfgrep has 1 bytes Data field.

Update: The data field is fine, but it is not identical to the "Data" referenced in the documentation. The Data field in documentation is called a command in the code.

sidcha commented 2 years ago

Good catch thanks!

This seems to be one of those changes in v2.2 which was not the case till v2.1.5 of the specification. There, the data filed can be any length as chosen by the vendor. This allowed some flexibility for me to defined some minimal structure to these commands so the whole length prefixed data thing was a LibOSDP specific extension (IMO, this is how they should have defined the struct to begin with).

I think this change doesn't make sense as it is limiting the possibility of what osdp_MFG and osdp_MFGREP can achieve. For this reason I'm really reluctant to "fix" this. But.. in the interest of playing nice to those who followed the 2.2 spec, I will make sure LibOSDP supports both formats.

sidcha commented 2 years ago

Actually, we are already supporting it both ways :). To be compatible with specification, you just have to set the length field to zero. I'll add comments to clarify this.