Re: newbie repetetive comedi read questions

On 21/07/05 09:15, Per Arlock wrote:
>    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;

cmd.stop_arg should be 0 when cmd.stop_src is TRIG_NONE.  You should
compare cmd.stop_arg to TRIG_COUNT here, I think.  Maybe this is the
problem.

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

Does comedi_command return 0 okay?  I guess it does, otherwise the
remaining code wouldn't work.

> 
>      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?

What does the C library's 'errno' variable get set to when it fails?  (I
don't know how you access that from Pascal, but I'm sure it must be
possible!  I'm assuming that the 'cread' Pascal function binds to the
'read' system call.)

> If I issue the:
>            ret := comedi_command(dev,cmd);
> between readings it works but then I lose data.

That will start off a new command if the old command has finished,
otherwise it returns an error.  The old command isn't meant to finish as
you are setting it up with a stop_src of TRIG_NONE, so setting up the
new command should fail.  This means there is something wrong with the
old command.  Try correcting 'stop_arg' as mentioned above and see if
that cures the problem.

> What would be a better solution to repetetively read data and feed a buffer?

You are on the right lines already.

> I would be very gratefuls for information on what I do wrong!
> 
> Best Regards!
> 
> Per Arlock

Good luck!

-- 
-=( Ian Abbott _at_ MEV Ltd.    E-mail: <abbotti_at_mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

Received on 2005-07-21Z10:29:53