newbie repetetive comedi read questions

Hi,

I would very much like to get some information on how to do repetetive readings in comedi without losing data.
I want the reading start at a certain time and last past when the board buffer is full.
As a newbie I thought that I could issue a read whenever I have issued a command :comedi_command(dev,cmd);{when the timer has finished counting the sampling starts} which I have found out from the demos from comedi. When the reading is done I want to continuously feed a buffer
with data. I am using an pci adv1710 board and do not know how to repetetively read of the buffer.

Part of the programcode is shown here:
The trigger section runs fine.

           subdevice:=0; {analog input}
           det:=0;

           cmd.start_src := TRIG_NOW;{0}
           cmd.start_arg := 0;

I have the command filled with :
function prepare_cmd_lib(dev : comedi_t; subdevice : integer; var cmd : comedi_cmd) : integer;
var
   ret :  integer;
begin
   cmd.subdev := 0;
   cmd.flags  := 0;
   cmd.start_src := TRIG_NOW;
   cmd.start_arg := 0;
   cmd.scan_begin_src := TRIG_FOLLOW;
   cmd.scan_begin_arg := 0;
   cmd.convert_src := TRIG_TIMER;
   cmd.convert_arg := 0;
   cmd.scan_end_src := TRIG_COUNT;
   cmd.scan_end_arg := 0{2};               { fylls i nedan. }
   cmd.stop_src := TRIG_NONE;           { 1 = TRIG_NONE, håll på för evigt. }
   cmd.stop_arg := 0;
   cmd.chanlist := _at_chanlist;
   cmd.chanlist_len := 0;
   cmd.data := _at_data;
   cmd.data_len := 0;

  {* This comedilib function will get us a generic timed command*}
   ret := comedi_get_cmd_generic_timed(dev,subdevice,cmd,round(1e9/freq));
   if ret < 0 then
                      begin
                        writeln('comedi_get_cmd_generic_timed failed');
                        prepare_cmd_lib := ret;
                      end
                          else
   begin
      { Modify parts of the command }
      cmd.chanlist     := _at_chanlist;
      cmd.chanlist_len := n_chan;
      cmd.scan_end_arg := n_chan;
      if cmd.stop_src = TRIG_NONE then
      begin
         cmd.stop_arg := n_scan;
      end;
      prepare_cmd_lib := 0;
   end;

and here I call do the call:
           ret := comedi_command(dev,cmd);

     begin
        begin {varv}
         for varv := 1 to 5 do
          begin
           ret := cread(comedi_fileno(dev),_at_bufarr[varv],BUFSZ);
---------------------------------------------------
Here I can only do this 1 time! Why is that?
If I issue the:
           ret := comedi_command(dev,cmd);
between readings it works but then I lose data.
What would be a better solution to repetetively read data and feed a buffer?
---------------------------------------------------
           a := 0;
         for varv := 1 to 5 do

        begin
           drainvarden(a,varv, storbufv^, storbuff^, storbuft^,bufarr);
           a := a + (BUFSZ div 8);
        end;
 
I would be very gratefuls for information on what I do wrong!

Best Regards!

Per Arlock

Received on 2005-07-21Z07:15:01