Page 1 of 1

Python access to PLIN Driver

Posted: Thu 9. Jun 2022, 17:57
by mplc005
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.

Re: Python access to PLIN Driver

Posted: Fri 10. Jun 2022, 10:35
by S.Grosjean
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,

Re: Python access to PLIN Driver

Posted: Tue 14. Jun 2022, 19:36
by mplc005
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.