Diagnostics on LIN

The free LIN software API (Application Programming Interface) for Windows® (only for usage with the PCAN-USB Pro CAN/LIN interface)
Post Reply
Gyula.L
Posts: 15
Joined: Fri 18. Oct 2024, 13:05

Diagnostics on LIN

Post by Gyula.L » Tue 5. Nov 2024, 10:02

Hello,

I try to set up an UDS diagnostic tool using PLIN. I know diagnostics well, but I have some troubles to program it with PLIN.

I can't find any example how to do it, so I do try and error:
- RegisterClient
- SetFrameEntry using FrameId 0x3C as Publisher
- SetFrameEntry using FrameId 0x3D as Subscriber
- SetSchedule for MasterRequest, Delay=20 ms, the only FrameID is 0x3C; ScheduleNumber=0
- SetSchedule for SlaveResponse, Delay= 20 ms, the only FrameID is 0x3D; ScheduleNumber=1
- InitHardware
- Write a MasterRequestFrame --> this will be physically sent
- StartScheduler 1 --> I expect to see at least the frame headers sending, it does, but always with 16 seconds delay :-( There must be somethig wrong with Delay at calling SetSchedule.

How should ist basically work? Do I need to StartSchedule=0 before I send a request and StartSchedule=1 after a sent request, expecting response?

Is there any example code available?

Gyula

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

Re: Diagnostics on LIN

Post by M.Maidhof » Tue 5. Nov 2024, 11:58

Hello,

when working with LIN Diagnose frames, IMHO it will be better to not use the scheduler for that. We typical use a multimediatimer and use LIN_Write() to send out the 3C publisher and the 3D subscriber frame. Take care to read the frames with LIN_Read() in a loop using also a multimedia timer to be able to see the answers of your requests.

regards

Michael

Gyula.L
Posts: 15
Joined: Fri 18. Oct 2024, 13:05

Re: Diagnostics on LIN

Post by Gyula.L » Tue 5. Nov 2024, 12:50

Okay fine! It works almost...

The 0x3D request will be sent, then I send the 0x7D (0x3D), and I see on the bus monitor, that the ECU has filled its payload into the frame, as I expected.
I read the response with Read() in a loop for 1 second, but the function returns always TLINError = errRcvQueueEmpty. I start the reading right after sending the 0x3D Id.
Do I need to initialize anything in order to read?

Another question, even if it works without any scheduler: I can create schedule with SetSchedule() using TLINSlotType = sltMasterRequest and sltSlaveResponse. What is the usage of these entries?

Gyula

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

Re: Diagnostics on LIN

Post by M.Maidhof » Tue 5. Nov 2024, 14:17

Hi,

please open the filters for all messages with SetClientFilter() to be able to read all LIN frames.

About your question of TLINSlotType : please see PLIN API documentation on page 13

regards

Michael

Gyula.L
Posts: 15
Joined: Fri 18. Oct 2024, 13:05

Re: Diagnostics on LIN

Post by Gyula.L » Wed 6. Nov 2024, 08:18

Hello,

I use LabVIEW 32-bit, I created a wraper around the PlinApi.dll. All functions are working, but there is an issue I can't solve.

If I call SetClientFilter() before Read(), calling the Read() function causes LabVIEW crash.

I have the following setup:
- RegisterClient()
- ConnectClient()
- SetClientFilter() : iRcvMask = 0xFFFFFFFFFFFFFFFF
- InitHardware()
- Write()
- Read() in a loop, but the first call of Read() crashes LabvIEW.

If I don't call SetClientFilter(), there is no LabVIEW crash, but the read queue is empty :-(

I am pretty sure that I call the dll functions in the right way: stdcall, 32-bit dll, all parameter types match the prototype in the .h file. And, all other functions are working, only this one not.

I tried to exchange SetClientFilter() through RegisterFrameId(), the same crash orrurs at Read().

Any idea, what could go wrong?

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

Re: Diagnostics on LIN

Post by M.Maidhof » Wed 6. Nov 2024, 08:58

Hi,

we can't help in any LabView related issues, but there are ready to use PLIN LabView VIs available by the company KDI/digiinst:

https://www.digiinst.de/c/software

They also offer support for their LabView drivers

regards

Michael

Post Reply