Skip to main content

Python PLIN library

This library provides a Python interface for interacting with PEAK devices such as the PCAN-USB Pro and PLIN-USB on Linux using the chardev API provided by the PEAK LIN Linux Driver. The PEAK LIN Linux driver is required to use this library and is available here.

Installation

The plin-linux package is available on PyPI and can be directly installed with pip install plin-linux.

Examples

Runnable examples are located in the examples/ directory.

Master Example

from plin.device import PLIN
from plin.enums import (PLINFrameChecksumType, PLINFrameDirection,
                        PLINFrameFlag, PLINMode)

# Initializes /dev/plin0 as a LIN master
master = PLIN(interface="/dev/plin0")

master.start(mode=PLINMode.MASTER, baudrate=19200)

# Get firmware version of the PEAK device
print(master.get_firmware_version())

# Get current status of the PEAK device
print(master.get_status())

# Add a publisher frame entry
master.set_frame_entry(id=0x22,
                       direction=PLINFrameDirection.PUBLISHER,
                       checksum_type=PLINFrameChecksumType.CLASSIC,
                       data=bytearray([0x01, 0x02, 0x03, 0x04]))

# Add a subscriber frame entry
master.set_frame_entry(id=0x23,
                       direction=PLINFrameDirection.SUBSCRIBER_AUTO_LEN,
                       checksum_type=PLINFrameChecksumType.CLASSIC)

# Get frame entry
print(master.get_frame_entry(id=0x22))

# Add unconditional slot to schedule 0
master.add_unconditional_schedule_slot(schedule=0, delay_ms=10, id=0x22)
master.add_unconditional_schedule_slot(schedule=0, delay_ms=10, id=0x23)

# Get schedule 0 slots
print(master.get_schedule_slots(0))

# Start schedule 0
master.start_schedule(0)

# Set ID filter
master.set_id_filter(bytearray([0xff] * 8))

# Read frames
while True:
    result = master.read()
    print(result)

Slave Example

from plin.device import PLIN
from plin.enums import PLINMode

# Initializes /dev/plin0 as a LIN slave
slave = PLIN(interface="/dev/plin0")

slave.start(mode=PLINMode.SLAVE, baudrate=19200)

# Set ID filter
slave.set_id_filter(bytearray([0xff] * 8))

# Read frames
while True:
    result = slave.read()
    print(result)

Unit Tests

  • Unit tests are located in the unit_tests/ directory.
  • Tests in unit_tests/integration/ require a PEAK LIN device connected to run.
  • Can be run with pytest.

License

Copyright 2024 Rivian Automotive, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Metadata

Release files for plin-linux 0.0.4

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

Source distribution (sdist)

Source distribution for plin-linux 0.0.4
File Size Uploaded
plin_linux-0.0.4.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for plin-linux 0.0.4
File Interpreter ABI Platform
plin_linux-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 28.3 kB

Release files / plin_linux-0.0.4.tar.gz

Download URL plin_linux-0.0.4.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e60137440e01cc1005e8b0caa96b27c7f4d8ec6f2b15076e64e6eea1bed79158
BLAKE2b-256 checksum
How to use checksums
ad00c9c82372c87b5856c901471bec36e57e0c6c71928958690e7110ead6e9fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / plin_linux-0.0.4-py3-none-any.whl

Download URL plin_linux-0.0.4-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8e044a0c8d7837fa82f355a3e82879e852f99e06ed830856194417c34195bd7
BLAKE2b-256 checksum
How to use checksums
b7c2ce3618d7f05e423a37e399e9368645069ac15c7cd63ab7b9a7b0be2e587b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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