comedi error in rtlinux kernel mode

 when I made comedi_read() uncommented,  the linux
system stopped.
(at the other times, it showed a segmentation fault)
Of course, rtlinux runs well if comedi functions are
not used, also comedi functions run well at user space
mode(int main()). 

So I have some questions,

1. Is it right when comedi_open() returns 0 in kernel
mode?
2. Is there any caution when I put a compile
options?(such as include dir, #include <>, etc)
3. Can I regard rlinux and comedi as normally
installed when rtlinux module program runs well 
without any comedi functions and when comedi functions
run well in user space mode?
4. Then why doesn't comedi functions work in kernel
mode?? 
5. Is there any simple code which can run in rtlinux
kernel mode 
   besides the code in the mailing list Fri, 24 May
2002 17:58:28 -0400 (EDT)?
   
  I attaches the results and  my codes:

 

Thanks in advance..

 

[root_at_localhost comedi_test]# make
gcc -I/usr/src/linux/include
-I/usr/src/rtlinux-3.2-pre3/include
-I/usr/src/rtlinux-3.2-pre3/include/compat 
-D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -pipe
-mpreferred-stack-boundary=2 -march=k6 -DMODULE
-DMODVERSIONS -include
/usr/src/linux/include/linux/modversions.h -g
-D__RTL__ -D_LOOSE_KERNEL_NAMES -O2
-I/usr/src/linux/include
-I/usr/src/rtlinux-3.2-pre3/include
-I/usr/src/rtlinux-3.2-pre3/include/compat
-I/usr/src/rtlinux-3.2-pre3/include/posix -I
/usr/src/comedi-0.7.68/include -g -c test1.c 

test1.c: In function `init_module':
test1.c:48: warning: assignment makes integer from
pointer without a cast
test1.c:57: warning: passing arg 3 of
`__pthread_create' from incompatible pointer type
test1.c:46: warning: unused variable `data'


[root_at_localhost comedi_test]# insmod test1.o
Warning: loading test1.o will taint the kernel: no
license
  See http://www.tux.org/lkml/#export-tainted for
information about tainted modules
Module test1 loaded, with warnings


[root_at_localhost comedi_test]# dmesg
Linux version 2.4.22-rtl3.2-pre3
(root_at_localhost.localdomain) (gcc version 3.2.3
20030422 (Hancom Linux 3.2.3)) #1 SMP È­ 12¿ù 30
19:43:19 KST 2003
BIOS-provided physical RAM map:

...


comedi_open() success:0  <<--------------comedi_open()
returned 0.. is it normal??
        before comedi_data_read()
0: data:0                            
        before comedi_data_read()
1: data:0
        before comedi_data_read()
...

=================================================================
  
   makefile:
=================================================================
  
#include /usr/src/rtlinux-3.2-pre3/rtl.mk
#include /usr/src/linux/.config

COMEDI_DIR = /usr/src/comedi-0.7.68
COMEDI_DEVEL_HEADERS = $(COMEDI_DIR)/include

all: test1.o

clean:
 rm -f *.o

 

test1.o: test1.c
 $(CC) ${INCLUDE} ${CFLAGS} -I ${COMEDI_DEVEL_HEADERS}
-g -c test1.c 
# -lcomedi
#  -D KCOMEDILIB_DEPRECATED


===================================================================
   test1.c
===================================================================
/*--------------------------------------------------------------------------
*  Comedi Program in RTLINUX kernel mode

*--------------------------------------------------------------------------*/

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/version.h>


#include <linux/comedilib.h>

#include <time.h>
#include <pthread.h>

pthread_t thread;


void * thread_code(void)
{
 static int index;

 lsampl_t        data=0;

 pthread_make_periodic_np(pthread_self(), gethrtime(),
1000000000);

 while(1)
 {
  pthread_wait_np();
  rtl_printf(" before comedi_data_read()\n");
//  if(comedi_data_read(0,0,0,0,AREF_DIFF,&data)<0)
//   rtl_printf("comedi_data_read() error\n");
  rtl_printf("%d: data:%d\n",index,(int)data);
  
  index++;
  // ENCODER READING
 }
 return 0;
}


int init_module(void)
{
 int ret;
 lsampl_t data=0;

 ret = comedi_open("dev/comedi0");
// ret = comedi_open(0);
 if(ret<0)
 {
  rtl_printf("Cannot open device 0\n");
  return -1;
 }
 rtl_printf("comedi_open() success:%d\n",ret);

 return pthread_create(&thread, NULL, thread_code,
NULL);
}

void cleanup_module(void)
{
 pthread_delete_np(thread);
 comedi_close("dev/comedi0");
 rtl_printf("comedi_close() success\n");
// comedi_close(0);
}



_____________________________________________________________________
¿¹»Û ÆíÁöÁö¿¡ ¸ÞÀÏÀ» º¸³»¼¼¿ä - ¾ßÈÄ! ¸ÞÀÏ
http://mail.yahoo.co.kr
½ÅÂ÷,Áß°íÂ÷,Á÷°Å·¡ ¸Å¹°ÀÌ ÇÑÀÚ¸®¿¡ - ¾ßÈÄ! ÀÚµ¿Â÷
http://autos.yahoo.co.kr/autos/

Received on 2004-06-11Z15:56:39