Eventfd in wxWidgets

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
MBajor
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Feb 03, 2020 7:14 pm
Location: Ukraine

Eventfd in wxWidgets

Post by MBajor » Tue Feb 04, 2020 6:55 pm

Hello everybody.
I'm looking for the best way to send an event from the kernel to user space.
The first thing I tried was the signals. Unfortunately, the widget program did not work properly. Often crashed.
After a bit of a look on the Internet, I decided to try the eventfd. Everything looks pretty clear in the kernel space.

Code: Select all

...
efd_ctx = eventfd_ctx_fdget(efd_file);
eventfd_signal(efd_ctx, plus_one);
eventfd_ctx_put(efd_ctx);
...
But how to "bind", "connect" a read event in wxWidgets user space unfortunately I can't find an example.
Thanks for the help.

User avatar
doublemax
Moderator
Moderator
Posts: 14509
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Eventfd in wxWidgets

Post by doublemax » Tue Feb 04, 2020 10:36 pm

This seems to be a Linux related problem which i don't know much about. But i'm pretty sure there is nothing in wxWidgets to help with that.

How would you do this in a non-wxWidgets application and why can't you do the same now?
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3787
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Eventfd in wxWidgets

Post by ONEEYEMAN » Tue Feb 04, 2020 11:34 pm

Hi,
Are you trying to write a driver for some specific hardware?
If so - the driver should have an ability to send a message to the user space.

Check the appropriate hardware documentation on which values to use and how to properly send the event from the driver to catch it in the user space.
The hardware documentation surely should have an example on how to send it and catch it in the user space.

Thank you.

MBajor
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Feb 03, 2020 7:14 pm
Location: Ukraine

Re: Eventfd in wxWidgets

Post by MBajor » Wed Feb 05, 2020 4:31 am

I'm trying to write a driver for a raspberry pi gpio. This is usually a polling through direct memory access (DMA) in the user's space. But I need to interact with a specific driver.
I think that in wxWidget I need to run some process that will waiting for an event in eventfd thru "select()" function.
Thanks for replay.

DavidHart
Site Admin
Site Admin
Posts: 3925
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Eventfd in wxWidgets

Post by DavidHart » Wed Feb 05, 2020 10:14 am

Hi,

AFAIK wxWidgets doesn't provide anything suitable.

However a few years ago I wrote my own code that calls select(). No guarantees about its quality, but you're welcome to look at it, copy it. The main function is ExecInPty::ExecuteInPty in https://sourceforge.net/p/fourpane/git4 ... e/Misc.cpp but check the rest of the class plus helpers too.

Regards,

David

Post Reply