Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol)
Reason this release was yanked:
Has a broken packaging method; won't install.
Project description
Python3 Bindings for LibOSDP
This is an initial effort at enabling python3 support for LibOSDP. This document assumes that you are already familiar with LibOSDP API and device life cycle management.
Build/Install
A python module osdp
and classes ControlPanel
and PeripheralDevice
are
made available when the sources of this directory is built and installed.
After cloning this repo (with --recurse-submodules
), you can do the following
(from the repo root) to build the python module.
mkdir build && cd build
cmake ..
make python
make python_install
If you want to undo this install, you can run make python_uninstall
.
How to use this module?
Control Panel Mode
import osdp
## Master key for secure channel
key = '01020304050607080910111213141516'
## populate osdp_pd_info_t from python
pd_info = [
{
"address": 101,
"channel_type": "uart",
"channel_speed": 115200,
"channel_device": '/dev/ttyUSB0',
},
{
"address": 102,
"channel_type": "uart",
"channel_speed": 115200,
"channel_device": '/dev/ttyUSB1',
}
]
## Setup OSDP device in Control Panel mode
cp = osdp.ControlPanel(pd_info, master_key=key)
## call this refresh method once every 50ms
cp.refresh()
## create and output command
output_cmd = {
"command": osdp.CMD_OUTPUT,
"output_no": 0,
"control_code": 1,
"timer_count": 10
}
## send a output command to PD-1
cp.send_command(1, output_cmd)
see samples/cp_app.py for more details.
Peripheral Device mode:
## Describe the PD
pd_info = {
"address": 101,
"channel_type": "uart",
"channel_speed": 115200,
"channel_device": '/dev/ttyUSB0',
"version": 1,
"model": 1,
"vendor_code": 0xCAFEBABE,
"serial_number": 0xDEADBEAF,
"firmware_version": 0x0000F00D
}
## Indicate the PD's capabilities to LibOSDP.
pd_cap = [
{
# PD is capable of handling output commands
"function_code": osdp.CAP_OUTPUT_CONTROL,
"compliance_level": 1,
"num_items": 1
},
]
## Setup OSDP device in Peripheral Device mode
pd = osdp.PeripheralDevice(pd_info, capabilities=pd_cap)
## call this refresh method periodically (at lease once every 50ms)
pd.refresh()
## Define a callback handler. Must return 0 on success, -ve on failures.
def handle_command(address, command):
if address != pd_info['address']:
return { "return_code": -1 }
print("PD received command: ", command)
return { "return_code": 0 }
## Set a handler for incoming commands from CP
pd.set_command_callback(handle_command)
see samples/pd_app.py for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file libosdp-2.4.0.tar.gz
.
File metadata
- Download URL: libosdp-2.4.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13c11878fae6cf214f888c95cefc4617886e5760d56d73be2b247b0b3fa58ebf |
|
MD5 | 0c36e06e47ecd2a12a3587e5318d6f89 |
|
BLAKE2b-256 | de682aaee5db135f142e9c03141312588e8489e3894318f8d72a3874c123afdd |
File details
Details for the file libosdp-2.4.0-cp311-cp311-macosx_14_0_arm64.whl
.
File metadata
- Download URL: libosdp-2.4.0-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 68.6 kB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8261f20e31d77bee977a726e087a7264be66414f3ba222b0745d3b88c75dc7d |
|
MD5 | be8ffac4546962cadcf1471de44c9da1 |
|
BLAKE2b-256 | fd013167539686abeba17adff6fc2eafaa9dd4035e30eeb60ea2f3db686cc5b3 |