bytedreamer / OSDP.Net

A .NET Core control panel implementation of the Open Supervised Device Protocol(OSDP)
Apache License 2.0
47 stars 19 forks source link

Send a osdp_COMSET command to an address that is already assigned #140

Closed bytedreamer closed 12 months ago

bytedreamer commented 12 months ago

The library should prevent sending a request to change to an address that is already assigned to an existing reader.

rsgmodelworks commented 12 months ago

I disagree. If the reader is defined but not present I think it's perfectly reasonable to comset a reader to that address. This scenario happens today in the real world where people ship a reader at address 0 and in the field it has to be moved to a different address. It is realistic IMO to encounter situations where the EAC has already had the reader defined at it's destination address.

bytedreamer commented 11 months ago

Good point about replacing reader scenario. There is an underlining collection of devices that requires unique addresses for each bus. In order to ensure data integrity, it is necessary for the EAC not to have multiple devices with the same address. With this change, the EAC can still perform a reader replacement. The OSDP.Net library would need the following steps to implement.

  1. Remove old device at address X from the bus
  2. Add a new device on bus with address 0
  3. Once new device is connected, send osdp_COMSET for address X
  4. Add a new device on bus with address X
  5. Remove device on bus with address 0

I may add a helper function in the future to reduce the steps involved with a swapping device addresses. This is how osdp_COMSET has always been done in the test console, except for step 1. The change I made is to explicitly enforce the unique address constraint. This will ensure that the EAC does the require steps shown above. Otherwise, the EAC could experience unexpected behavior after sending the osdp_COMSET command to an existing device on that address.