-
-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Describe the bug
Using the sample python application, changing the CardFormat to anything except 'ASCII' throws an error. The event:
card_event = {
'event': Event.CardRead,
'reader_no': 1,
'direction': 1,
'format': CardFormat.ASCII, <-- change this to CardFormat.Wiegand to reproduce
'data': bytes([9,1,9,2,6,3,1,7,7,0]),
}
Expected behavior
exceptions are not thrown
Observed behavior
$ ./pd_orig.py --baudrate 9600 --log-level 7 /dev/ttyUSB1
OSDP: PD-0: 2025-12-12T17:13:21Z osdp_pd.c:1184 [WARN ] SCBK not provided. PD is in INSTALL_MODE
pyosdp: 2025-12-12T17:13:21Z osdp_pd.c:1202 [INFO ] PD Setup complete; LibOSDP-3.1.0 master (v3.1.0)
OSDP: PD-0: 2025-12-12T17:13:21Z osdp_phy.c:581 [DEBUG] Packet scan skipped:2 mark:1
OSDP: PD-0: 2025-12-12T17:13:22Z osdp_pd.c:699 [DEBUG] CMD: CAP(62) REPLY: PDCAP(46)
OSDP: PD-0: 2025-12-12T17:13:22Z osdp_pd.c:699 [DEBUG] CMD: ID(61) REPLY: PDID(45)
OSDP: PD-0: 2025-12-12T17:13:22Z osdp_pd.c:699 [DEBUG] CMD: COMSET(6e) REPLY: COM(54)
PD: Received command: {'command': 6, 'address': 0, 'baud_rate': 9600}
OSDP: PD-0: 2025-12-12T17:13:22Z osdp_pd.c:1086 [INFO ] COMSET Succeeded! New PD-Addr: 0; Baud: 9600
Traceback (most recent call last):
File "/home/robert/CE-reader-issues/./pd_orig.py", line 76, in <module>
pd.submit_event(card_event)
File "/home/robert/CE-reader-issues/venv/lib/python3.11/site-packages/osdp/peripheral_device.py", line 69, in submit_event
ret = self.ctx.submit_event(event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Unable to get event struct!
Additional context
libosdp was installed through pip.
Also, this shows a problem with the current code: in the submit_event function, because the exception is being thrown the mutex is never being unlocked, thus locking up the entire system. The code needs to use a context manager in order to lock/unlock, something like this to ensure that the lock is released if there is an error:
def submit_event(self, event):
with self.lock:
ret = self.ctx.submit_event(event)
return ret
Metadata
Metadata
Assignees
Labels
No labels