Skip to main content

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.

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

ptcc_library-0.1.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ptcc_library-0.1.0-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

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

Hashes for ptcc_library-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b260fa8de3be9da0e6a7289bcf3072e76b27869309be041b6044182b86ad0794
MD5 759db3215eba5a17e4be9d2bc88e4b04
BLAKE2b-256 56d008f5aae5a7a8c391adf66ba9ad8428bc70965a4eb36597bebe80260ebeba

See more details on using hashes here.

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

Hashes for ptcc_library-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd2f82a59e00384905e240b171214148789f4e1e368b40a3a36aa020fd463baa
MD5 2eddd496af8e4e83dfefe8a1f3407412
BLAKE2b-256 782b2a8b1ce6ffe186ac03d8eee3eefba26ee197634af9ce0cafd5ce9dcdf648

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page