[prev in list] [next in list] [prev in thread] [next in thread] 

List:       comedi
Subject:    comedi_command_test fails using rtai_comedi
From:       "Andreas Leuner" <al14 () inf ! tu-dresden ! de>
Date:       2005-02-15 17:33:47
Message-ID: 32923.141.76.47.9.1108488827.squirrel () mail ! inf ! tu-dresden ! de
[Download RAW message or body]

Hi all,

I want to use a National Instruments PCI-6024E from a LXRT program. I have
linux-2.4.27 and rtai-3.1 installed, together with a recent (downloaded
2005-02-15) comedi cvs snapshot. The 'cmd' demo program from comedilib works
fine with my setup. Also I have been able to get comedi_data_reads to work
under LXRT.
However if I test a comedi command using comedi_command_test I always get 1
(one) as a result (For this I use the same chanspec as with the
comedi_data_reads). If I understand correctly this means that there were
invalid or missing triggers in the command I wanted to test.
From reading the comedi handbook and the source code (in ni_mio_common.c) I
believe this probably can't be the case. I just built a very simple command
that just had to work. Trying to hunt the cause of this I've "flooded" the
call stack down to ni_ai_cmdtest (in ni_mio_common.c) with messages that
rt_printk the contents of that command.
From that I learnt that the command arriving there has all fields set to zero
(which of course makes the test result correct ;-( ). The error seems to
happen in rt_comedi_command_test (in kcomedi-module.c), where the command
that is passed inside parameter cmd is still the one I made, but the command
that rt_comedi_command_test passes to comedi_command_test is no longer.
Trying to access the command variable causes a kernel page fault. If left
alone instead and inspected later inside comedi_command_test the command
appears zeroed out.

These are the IMHO relevant parts of my code:
-----------------------------------------------------------------------
#include rtai_comedi.h
#define BUFF_LEN 4096

comedi_command *mpComediCommand;
sampl_t *data;
-----------------------------------------------------------------------

This is the portion of my code that prepares the command:
-----------------------------------------------------------------------
//prepare comedi command:
unsigned int *chanlist;
mpComediCommand = rt_comedi_alloc_cmd(&chanlist,1,&data,BUFF_LEN);
mpComediCommand->subdev=mSubdevice;

// request real time
mpComediCommand->flags|=TRIG_RT;

//start immediately
mpComediCommand->start_src=TRIG_NOW;
mpComediCommand->start_arg=0;

mpComediCommand->scan_begin_src=TRIG_TIMER;
mpComediCommand->scan_begin_arg=100000;

mpComediCommand->convert_src=TRIG_TIMER;

//this should be properly corrected by comedi_command_test(...)
mpComediCommand->convert_arg=0;

mpComediCommand->scan_end_src=TRIG_COUNT;
mpComediCommand->scan_end_arg=1;
mpComediCommand->stop_src=TRIG_COUNT;
mpComediCommand->stop_arg=getPacketsToSend();

chanlist[0] = CR_PACK(mComediChannel,mComediRange,AREF_GROUND);

mpComediCommand->chanlist_len=1;
mpComediCommand->data_len=BUFF_LEN;

cout << "Initiating test of Comedi command at " << mpComediCommand <<endl;
// print the contents command to stdout:
dump_cmd(mpComediCommand);
int result = comedi_command_test(mpComediDevice,mpComediCommand);
dump_cmd(mpComediCommand);
-----------------------------------------------------------------------
On rare occasions this comedi_command_test seems to work correctly. Then it
returns 3. But then, with e.g. a reboot between I witness crashes or again
just the behavior I described at the beginning of my mail.

Please help me determining the cause of this problem since it seems to be
beyond my skills.


_______________________________________________
comedi mailing list
comedi@comedi.org
https://cvs.comedi.org/cgi-bin/mailman/listinfo/comedi
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic