Skip to main content

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/ptcc-library

Quick Start Example

1. Detect and Connect to Device

To communicate with your hardware, the library first needs an active communication channel. This is typically a serial port object that you create and configure. You pass this communication object to the detect_device() function. If a compatible device is found, the function returns a device object, which is your primary interface for all further interactions.

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

A callback is a function you write that is automatically executed when a specific piece of data arrives from the device. This allows you to react to incoming information asynchronously. You link your function to a data ID using device.receiver.register_callback(). You can also pass an optional context argument, which is a static value supplied to your callback, useful for identifying a measurement's source.

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

The device object provides straightforward methods for sending commands and requests to the hardware, typically named write_msg_*. For example, write_msg_get_module_iden() requests identity information, while write_msg_set_temperature() commands the device to change its temperature. When the device responds, it will trigger the corresponding callbacks you registered.

device.write_msg_get_module_iden()
device.write_msg_set_temperature(value_in_kelvins=230)

4. Handle Incoming Data

The library does not read from the serial port on its own. Your application is responsible for reading incoming bytes and feeding them to the library's receiver. You must implement a loop that reads data and passes it to device.receiver.add_byte() or device.receiver.add_bytes(). As the receiver processes data, it automatically finds complete messages and triggers the appropriate callbacks.

while True:
    byte = ser.read(1)
    if byte:
        if device.receiver.add_byte(byte[0]) == PtccMessageReceiveStatus.FINISHED:
                print("New message received")

Handle Containers

The device communicates by sending data in packets called containers. Each container holds a collection of related data objects. To process full data as it arrives, you must register a callback function that will be executed when a specific type of container is received.

Container IDs include:

  • DEVICE_IDEN
  • MODULE_IDEN
  • PTCC_CONFIG
  • PTCC_MONITOR
  • MODULE_BASIC_PARAMS
  • MODULE_LAB_M_MONITOR
  • MODULE_LAB_M_PARAMS
def iden_callback(objects):
    for o in objects:
        print(f"{o.name} = {o.value}")
device.receiver.register_callback(CallbackPtccObjectID.DEVICE_IDEN, iden_callback)

Product Page

Photo of the PTCC-01 TEC Controller

PTCC-01 is a series of programmable, precision, low-noise thermoelectric cooler controllers. They are designed to operate with VIGO infrared detection modules.

👤 Author

Wojciech Szczytko
wszczytko@vigo.com.pl
GitLab: @wszczytko1 @wszczytko @wszczytk

Metadata

Release files for ptcc-library 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ptcc-library 0.2.1
File Size Uploaded Provenance Actions
ptcc_library-0.2.1.tar.gz 181.1 kB Without provenance Details for ptcc_library-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ptcc-library 0.2.1
File Interpreter ABI Platform Actions
ptcc_library-0.2.1-py3-none-any.whl Python 3 none any Details for ptcc_library-0.2.1-py3-none-any.whl

Total release size: 366.4 kB

Release files / ptcc_library-0.2.1.tar.gz

Download URL ptcc_library-0.2.1.tar.gz
Size 181.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2d82779e9ace3b67bf3b38dfc858eab5ed683608346b1756852f4fcaea30ad32
BLAKE2b-256 checksum
How to use checksums
b03844535cae5580e6d1b33d933094c9cd8df1525a186730c7c049787a6e1845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / ptcc_library-0.2.1-py3-none-any.whl

Download URL ptcc_library-0.2.1-py3-none-any.whl
Size 185.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cc2cb1eee72b8b0ef62f3f30caedb43482c55167bf3c59c209fe8f6b63864d3
BLAKE2b-256 checksum
How to use checksums
4cf18189f89eb2132d0bdc47fcb387a87e0d8a7a34d57fcfd733d4ebb7b16c71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for ptcc-library 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page