- From: ÇÑ°æ·æ <sidabari_at_postech.ac.kr>
- Date: Tue, 25 Feb 2003 14:01:24 +0900
confirm 553056
I use AT-MIO-16E-1 of NI with RTLinux.
This board works well at User-space : The work is reading data or writing data.
But at kernel-space it does not work.
Test program is below....
---------------------------------------------------------------------
#include <rtl.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/comedi.h>
#include <linux/comedilib.h>
#define BUFSIZE 1024
#define CH0 1
#define CH1 2
#define CH2 3
#define CH3 4
unsigned int dev = 0;
unsigned int subd = 0;
int init_module(void)
{
unsigned int data[4] = { 0, 0, 0, 0};
int ret;
printk("-----------------------------\n");
printk( "Comedi real-time example\n" );
printk("-----------------------------\n");
// device open
ret = comedi_open( dev );
if( dev != 0 ) printk( "comedi_open error\n" );
else printk( "comedi_open success\n" );
// get board information
printk( "driver name: %s\n", comedi_get_driver_name(dev) );
printk( "board name: %s\n", comedi_get_board_name(dev) );
printk( "number of chnls: %d\n", comedi_get_n_channels(dev,subd) );
// output mode config
ret = comedi_dio_config( dev, subd, CH0, COMEDI_OUTPUT );
comedi_dio_config( dev, subd, CH1, COMEDI_OUTPUT );
comedi_dio_config( dev, subd, CH2, COMEDI_OUTPUT );
comedi_dio_config( dev, subd, CH3, COMEDI_OUTPUT );
if( ret == 0 ) printk( "comedi_config success\n" );
else printk( "comedi_config error: (code)%d\n", ret );
// digital write
ret = comedi_dio_write( dev, subd, CH0, 1 );
if( ret == 0 ) printk( "comedi_write success\n" );
else printk( "comedi_write error: (code)%d\n", ret );
comedi_dio_write( dev, subd, CH1, 0 );
comedi_dio_write( dev, subd, CH2, 1 );
comedi_dio_write( dev, subd, CH3, 0 );
// input mode config
ret = comedi_dio_config( dev, subd, CH0, COMEDI_INPUT );
comedi_dio_config( dev, subd, CH1, COMEDI_INPUT );
comedi_dio_config( dev, subd, CH3, COMEDI_INPUT );
comedi_dio_config( dev, subd, CH2, COMEDI_INPUT );
if( ret == 0 ) printk( "comedi_config success\n" );
else printk( "comedi_config error: (code)%d\n", ret );
ret = comedi_dio_read( dev, subd, CH0, data );
comedi_dio_read( dev, subd, CH1, data+1 );
comedi_dio_read( dev, subd, CH2, data+2 );
comedi_dio_read( dev, subd, CH3, data+3 );
if( ret == 0 ) printk( "comedi_read success: %u%u%u%u\n", data[0], data[1], data[2], data[3] );
else printk( "comedi_read error: (code)%d, (data)%u%u%u%u\n", ret, data[0], data[1], data[2], data[3] );
return 0;
}
void cleanup_module(void)
{
// device close
comedi_close( dev );
printk("comedi_closed\n");
}
------------------------------------------------------------------------------
Utill "get board information" success.
However, error occur from next line.
Most of all, "comedi_dio_config", "comedi_dio_read", "comedi_dio_write" are important functions.
these fucntion do not work!!
Maybe I compiled correctly. (Just my opinion)
I used the driveres of 8255, ni_atmio and isatools.
I want to use AT-MIO-16E-1 at kernel-space.
Please show me the way, step by step.....from the start.....!!
Received on 2003-02-25Z05:01:24