- From: wanjae Shin <downer2k_at_yahoo.co.kr>
- Date: Sat, 12 Jun 2004 23:21:44 +0900 (JST)
I sent my message yesterday, but some parts of that
were cut, so I send it again..
I'm using
rtlinux-3.2-pre3,
NI-PCI6024,
comedi-0.7.68,
comedilib-0.7.21
I want to use comedi functions in rtlinux modules.
I succeeded it in user space mode(int main()...)
but when I tried in kernel mode, it doesn't work.
I tried the code in mailing list in Fri, 24 May 2002
17:58:28 -0400 (EDT), but it cannot be compiled at all
(of course, I changed the arg. 0 to "/dev/comedi0" in
comedi_open() and comedi_close(), but it didnt work
either)
I have the following procedures
1. rtlinux start
2. modprobe ni_pcimio
3. comedi_config /dev/comedi0 ni_pcimio
4. modprobe kcomedilib
5. make
6. insmod test1.o
at this case, it works. (but I cannot be sure
comedi_open() work well because I might see some
articles that the return value of comedi_open() in
kernel space and user space different.).
Anyway, when I made comedi_read() uncommented, it
made the linux system stop.
(sometimes, it shows a segmentation fault)
Of course, rtlinux runs well if comedi functions are
not used, Also comedi functions run well at usr space
mode.
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 comedi as well 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)?
My execution results are:
[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 OK???
before comedi_data_read()
0: data:0
before comedi_data_read()
1: data:0
before comedi_data_read()
...
I attaches my codes:
=================================================================
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: hello.c
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);
}
Thanks in advance..
_____________________________________________________________________
¿¹»Û ÆíÁöÁö¿¡ ¸ÞÀÏÀ» º¸³»¼¼¿ä - ¾ßÈÄ! ¸ÞÀÏ
http://mail.yahoo.co.kr
½ÅÂ÷,Áß°íÂ÷,Á÷°Å·¡ ¸Å¹°ÀÌ ÇÑÀÚ¸®¿¡ - ¾ßÈÄ! ÀÚµ¿Â÷
http://autos.yahoo.co.kr/autos/
Received on 2004-06-12Z13:21:44