In message <5AOL$SBArbnBFAhV@ob5.co.uk>, John Cameron
writes
>Hi,
>
>I am gathering binary data from an RS232 port at 115,200baud and at 1
>character every 125us.
>
>I have a com callback installed to handle the data and a global variable
>in which to put it.
>
>The data is written to file and plotted on a strip chart.
>
>After about 5 seconds (around 43,000 bits of data), PlotStripChart()
>causes a stack overflow.
Sorry, that should be bytes of data.
>
>The code is below, can anyone see why this is happening? The variable
>'count' was added for debugging and is always in the order of 43,000
>when the stack overflows and the variable 'read' is always exactly 16.
>
>/* Global. */
>char data[40000];
>
>/* Com port configured. */
>status = OpenComConfig (port, "", 115200, 0, 8, 1, 32767, -1);
>
>/* Callback installed. */
>status = InstallComCallback (port, LWRS_RECEIVE, 100, 0, comCallback,0);
>
>/* This function is called when there is data in the RS232 input queue
>to be fetched. */
>void CVICALLBACK comCallback (int COMPort, int eventMask, void
>*callbackData)
>{
> /* Variables. */
> int len, read;
> static int count = 0;
>
> /* Loop while there is data to be fetched. */
> while( 0 < (len = GetInQLen (port)) ){
> /* Limit the amount fetched to the size of data[] */
> if(40000 < len)
> len = 40000;
>
> /* Read the data and note how many bytes where actually
>read. */
> read = ComRd (port, data, len);
>
>
> /* Write the data to the file. */
> fwrite (data, sizeof(char), len, fp);
>
> /* Display the data. */
> SetCtrlVal(panelHandle,PANEL_NUMERICMETER,data[read-1]);
> PlotStripChart (panelHandle, PANEL_STRIPCHART, data,
>read, 0, 0, VAL_CHAR);
>
> count+= read;
>
> /* Keep the UIR updated. */
> ProcessSystemEvents();
> };
>
>
>}
>
--
Regards,
John Cameron.
Type softly, read gently.