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

Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Postby 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);
Fojtik
 
Posts: 13
Joined: Thu 8. Feb 2018, 13:06

Re: Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Postby 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?
RcvEvent1.PNG
TPCANParameter page
RcvEvent1.PNG (37.71 KiB) Viewed 376 times

or at least the introduction of it?
RcvEvent0.PNG
Help Introduction - Reading with events
RcvEvent0.PNG (47.09 KiB) Viewed 376 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
RcvEvent4.PNG
Executable file within the PCAN-Basic package
RcvEvent4.PNG (16.81 KiB) Viewed 376 times

or maybe the dedicated PDF Help file for parameters:
RcvEvent3.PNG
PDF help file
RcvEvent3.PNG (74.29 KiB) Viewed 376 times


check again... maybe you can find it now....
Best regards,
Keneth
K.Wagner
Software Development
Software Development
 
Posts: 446
Joined: Wed 22. Sep 2010, 12:36
Location: Darmstadt, Germany

Re: Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Postby 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/viewtopic.php?f=120&t=2511 is faster than PCAN-LIGHT. May be that it does not matter which API is used.
Fojtik
 
Posts: 13
Joined: Thu 8. Feb 2018, 13:06

Re: Missing CAN_SetRcvEvent() equivalent in PCAN-BasicAPI

Postby 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
M.Maidhof
Support
Support
 
Posts: 936
Joined: Wed 22. Sep 2010, 13:00
Location: Darmstadt, Germany


Return to Suggestions & Feature Requests



cron

This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy