- From: qiang zeng <zengqianghit_at_gmail.com>
- Date: Wed, 26 Jan 2005 00:16:34 +0800
HI, All,
I didn't find my yesterday post here, so plz excues me for posting
again 'cause it's really urgent for me.
recently i have reinstalled my pc. and found that my program can still
run on it, but if
i do 'make clean' and recompile. the comedi would give such errors. (i
found the new compiled file's size is a little bit smaller than the
previous one)
I am using Redhat linux9.0, rtai24.1.11 and comedi0.7.65 comedilib 0.7.21.
i don't think it's the codes' problem.can't figure out what the reason is.
Thanks in Advance,
ZQ
Error performing insn: Success
Error performing insn1: Success
Error performing insn2: Success
Error performing insn3: Success
Error performing insn2: Success
Error performing insn3: Success
Error performing insn2: Success
Error performing insn3: Success
Error performing insn2: Success
Error performing insn3: Success
Error performing insn2: Success
Error performing insn3: Success
Error performing insn4: Success
Error performing insn5: Success
Error performing insn6: Success
Error performing insn7: Success
Error performing insn8: Success
Error performing insn: Success
MASTER INIT: name = 2102370922, address = 0xc1ed0230.
REALTIME THREAD INIT: index = 1, name = 2001, address = 0xc1ed08a0.
----------------------------------
This is part of my comedi code:
void initialiseCounter (void)
{
lsampl_t op[2], lastData;
comedi_insn insn;
comedi_insn insnRC0, insnRC1;
//comedi_insn insnRC[2];
//comedi_insnlist il;
unsigned int pfi = 7;/*subdevices index with global subcounter*/
int n = 0, i = 0, nError = 0;
/* open the device */
device = comedi_open(filename);
if ( NULL == device )
{
printf ( "Error opening comedi device: %s\n",
comedi_strerror(comedi_errno() ) );
}
/* lock the subdevice */
nError = comedi_lock(device, subcounter);
if( -1 == nError )
{
/* there was an error locking the device, we can continue but
might be unexpected results */
printf("Error locking subdevice: %s\n",
comedi_strerror(comedi_errno()));
}
// set up PFI8 for input
op[0] = COMEDI_INPUT;
insn.insn = INSN_CONFIG;
insn.n = 1;
insn.data = op;
insn.subdev = pfi;
insn.chanspec = CR_PACK ( pfi_chan, 0, 0 );
if ((comedi_do_insn ( device, &insn ) ) < 0 )
{//Setting the direction of PFI8 pin as input
printf ( "Error performing insn: %s\n",
comedi_strerror(comedi_errno() ) );
}
// set up PFI3 for input
op[0] = COMEDI_INPUT;
insn.insn = INSN_CONFIG;
insn.n = 1;
insn.data = op;
insn.subdev = pfi;
insn.chanspec = CR_PACK ( pfi_chan1, 0, 0 );
if ((comedi_do_insn ( device, &insn ) ) < 0 )
{//Setting the direction of PFI3 pin as input
printf ( "Error performing insn1: %s\n",
comedi_strerror(comedi_errno() ) );
}
for ( i = 1; i <= 5; i++ )
{//Sequence in configuring the card GPCTR
switch ( i )
{
case 0:
// reset all counter settings
op[0] = GPCT_RESET;
n = 1;
break;
case 1:
// set the source of the counts
// if this is counter 0, the external pin is PFI8/GPCT0_SOURCE
// if this is counter 1, the external pin is PFI3/GPCT1_SOURCE
//
op[0] = GPCT_SET_SOURCE;
op[1] = GPCT_EXT_PIN; // set to external pin as above
// op[1] = GPCT_INT_CLOCK; // set to the internal clock
n = 2;
break;
case 2:
// set the gate to latch the input to
// if this is counter 0, the external latch would be
PFI10/GPCT0_GATE
// if this is counter 1, the external latch would be
PFI4/GPCT1_GATE
op[0] = GPCT_SET_GATE;
op[1] = GPCT_NO_GATE; //no latch on the gate
// op[1] = GPCT_EXT_PIN; // latch to the external
pin as above
n = 2;
break;
case 3:
// set the direction the counter should count ///??up and down??
op[0] = GPCT_SET_DIRECTION;
op[1] = GPCT_HWUD; // UP and Down counter
// op[1] = GPCT_DOWN; // decrement the counter
n = 2;
break;
case 4:
// set the type of counter //??simple event??
op[0] = GPCT_SET_OPERATION;
op[1] = GPCT_SIMPLE_EVENT; //count the edges of the pulse
n = 2;
break;
}
insn.insn = INSN_CONFIG;
insn.n = n;
insn.data = op;
insn.subdev = subcounter;
insn.chanspec = CR_CHAN(counter_chan);//what is this CR_CHAN command??
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{//Sending command to configure the card after each insn command
printf ( "Error performing insn2: %s\n",
comedi_strerror(comedi_errno() ) );
}
insn.chanspec = CR_CHAN(counter_chan1);
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{//Sending command to configure the card after each insn command
printf ( "Error performing insn3: %s\n",
comedi_strerror(comedi_errno() ) );
}
}
//To Zero Counter
// stop the counter
insn.insn = INSN_CONFIG;
insn.n = 1;
op[0] = GPCT_DISARM;
insn.data = op;
insn.subdev = subcounter;
insn.chanspec = CR_CHAN ( counter_chan );
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{
printf ( "Error performing insn4: %s\n", comedi_strerror (
comedi_errno() ) );
}
insn.chanspec = CR_CHAN ( counter_chan1);
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{
printf ( "Error performing insn5: %s\n", comedi_strerror (
comedi_errno() ) );
}
// reset the counter to zero
insn.insn = INSN_WRITE;
insn.n = 1;
op[0] = 1000000;// set the initial count to 1000000
insn.data = op;
insn.subdev = subcounter;
insn.chanspec = CR_CHAN ( counter_chan );
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{
printf ( "Error performing insn6: %s\n", comedi_strerror (
comedi_errno() ) );
}
insn.chanspec = CR_CHAN ( counter_chan1);
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{
printf ( "Error performing insn7: %s\n", comedi_strerror (
comedi_errno() ) );
}
// start the counter
insn.insn = INSN_CONFIG;
insn.n = 1;
op[0] = GPCT_ARM;
insn.data = op;
insn.subdev = subcounter;
insn.chanspec = CR_CHAN ( counter_chan );
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{
printf ( "Error performing insn8: %s\n", comedi_strerror (
comedi_errno()));
}
insn.chanspec = CR_CHAN ( counter_chan1);
if ( ( comedi_do_insn ( device, &insn ) ) < 0 )
{
printf ( "Error performing insn: %s\n", comedi_strerror (
comedi_errno()));
}
//usleep (10);
}
Received on 2005-01-25Z16:16:34