Python access to PLIN Driver

This is a forum for the communication between the beta testers and our developers. It is only visible for PEAK-System employees and authorized testers.
Post Reply
mplc005
Posts: 2
Joined: Thu 9. Jun 2022, 17:34

Python access to PLIN Driver

Post by mplc005 » Thu 9. Jun 2022, 17:57

Hello!
I recently received a PCAN-USB Pro and I am testing it in a Raspberry Pi 3B+ using RaspOS.
I can succesfully install the driver and make some operations from terminal.

However, I have all my code developed in Python and access to PLIN library is not very handy. At the moment I am using:

Code: Select all

os.system(command)
f.e: x = os.system('lin start slave 19200 /dev/plin0')
or

Code: Select all

subprocess.Popen (command)
f.e: readLIN = subprocess.Popen(["linread", port], text=True, stdout=subprocess.PIPE)
they work fine but after some time RaspOS freezes, probably due to the big amount of processes launched when sending messages.

Is there a better way to access PLIN library?
I read somewhere do you plan to develop python lib for plin driver?

Thank you in advanced.
Last edited by K.Wagner on Fri 10. Jun 2022, 07:57, edited 1 time in total.
Reason: Code formatting for better reading

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: Python access to PLIN Driver

Post by S.Grosjean » Fri 10. Jun 2022, 10:35

Hi,

Thank you for you interest in the PEAK-System LIN products.

lin, linread and linwrite are tools useful to configure, read and write data over the LIN bus, but are also C language examples of how to use the API provided by the plin driver.

The plin driver proposes a chardev API (open(), read(), write(), ioctl(), close()) these programs use. Please have a look to utils/linread.c, for example, which demonstrates how to open() then read() data from a plin device node that has been previously configured with "lin" tool. "utils" also contains several shell scripts that demonstrate how a LIN actor (slave or master) should be configured.

There's currently no real plan to develop any python lib for this driver but a TODO list item only...

Regards,
— Stéphane

mplc005
Posts: 2
Joined: Thu 9. Jun 2022, 17:34

Re: Python access to PLIN Driver

Post by mplc005 » Tue 14. Jun 2022, 19:36

Ok, I managed to use Schedule table properly for my purposes and the problem is over and working great.
I found some other blockers but not a big problem at this moment. (such as read values from slave and setting values in the Schedule Table frame at the same time)

A more detailed documentation would be very helpful.
And hopefully a python lib is available soon.

Thank you.

Post Reply