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