Does TLINClientParam.clpOnReceiveEventHandle really work?

The free LIN software API (Application Programming Interface) for Windows® (only for usage with the PCAN-USB Pro CAN/LIN interface)
Locked
Murat.Ocakturk
Posts: 14
Joined: Wed 29. Jun 2016, 14:07

Does TLINClientParam.clpOnReceiveEventHandle really work?

Post by Murat.Ocakturk » Thu 2. Feb 2023, 07:26

Hello,

"TLINClientParam" enumeration has "clpOnReceiveEventHandle" for setting handle for the receive event.
However, It is not used in the samples inside PLinAPI. Also, it is not documented in the GetClientParam and SetClientParam functions. Supported client parameters are documented for GetClientParam and SetClientParam. "clpOnReceiveEventHandle" is not included.

So, my question: "clpOnReceiveEventHandle" really supported by SetClientParam function?

Thanks,
Murat

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Does TLINClientParam.clpOnReceiveEventHandle really work?

Post by K.Wagner » Thu 2. Feb 2023, 10:21

Hello Murat,

it seems as this parameter, clpOnReceiveEventHandle , as well as clpOnPluginEventHandle were forgotten to be included in the documentation of LIN_GetCleintParam and LIN_SetClientParam. I nevertheless can confirm, that these parameters are supported by both functions (and class methods).

The samples use the timer approach, so that the use of those parameter was not needed. Here is an example on how to set and get the parameter in C#:

PLinApi.SetClientParam

Code: Select all

// Member variable definition 
System.Threading.AutoResetEvent m_Event;
...

// Member variable initialization
m_Event = new System.Threading.AutoResetEvent(false);
...

// Configuring reception event
...
int buffer = m_Event.SafeWaitHandle.DangerousGetHandle().ToInt32();
if (Peak.Lin.PLinApi.SetClientParam(m_hClient, Peak.Lin.TLINClientParam.clpOnReceiveEventHandle, buffer) == Peak.Lin.TLINError.errOK)
    MessageBox.Show("Handle was Configured: " + buffer.ToString());
else
    MessageBox.Show("Error configuring event handle ");
...
PLinApi.GetClientParam

Code: Select all

// Retrieving reception event 
int buffer;
if (Peak.Lin.PLinApi.GetClientParam(m_hClient, Peak.Lin.TLINClientParam.clpOnReceiveEventHandle, out buffer, 4) == Peak.Lin.TLINError.errOK)
    MessageBox.Show("Configured handle: " + buffer.ToString());
else
    MessageBox.Show("Error retrieving event handle ");
You need to use a thread to wait for the event signalization, when a message is received

Code: Select all

System.Threading.Thread m_Thread;
...
m_Thread = new System.Threading.Thread(DoRead);
m_Thread.IsBackground = true;
m_Thread.Start();
...
private void DoRead()
{
     while (true)
    {
        if(m_Event.WaitOne(50))
            ReadMessages();
    }
}                
I hope this helps you. Thanks for bringing this to our attention.
Best regards,
Keneth

Murat.Ocakturk
Posts: 14
Joined: Wed 29. Jun 2016, 14:07

Re: Does TLINClientParam.clpOnReceiveEventHandle really work?

Post by Murat.Ocakturk » Thu 2. Feb 2023, 11:42

Thank you Keneth for quick and perfect response.

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Does TLINClientParam.clpOnReceiveEventHandle really work?

Post by K.Wagner » Thu 2. Feb 2023, 14:56

you are welcome. Closed.
Best regards,
Keneth

Locked