Different connection results: PLIN-View PRO vs. PLIN_API_Console.py

The free LIN software API (Application Programming Interface) for Windows® (only for usage with the PCAN-USB Pro CAN/LIN interface)
Post Reply
andy_tengam.com
Posts: 3
Joined: Thu 1. Aug 2024, 15:48

Different connection results: PLIN-View PRO vs. PLIN_API_Console.py

Post by andy_tengam.com » Thu 1. Aug 2024, 16:38

Hardware:
PLIN-USB, PC

Software:
PEAK software downloaded within past week. PLIN_API_Console.py is internally dated 09.11.2015
Python 3.10, Win10

Goal:
Control several PLIN-BUS in production setting to test functionality of manufactured pump product at various stages of build. Using Python with variety of meters, sensors etc.

Try:
PLIN-View PRO
Set connection as master. Controlling simple pump with only 2 valid LIN frames, one as publisher (cmd speed), the other subscribe the resulting data.
Setup with known LDF file
Everything works perfectly, very clear, very nice. Great simple program! I can switch the USB ports, power up/down the PLIN-Bus, never fails.

PLIN_API_Console.py
Running program as intended, tried both from IDLE or directly.
1. If PLIN-View PRO was run earlier in session, the API_Console.py works fine, and correctly identifies my 2 valid frames, no issues.
However.
2. if I switch USB ports, or power down the PC, or turn off power to the PLIN-USB, the API_Console.py might not connect properly. Does NOT identify valid publisher frame. CANNOT command speed. API_Console.py does NOT ask for frame data, as it does in 1. above. I can however see the subscriber frame correctly.
3. I then modify the API_Console.py, add various delays within the initialize() methos, using typical Python time.sleep(). Still variable success as in 2. above

So it seems the PLIN-View PRO has slightly more robust connection protocol than the API_Console.py Makes sense, the API_Console is now getting old. Any idea what API commands might help?

Andy

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: Different connection results: PLIN-View PRO vs. PLIN_API_Console.py

Post by M.Maidhof » Fri 2. Aug 2024, 09:27

Hello,

this looks like the frame configuration in the hardware is not set correctly. When using PLIN-View Pro and you load a ldf file, the frame configuration listed in the ldf file is loaded into the PLIN hardware. If you use the PLIN_API_Console.py application without modification, the frame configuration is only set for some frames (0x1, 0x2, 0x3, 0x5, 0x3C, 0x3D) to a specific value. Did you adapt the frame config to your needed configuration in the python code?

regards

Michael

andy_tengam.com
Posts: 3
Joined: Thu 1. Aug 2024, 15:48

Re: Different connection results: PLIN-View PRO vs. PLIN_API_Console.py

Post by andy_tengam.com » Fri 2. Aug 2024, 16:11

Michael

No. I am ignorant, a very new LIN student, and did not. I see I need to change the code in the API_Console.py here, code lines 233-239:

Code: Select all

            # length values is set to LIN 1.2.
            if ((i >= 0x00) and (i <= 0x1F)):
                lFrameEntry.Length = c_ubyte(2)
            elif ((i >= 0x20) and (i <= 0x2F)):
                lFrameEntry.Length = c_ubyte(4)
            elif ((i >= 0x30) and (i <= 0x3F)):
                lFrameEntry.Length = c_ubyte(8)
The above code must be changed to match my two frames which are only 0x0A and 0x0B. These frames each have eight bytes each, and code must be something like

Code: Select all

            if i >= 0x0A and i <= 0x0B : 
                lFrameEntry.Length = c_ubyte(8)
Not asking you to write my code, and thanks for your assistance
Andy
Last edited by K.Wagner on Fri 2. Aug 2024, 16:14, edited 1 time in total.

andy_tengam.com
Posts: 3
Joined: Thu 1. Aug 2024, 15:48

Re: Different connection results: PLIN-View PRO vs. PLIN_API_Console.py

Post by andy_tengam.com » Fri 2. Aug 2024, 17:30

Also added these lines

Code: Select all

 if i == 0x0a : 
                lFrameEntry.Direction = PLinApi.TLIN_DIRECTION_PUBLISHER
                lFrameEntry.ChecksumType = PLinApi.TLIN_CHECKSUMTYPE_CLASSIC
         

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: Different connection results: PLIN-View PRO vs. PLIN_API_Console.py

Post by M.Maidhof » Mon 5. Aug 2024, 09:48

Hi Andy,

yes, you also have to set the checksum type depending on the configuration which is listed in the ldf. If you still have problems, send us the ldf to our support email address to be able to solve your problem.

regards

Michael

Post Reply