LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with PlotY in a thread

Hi all,

I have a problem using the function PlotY in a thread. The problem is that
the graph which is displayed is sometimes partially or completely garbled.

Here are the symptoms:
the graph data to be displayed always consists of a buffer of 1600 unsigned
short integers. In the thread (the only thread running in the application),
the buffer is filled first and then displayed. If I set a breakpoint just
before calling PlotY and inspect the data buffer, the data is always
correct, also when using the graphical array view. The buffer for PlotY is
malloc'ed once, somewhere in main() and before the thread is created. No
other thread is running, so no one is modifying the buffer during PlotY.

But: if I make a copy (memcpy) of the buffer to a GLO
BAL array first, that
is: just before calling PlotY, and call PlotY for this copy, the displayed
graph is always OK! If I make a copy to a LOCAL array, inside the function
that calls PlotY, the output is garbled again.

Error result with:

result = PlotY(pnl_Main, PNL_MAIN_CENTERSPECTRUM,
CallbackData->ccdbuffer, 1600,
VAL_UNSIGNED_SHORT_INTEGER, VAL_THIN_LINE,
VAL_CONNECTED_POINTS, VAL_SOLID, 0, VAL_RED);


OK result with (dummy is a GLOBALLY declared array dummy[1600]):

memcpy(dummy, CallbackData->ccdbuffer, 1600 * sizeof(WORD));
result = PlotY(pnl_Main, PNL_MAIN_CENTERSPECTRUM,
dummy, 1600,
VAL_UNSIGNED_SHORT_INTEGER, VAL_THIN_LINE,
VAL_CONNECTED_POINTS, VAL_SOLID, 0, VAL_RED);


What might be the problem? I am using Windows 2000, CVI 6.0. Threads are
implemented with the Windows SDK.

Thanks in advance for any suggestions & tips,

Roel Smeets

r.a.s.m.smeets@tue.nl.removeforspam
0 Kudos
Message 1 of 3
(2,706 Views)
Make sure that your graph is configured to "Copy Original Plot Data". You can verify this by editing the graph in the UI Editor. If that option is unchecked, the graph requires that the data always be available in your buffer. From your description of the problem, it sounds as if this could be a factor.

Luis Gomes
NI
0 Kudos
Message 2 of 3
(2,706 Views)
Luis Gomes wrote in
news:506500000005000000CA210100-1042324653000@exchange.ni.com:

> Make sure that your graph is configured to "Copy Original Plot
Data".
> You can verify this by editing the graph in the UI Editor. If that
> option is unchecked, the graph requires that the data always be
> available in your buffer. From your description of the problem, it
> sounds as if this could be a factor.
>
> Luis Gomes
> NI


That solved the problem !

Thanks,

Roel Smeets
0 Kudos
Message 3 of 3
(2,706 Views)