Skip to main content

Local Interconnect Network (LIN) support for python

Project description

LIN Python lib

Library is under development API will change

Features

  • LIN frame transmission / reception
  • LDF signals encoding / decoding (only signal and frames currently working, schedule table parsing not implemented, max signal size is 1 byte)
  • Works on windows, linux, mac. Supported hardware , uCAN LIN USB CONVERTER

Installation

pip install ucanlintools

Example usage

To load ldf

from ucanlintools.LDF_parser import parseLDF
ldf = parseLDF("D:\\ldfe.ldf") 
message = ldf.get_message_by_name('FRAME_A')
print(message.signals)

To decode/ encode frame

aaa = message.encode({'SIGNAL_A': 1})
bbb = b'\x00\x00\x00\x00\x00\x00'
message.decode(bbb)

To setup LIN USB Converter

lin = ucanlintools.LUC('COM7')
lin.set_frame_rx_handler(rx_any)
lin.set_new_frame_rx_handler(rx_new_data)

lin.openAsMaster()

lin.addReceptionFrameToTable(52,8)
lin.addReceptionFrameToTable(54,8)
lin.enable()

Example data reception handler

def rx_new_data(f):
        global message
        print (hex(f.id) + ": " +(f.data.hex()))
        if (message.id == f.id):
                message.decode(f.data)
                print(message.diff_str())

For more info see

https://ucandevices.github.io

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

ucanlintools-0.0.8.tar.gz (8.7 kB view hashes)

Uploaded Source

Supported by

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