Skip to main content

The python-plin package is a Python wrapper for the chardev API provided by the PEAK LIN Linux Beta.

Project description

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 Beta. The PEAK Linux beta 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.

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

plin_linux-0.0.3.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

plin_linux-0.0.3-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file plin_linux-0.0.3.tar.gz.

File metadata

  • Download URL: plin_linux-0.0.3.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for plin_linux-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1425963aaf87f604eea54b8b8acba9d2caeea5493cecda80dccd75607f9cf9d5
MD5 99b215a9e212f751dcc75b68de1b0fe1
BLAKE2b-256 855e8a0bf6ab6837e52d38074a642889571cb2d88c80ae2255cff051711346cd

See more details on using hashes here.

File details

Details for the file plin_linux-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: plin_linux-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for plin_linux-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 780b34f9abfcd7c1674f4fd6fa2894bdf8af60632e60c1a0c46da1eae2d35705
MD5 728f7ce31478234692ba33b0efc1eb92
BLAKE2b-256 e0f9a913c34b15adcb58112340df34cf49a6bec9d044ea302ff0068c50cab8a7

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