This is a modular Python library for communicating with PTCC hardware devices over a custom byte-based protocol. It supports message construction, parsing, throttled I/O communication, device detection, and callback-based event handling.
Project description
PTCC Communication Framework
A modular Python library for communicating with PTCC hardware devices over a custom byte-based protocol. It supports message construction, parsing, throttled I/O communication, device detection, and callback-based event handling.
- Project Homepage: https://gitlab.com/vigophotonics/ptcc-library
- Download Page: https://pypi.org/project/pttcc-library
Features
- Communication with PTCC devices and modules
- Simplified message generation for communication
- Interface abstraction for serial or custom communication backends
- Auto-detection of PTCC device/module types (NOMEM, MEM, LAB_M)
- Full PtccObject and PtccMessage encoding/decoding support
- Callback registration for received object IDs
- Values retrieving and setting in SI units
Documentation
Full documentation can be found at https://ptcc-library.readthedocs.io/
Installation
ptcc_library can be installed from PyPI:
pip install ptcc-library
Detailed information can be found at https://pypi.org/project/pttcc-library
Quick Start Example
1. Detect and Connect to Device
from ptcc_library import detect_device
import serial
with serial.Serial('COM5', baudrate=57600, timeout=0.1) as ser:
device = detect_device(comm=ser)
2. Register Callbacks
from ptcc_library import CallbackPtccObjectID
def name_callback(name):
print("Module Name:", name)
def temp_callback(temp, context):
print(f"Temperature: {temp} K ({context})")
device.receiver.register_callback(CallbackPtccObjectID.MODULE_IDEN_NAME, name_callback)
device.receiver.register_callback(CallbackPtccObjectID.MODULE_BASIC_PARAMS_T_DET, temp_callback, "live")
3. Send Messages
device.write_msg_get_module_iden()
device.write_msg_set_temperature(value_in_kelvins=230)
4. Handle Incoming Data
while True:
byte = ser.read(1)
if byte:
if device.receiver.add_byte(byte[0]) == PtccMessageReceiveStatus.FINISHED:
print("New message received")
👤 Author
Wojciech Szczytko
wszczytko@vigo.com.pl
GitLab: @wszczytko1
@wszczytko
@wszczytk
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ptcc_library-0.1.0.tar.gz.
File metadata
- Download URL: ptcc_library-0.1.0.tar.gz
- Upload date:
- Size: 38.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b260fa8de3be9da0e6a7289bcf3072e76b27869309be041b6044182b86ad0794
|
|
| MD5 |
759db3215eba5a17e4be9d2bc88e4b04
|
|
| BLAKE2b-256 |
56d008f5aae5a7a8c391adf66ba9ad8428bc70965a4eb36597bebe80260ebeba
|
File details
Details for the file ptcc_library-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ptcc_library-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd2f82a59e00384905e240b171214148789f4e1e368b40a3a36aa020fd463baa
|
|
| MD5 |
2eddd496af8e4e83dfefe8a1f3407412
|
|
| BLAKE2b-256 |
782b2a8b1ce6ffe186ac03d8eee3eefba26ee197634af9ce0cafd5ce9dcdf648
|