Skip to main content

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

Reason this release was yanked:

did not properly include dependencies

Project description

Python PLIN library

The plin module 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.

Examples

Runnable examples are located in the examples/ directory.

Master Example

from plin.plin 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.plin 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 and require a PEAK LIN device connected to run.

License

Copyright 2023 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.1.tar.gz (14.5 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.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file plin-linux-0.0.1.tar.gz.

File metadata

  • Download URL: plin-linux-0.0.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for plin-linux-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3253fc99218058917da6e014f3abdf218dd4c2ec21a8111d05fa4e8e0bed8548
MD5 f6508107d80c00ce9ff659a0e4486b41
BLAKE2b-256 0dddc7cf3100eb49d50e4e0e8fefa6ec1e4465d337a9578272fe77e9d447e15c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: plin_linux-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for plin_linux-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4523290c64adf3a0a3991d42a42596d72446c115970ce58a9201d59f68292e84
MD5 e750e69b50708c4eb97007c636e3d570
BLAKE2b-256 f8173c53fe7b033a47c10e7ed5000faf22912bc7fe470e6cb499c0f2f0dec541

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