LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting data from SendMessage function

I want to load EEG data to PC.

I have the DLL file and related header files.

 

in DLL,

Key function is,

"void Start_Stream()", which operates A/D convert and data transfer to PC.

 

The trouble is :

 

The function has no return value, but transfers data using

 

SendMessage(TARGET_WINDOW, WM_AcqUnitData, 0, (LPARAM)AcqUnitData);  // Predefined function in user32.dll


Here, "TARGET_WINDOW"  refers the handle of message target window,

WM_AcqUnitData is just a constant(WM_USER+1), which represents that this is user-defined message.

(LPARAM)AcqUnitData, which stores EEG data values,  refers the pointer of stream memory.
 

Are there any ways to load the data (LPARAM)AcqUnitData, transfered by "SendMessage()" function in LABVIEW? 

0 Kudos
Message 1 of 22
(6,614 Views)

Hi HYSEO,

see this link

http://sine.ni.com/devzone/cda/epd/p/id/4394

it contains a library and a wrapper dll.

 

If you can't open them, then please see this link

http://forums.ni.com/ni/board/message?board.id=170&message.id=283998&requireLogin=False

 

Mike

Message 2 of 22
(6,586 Views)
I'm wondering if the OP solved this.  I have a similar application, where I want to use SendMessage or PostMessage (with WM_USER+1 ... WM_USER+N) from my own wrapper DLL, and handle the messages in my VI.  I looked at the example code and I think some of what I need is there, but I think I don't need a que if I only use SendMessage.  
0 Kudos
Message 3 of 22
(6,354 Views)
Anybody?
0 Kudos
Message 4 of 22
(6,335 Views)

Hi garya505,

can you explain what you need?

If you want to trigger something in your LabVEW code, then maybe this will also help.

 

 

Mike

Message 5 of 22
(6,333 Views)

I am doing exactly what the code in your link shows how to do, and I have PostLVUserEvent working from my wrapper DLL.  However, as you know, this puts the event in a queue.  What I need is for the calling function in the wrapper DLL to wait until the VI actually handles the event.  Ideally, some sort of sunchronization event for the wrapper DLL function.  A semaphore might work.

 

 

0 Kudos
Message 6 of 22
(6,325 Views)

Hi garya505,

you can wait inside your dll, til another function of your dll was called. Call the other funtion from after the event structure, after you have handled the event.

 

Mike

0 Kudos
Message 7 of 22
(6,312 Views)
That might work, thought I'm not sure how I would block in the callback without something like a semaphore.
0 Kudos
Message 8 of 22
(6,288 Views)

Hi garya505,

what i meant was, you can start a process in your dll file which runs after you "activate" the event in labview and which wait til your labview vi sends something back to the waiting process. Parallel to the response of your vi, you should use a timeout which ends the process in case of an error.

 

Mike

0 Kudos
Message 9 of 22
(6,276 Views)

Yeah, that's sort of what I am trying now.  This is video hardware.  When the hardware completes a task, typically receiving or sending a frame, it generates a local interrupt which causes a callback function in the wrapper DLL to be called.  The callback function must be blocked until any memory access is completed.  In this callback function I post a LabVIEW event (PostLVUserEvent) upon which a LabVIEW VI will do something.  What it actually does is application dependent, but typically reading data from the card when receiving or writing data to the card when transmitting.  I don't know how long the VI will take to complete it's work, so I need the callback to block until the LabVIEW VI is done doing that. 

 

I am starting a synchronization thread in the wrapper DLL for each card.  The thread is sort of a simple state machine which progresses through START, WAIT, END callback states.  The thread will enter the START state when the callback is called the LabVIEW User Event is posted.  The thread will then block on the WAIT event and the callback will then block on the END event.  I am adding a function to the wrapper DLL to allow a VI to call using a CLN to set the WAIT event.  When the WAIT event is set, the thread will be unblocked and will set the END event.  At this point the callback will exit and the card will be able to access the memory again.

 

I guess a diagram would help here ...

 

 

0 Kudos
Message 10 of 22
(6,270 Views)