Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

This is a forum dedicated to discuss suggestions about the functionality of any software product as well as the study of new interesting ideas to develop
Post Reply
Fojtik
Posts: 30
Joined: Thu 8. Feb 2018, 13:06

Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Post by Fojtik » Thu 8. Feb 2018, 13:17

I did not find any equivalent of function CAN_SetRcvEvent() in PCAN-Basic API.
The registered event could improve performance of code a lot.

Without such event, the code will need to pool CAN_Read very frequently. And it could drop overall performance.

Code: Select all

     result = WaitForMultipleObjects(2,hh,FALSE,15);  
     if(result == WAIT_OBJECT_0+1) 	 goto CONTINUE;	//look to a PopMsgFromQueue() (continue will check while(), goto skips it)

     if(result==WAIT_OBJECT_0 || result==WAIT_TIMEOUT)
     {
        Res = CAN_Read(&peakMsg);

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

Re: Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Post by K.Wagner » Thu 8. Feb 2018, 13:58

Fojtik wrote: did not find any equivalent of function CAN_SetRcvEvent()
are you sure you have tried to search for it?

did you read the *.chm help file?
TPCANParameter page
TPCANParameter page
RcvEvent1.PNG (37.71 KiB) Viewed 8823 times
or at least the introduction of it?
Help Introduction - Reading with events
Help Introduction - Reading with events
RcvEvent0.PNG (47.09 KiB) Viewed 8823 times
did you check the example code?

Code: Select all

	// Sets the handle of the Receive-Event.
	//
	stsResult = m_objPCANBasic->SetValue(m_PcanHandle, PCAN_RECEIVE_EVENT ,&m_hEvent, sizeof(m_hEvent));

	// If it fails, a error message is shown
	//
	if (stsResult != PCAN_ERROR_OK)
	{
		::MessageBox(NULL, GetFormatedError(stsResult), "Error!",MB_ICONERROR);
		m_Terminated = true;
		return 1;
	}

	// While this mode is selected
	//
	while(!m_Terminated)
	{
		//Wait for CAN Data...
		result = WaitForSingleObject(m_hEvent, 1);

		if (result == WAIT_OBJECT_0)
			ReadMessages();
	}
did you tried to run any of the examples? there is even an exe within the PCAN-Basic package... double click and you can see it
Executable file within the PCAN-Basic package
Executable file within the PCAN-Basic package
RcvEvent4.PNG (16.81 KiB) Viewed 8823 times
or maybe the dedicated PDF Help file for parameters:
PDF help file
PDF help file
RcvEvent3.PNG (74.29 KiB) Viewed 8823 times
check again... maybe you can find it now....
Best regards,
Keneth

Fojtik
Posts: 30
Joined: Thu 8. Feb 2018, 13:06

Re: Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Post by Fojtik » Thu 8. Feb 2018, 15:03

K.Wagner wrote:are you sure you have tried to search for it?
Excuse me. I attempted to rewrite program written in PCAN-Light to PCAN-basic.

Code: Select all

///////////////////////////////////////////////////////////////////////////////
//  CAN_SetRcvEvent()
//  This function is used to set the Event for the Event Handler
//
//  Possible Errors: ILLCLIENT ILLPARAMTYPE ILLPARAMVAL NOVXD
//
DWORD __stdcall CAN_SetRcvEvent(HANDLE hEvent);
I have searched for any function that has a HANDLE as parameter.

Code: Select all

/// <summary>
/// Configures or sets a PCAN Channel value 
/// </summary>
/// <remarks>Parameters can be present or not according with the kind 
/// of Hardware (PCAN Channel) being used. If a parameter is not available,
/// a PCAN_ERROR_ILLPARAMTYPE error will be returned</remarks>
/// <param name="Channel">"The handle of a PCAN Channel"</param>
/// <param name="Parameter">"The TPCANParameter parameter to set"</param>
/// <param name="Buffer">"Buffer with the value to be set"</param>
/// <param name="BufferLength">"Size in bytes of the buffer"</param>
/// <returns>"A TPCANStatus error code"</returns>
TPCANStatus __stdcall CAN_SetValue(
        TPCANHandle Channel,
        TPCANParameter Parameter,
        void* Buffer,
		DWORD BufferLength);
And I forget to CAN_SetValue. Thank you again.

I still do not know whether PCAN-BASIC http://www.peak-system.com/forum/viewto ... 120&t=2511 is faster than PCAN-LIGHT. May be that it does not matter which API is used.

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

Re: Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Post by M.Maidhof » Thu 8. Feb 2018, 15:23

Hi,

there is no difference in speed between the different APIs, it is just a question of how you program your application!

regards

Michael

Post Reply