- From: Bernd Porr <BerndPorr_at_f2s.com>
- Date: Fri, 16 Jul 2004 16:09:28 +0100
Hi!
No need to wait for the data. You can fetch it whenever you want.
This is a code fragment from qtscope:
http://www.cn.stir.ac.uk/~mhh1/qtscope/
--------------------------
while (comedi_get_buffer_contents(comediDevice,comediSubdevice))
{
// read data from device
if (read(comedi_fileno(comediDevice), dataBuffer,
comediChannels*2) == 0)
{
cerr << "Error: end of Aquisition\n";
return;
}
if( num < MAX_DATA_BUFFER )
{
// fill the data buffer
for( i = 0; i < comediChannels; i++)
convDataBuffer[i][num] = ((sampl_t *)dataBuffer)[i]* \
(myRanges[i]->max-myRanges[i]->min)/4095.0+
myRanges[i]->min;
num++;
}
else
cout << "data buffer overflow\n";cout.flush();
}
// announce data to plugins
---------------------------
Basically this routine is called from a QT-timer which is terribly
unreliable. Thus, the buffer contains more or less data or is even
empty. This is checked by comedi_get_buffer_contents. The while loop
loops as long as data is there ("read"). The data is then plotted on the
screen as soon as the buffer has been emptied.
Hope you got the idea. There's also a simpler version of the program:
http://www.linux-usb-daq.co.uk/applications/comedi-scope/
/Bernd
www: http://www.berndporr.me.uk/
http://www.linux-usb-daq.co.uk/
Mobile: +44 (0)7769 506746
Work: +44 (0)141 330 5237
University of Glasgow
Department of Electronics & Electrical Engineering
Room 519, Rankine Building, Oakfield Avenue,
Glasgow, G12 8LT
Christian Fleischer wrote:
> Hello!
>
> I've comedi v0.7.68, comedilib 0.7.21 and wonder about something when I use
> the "cmd.c" test-program:
>
> When I set the number of samples to deliver to 4000, the frequency to 1000 and
> the number of channels to 1, the read command always waits for 1024 bytes.
> Is it possible to make this queue smaller, so that the read command returns
> faster with less bytes?
> The command line for the test-program is:
> cmd -N 4000 -F 1000 -n 1 -v
>
> Is there any other option for a comedi command to specify how long this
> internal buffer is?
>
> Thanks a lot,
> Christian
>
>
>
>
Received on 2004-07-16Z14:09:28