Documentation
Python Events
Events flow from a PD to a CP. In Python an event is a plain dict. Every event dict carries an event key set to an Event value; the remaining keys depend on that event.
A PD sends an event with PeripheralDevice.notify_event(event); a CP receives the same dict from ControlPanel.get_event(address) or its event handler.
from osdp import Event, CardFormat
pd.notify_event({
'event': Event.CardRead,
'reader_no': 1,
'direction': 1,
'format': CardFormat.ASCII,
'data': bytes([9, 1, 9, 2, 6, 3, 1, 7, 7, 0]),
})
The keys below match the C Event Structure.
Card Read — Event.CardRead
A card was presented at a reader.
| Key | Type | Notes |
|---|---|---|
reader_no | int | Reader that read the card. |
format | CardFormat | Card data format. |
direction | int | 0 for forward, 1 for reverse. |
data | bytes | Card data. |
length | int | Only for Wiegand/Unspecified formats — data length in bits. For other formats the length is taken from len(data). |
For raw Wiegand or unspecified formats, data holds the bits packed into bytes and length gives the exact bit count; otherwise omit length.
Key Press — Event.KeyPress
Keypad input.
| Key | Type | Notes |
|---|---|---|
reader_no | int | Reader that captured the keys. |
data | bytes | Key codes. |
Manufacturer Reply — Event.ManufacturerReply
A vendor-specific reply.
| Key | Type | Notes |
|---|---|---|
vendor_code | int | IEEE-assigned vendor code. |
data | bytes | Vendor-defined payload. |
Status — Event.Status
An (un)solicited status report.
| Key | Type | Notes |
|---|---|---|
type | StatusReportType | Report type. |
report | bytes | One status byte per entry. |
Notification — Event.Notification
Emitted when the LibFlag.EnableNotification flag is set.
| Key | Type | Notes |
|---|---|---|
type | int | Notification type. |
arg0 | int | Type-specific argument. |
arg1 | int | Type-specific argument. |