send event from extension?

M

Markus von Ehr

Hi everybody,

I'd like to create an event which I have to post/set
within an extension (new frame signal from a camera).
In python I would like to react on this event.
How could I create and post the event in c and
how could I receive it in a python event handler
routine done with the win32event module?

Thanks for any answer,

Markus
 
R

Roger Upole

You could use win32event.CreateEvent and pass the handle into your
extension,
call SetEvent in the c code, and use win32event.WaitForSingleObject to wait
for
the signal. Alternately, you could create a named event and call OpenEvent
to
get a handle instead of passing it around.
hth
Roger
 
M

Markus von Ehr

Roger said:
You could use win32event.CreateEvent and pass the handle into your
extension,
call SetEvent in the c code, and use win32event.WaitForSingleObject to wait
for
the signal. Alternately, you could create a named event and call OpenEvent
to
get a handle instead of passing it around.
hth
Roger

Hi Roger,

I don't know how to pass the handle. Is only the event.handle
important? And how to wait for the event?
Do I have to verify that the correct event fired my
WaitForSingleObject?
Can you help me?
I do the following in my python code:

import win32event
..
..
..
evt = win32event.CreateEvent(None, 0, 0, None)

# pass event to c-extension
cam_ext.SetEvent(evt.handle)


# and wait for the event
win32event.WaitForSingleObject(evt)


###########################################

// c-extension

int event;

PyObject *cam_ext_SetEvent(PyObject *pSelf, PyObject *pArgs)
{

if (!PyArg_ParseTuple(pArgs, "i", &event))
return NULL;

Py_INCREF(Py_None);
return Py_None;
}


// Set the event

::SetEvent(event);

Do you think it's correct? generally SetEvent needs an event object and
not only a number?

Thanks for hints,

Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top