CAN_Read and CAN_ReadFD as blocking call?

This forum covers issues concerning multiple software products.
Locked
Ales1000
Posts: 19
Joined: Fri 4. Oct 2019, 09:01

CAN_Read and CAN_ReadFD as blocking call?

Post by Ales1000 » Thu 28. May 2020, 07:37

Hello,

is it possible to use CAN_Read() and CAN_ReadFD() functions as blocking call in Linux and Windows using PCANBasic lib? For example like recv() function for receiving TCP/UDP packets or getchar() function for reading inserted text to command prompt.

Thank you.

Ales

M.Heidemann
Sales & Support
Sales & Support
Posts: 425
Joined: Fri 20. Sep 2019, 13:31

Re: CAN_Read and CAN_ReadFD as blocking call?

Post by M.Heidemann » Thu 28. May 2020, 16:11

Hello,

The PCANBasic API does not use blocking calls.

Our Linux APIs (With the exception of PCANBasic)(CAN 2.0 API / CAN FD API) do provide such functions,
you can learn more about this in the documentation for our Linux driver package, see the chapter 5 "Developer Guide" -> "CharDev Mode":

http://www.peak-system.com/fileadmin/me ... an_eng.pdf

Best Regards

Marvin

Ales1000
Posts: 19
Joined: Fri 4. Oct 2019, 09:01

Re: CAN_Read and CAN_ReadFD as blocking call?

Post by Ales1000 » Fri 19. Jun 2020, 14:50

Hi,

thank you for your response. I found out, that Windows PCANBasic can use it this way normally. So problem is, that Linux PCANBasic does not support the same things as the Windows version? If yes, it would explained, that PCAN-view on Windows does not utilize processor too much, but on the Linux, it utilize one whole one thread, maybe (while(1){read(...)...}).

As I see in the Linux manual, the functions looks sometimes same as in PCANBasic API and some of them are different, why is it not like in PCANBasic API, it seems to be chaotic and it is annoying when you implement cross-platform API and you have to use you different libraries and commands for the same device.

Thank you for your response.

Ales

M.Heidemann
Sales & Support
Sales & Support
Posts: 425
Joined: Fri 20. Sep 2019, 13:31

Re: CAN_Read and CAN_ReadFD as blocking call?

Post by M.Heidemann » Fri 19. Jun 2020, 15:33

Hello,

What are your refering to here: "I found out, that Windows PCANBasic can use it this way normally" ?
"As I see in the Linux manual, the functions looks sometimes same as in PCANBasic API and some of them are different, why is it not like in PCANBasic API, it seems to be chaotic and it is annoying when you implement cross-platform API and you have to use you different libraries and commands for the same device."
You are refering to our Linux APIs? Both are completely different APIs which just happen to serve the same functionality (Using our CAN-Interfaces),
the PCAN 2.0 API and PCAN FD API support features that PCANBasic does not. By offering PCANBasic for Linux we want to make it as easy as possible for users
to write applications for both platforms.

If you want to implement a cross platform application, i'd recommend to take a look at our Python or Java-examples for PCAN-Basic.


Best Regards

Marvin

Ales1000
Posts: 19
Joined: Fri 4. Oct 2019, 09:01

Re: CAN_Read and CAN_ReadFD as blocking call?

Post by Ales1000 » Fri 19. Jun 2020, 15:41

I was trying to tell, that in Windows it is possible to use blocking call for reading for example by command:

CAN_SetValue(PCAN_USBBUS1, PCAN_RECEIVE_EVENT, &hEvent, sizeof(hEvent))

I do not understand why this does not work in Linux.

I have already implemented a cross-platform interface based on PCANBasic for Windows and Linux for commanding PCANs. I do not want to use PCANBasic for Windows, PCAN 2.0 API for CAN-HIGH, and PCAN FD API for CAN-FD, this is mad!

Why is it too simple on Windows and too complicated on Linux?

Thank you.

Ales

M.Heidemann
Sales & Support
Sales & Support
Posts: 425
Joined: Fri 20. Sep 2019, 13:31

Re: CAN_Read and CAN_ReadFD as blocking call?

Post by M.Heidemann » Fri 19. Jun 2020, 16:10

Hello,

Okay, this clears things up.

There is information regarding this in the PCANBasic documentation, which might went unnoticed:
ReceiveEvent.PNG
ReceiveEvent.PNG (262.61 KiB) Viewed 841 times
The Windows Event Object does not exist on Linux, but still you can use events on Linux, the handling is different though,
for reference take a look at /libpcanbasic/examples/c++/src/pcaneventread.cpp.


For further questions feel free to contact me again.


Best Regards

Marvin

Ales1000
Posts: 19
Joined: Fri 4. Oct 2019, 09:01

Re: CAN_Read and CAN_ReadFD as blocking call?

Post by Ales1000 » Mon 22. Jun 2020, 09:30

Hi Marvin,

Thank you, this is exactly what I looked for.

Ales

Locked