- From: Tuomas Räsänen <tuomas.rasanen_at_ssf.fi>
- Date: Thu, 06 May 2004 11:25:57 +0300
Hello,
I am using a NI PCI-DIO-96 -card in a PC, which has Linux Red Hat 8.0.
I have tried the card on a Windows machine, and it works.
Driver S/W has been installed, and /dev/comedi0 ... /dev/comedi3 created.
I have added following aliases into /etc/modules.conf:
alias char-major-98 comedi
alias char-major-98-0 ni_pcidio
I have tried configuring the card for both ni_pcidio and 8255 with following
results:
(I have included the messages from /var/log/messages.)
Trial 1: ni_pcidio
===================
/sbin/modprobe ni_pcidio
/var/log/messages:
May 4 14:17:47 boojum kernel: comedi: version 1.0.0 - David Schleef
<ds_at_schleef.org>
May 4 14:17:47 boojum kernel: Available NI device IDs: 0x0160
/usr/local/sbin/comedi_config -v /dev/comedi0 ni_pcidio 0x0160
Answer in shell:
configuring driver=ni_pcidio
352,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Configure failed!: Input/output error
Check kernel log for more information
Possible reasons for failure:
Driver not found
/var/log/messages:
May 4 16:02:31 boojum kernel: comedi0: nidio:no device found
May 4 16:02:31 boojum kernel: Available NI device IDs: 0x0160
- Another attempt:
/usr/local/sbin/comedi_config -v /dev/comedi0 ni_pcidio
Answer in shell:
configuring driver=ni_pcidio
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
/var/log/messages:
May 4 16:07:14 boojum kernel: comedi0: nidio:MITE:0xfce5e000 mapped to e08c8000
DAQ:0xfce5f000 mapped to e08e1000
May 4 16:07:14 boojum kernel: pci-dio-968255 support not configured --
disabling subdevice
May 4 16:07:14 boojum kernel: 8255 support not configured -- disabling subdevice
May 4 16:07:14 boojum last message repeated 2 times
May 4 16:07:14 boojum kernel:
At this stage, running MyDio.c, which I have included, caused 'illegal channel'
-messages.
Trial 2: 8255
=============
/sbin/modprobe -r ni_pcidio
/var/log/messages:
May 4 16:15:18 boojum kernel: Trying to free free IRQ5
/sbin/modprobe 8255
/var/log/messages:
May 4 16:16:14 boojum kernel: comedi: version 1.0.0 - David Schleef
<ds_at_schleef.org>
/usr/local/sbin/comedi_config /dev/comedi0 8255 0x200,0x204,0x208,0x20C
Answer in shell:
configuring driver=8255
512,516,520,524,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
/var/log/messages:
May 4 16:17:17 boojum kernel: comedi0: 8255: 0x0200 0x0204 0x0208 0x020c
Now MyDio does not produce any error messages, but all channels, whether input
or output, have +5 V. All channels I have configured as inputs, have value 1.
That persists even when I ground some channel with a jump wire.
Program /usr/local/comedi_examples/monitor/monitor shows always:
Tue May 4 16:24:22 2004 EET +003651us
channel data
dio 0:0:00 1111 1111
dio 0:1:00 1111 1111
dio 0:2:00 1111 1111
dio 0:3:00 1111 1111
- And finally:
/sbin/modprobe -r 8255
/var/log/messages:
May 4 16:26:10 boojum kernel: comedi0: 8255: remove
Rebooting the PC did not help.
It is as if I had some piece missing,just I don't know which.
/*****************************************************************************/
/* - RTTE - */
/* _at_Name: MyDio.c */
/* */
/* v. 1.0, 30.04.2004, Created, Tuomas Rasanen */
/* */
/*****************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <comedilib.h>
/*****************************************************************************/
/* Constants: */
/*****************************************************************************/
/*****************************************************************************/
/* Type definitions: */
/*****************************************************************************/
/*****************************************************************************/
/* Variables: */
/*****************************************************************************/
/*****************************************************************************/
/* Functions: */
/*****************************************************************************/
int subdev = 0;
int chan = 0;
int range = 0;
int aref = AREF_GROUND;
/* Read_Di ----------------------------------------------------------------- */
unsigned int Read_Di (comedi_t *dev, int subd)
{
int i, k;
unsigned int result;
int bit;
result = 0;
for (i=0; i<24; i++) {
k = comedi_dio_read (dev, subd, i, &bit);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev %d, ch. %d, luku pieleen. ", subd, i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
result |= (bit << i);
}
return result;
}
/* Some_Checking ---------------------------------------------------------- */
void Some_Checking (comedi_t *dev)
{
int n_chan, n_subd, subd;
n_subd = comedi_get_n_subdevices(dev);
printf (" XXX %d subdevices.\n", n_subd);
for(subd=0; subd<n_subd; subd++){
n_chan = comedi_get_n_channels(dev, subd);
printf ("XXX Subdevice %d, %d channels.\n", subd, n_chan);
}
} /* ... Some_Checking */
/* ------------------------------------------------------------------------- */
/* */
/* main () */
/* */
/* ------------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
comedi_t *it;
lsampl_t data;
int stype;
int sdev;
unsigned int digin;
unsigned int bit;
int i, j, k;
it = comedi_open("/dev/comedi0");
sleep (1);
stype = comedi_get_subdevice_type(it, 0);
printf ("## Subdevice %d: type %d.\n", 0, stype);
stype = comedi_get_subdevice_type(it, 1);
printf ("## Subdevice %d: type %d.\n", 1, stype);
stype = comedi_get_subdevice_type(it, 2);
printf ("## Subdevice %d: type %d.\n", 2, stype);
stype = comedi_get_subdevice_type(it, 3);
printf ("## Subdevice %d: type %d.\n", 3, stype);
Some_Checking (it);
for (i=0; i<24; i++) {
k = comedi_dio_config (it, 0, i, COMEDI_INPUT);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev 0, kanava %d pieleen. ", i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
}
for (i=0; i<24; i++) {
k = comedi_dio_config (it, 1, i, COMEDI_INPUT);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev 1, kanava %d pieleen. ", i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
}
for (i=0; i<24; i++) {
k = comedi_dio_config (it, 2, i, COMEDI_OUTPUT);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev 2, kanava %d pieleen. ", i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
}
for (i=0; i<24; i++) {
k = comedi_dio_config (it, 3, i, COMEDI_OUTPUT);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev 3, kanava %d pieleen. ", i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
}
sleep (1);
for (j=0; j<2; j++) {
for (i=0; i<24; i++) {
k = comedi_dio_read (it, j, i, &bit);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev %d, ch. %d, luku pieleen. ", j, i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
else {
printf (" ## Subdev %d, bitti %d: %d.\n", j, i, bit);
}
}
}
comedi_data_read (it, subdev, chan, range, aref, &data);
printf ("\n ## comedi_data_read: 0x%08X\n\n", data);
bit = 0;
while (bit == 0 || bit == 1) {
printf (" ## Give subdevice, ch. no. (0-23) and bit value (0-1): ");
scanf ("%d %d %d", &sdev, &i, &bit);
printf ("\n");
if (bit != 0 && bit != 1)
break;
k = comedi_dio_write (it, sdev, i, bit);
if (k == -1) {
k = comedi_errno();
printf ("-- Subdev %d, ch. %d, kirjoitus pieleen. ", sdev, i);
printf ("-- Error n:o %d: %s.\n", k, comedi_strerror(k));
}
printf (" ## Wrote Subdev %d, Ch. %d into %d.\n", sdev, i, bit);
digin = Read_Di (it, 0);
printf (" ## D/IN: Subdev 0: 0x%03X -", digin);
digin = Read_Di (it, 1);
printf (" Subdev 1: 0x%03X\n", digin);
}
comedi_close(it);
return 0;
}
/* EOF */
Regards,
-- Tuomas
--------------------------------------------------------------
Tuomas Räsänen tuomas.rasanen_at_ssf.fi
Space Systems Finland +358 9 613 28654
Kappelitie 6, 02200 Espoo mobile: 050 330 1758
Received on 2004-05-06Z07:25:57