Seg Fault NI-Daq 6024E

I'm trying to read digital input from a NI DAQ 6024E.  I'm running
Slackware 9 with kernel 2.4.20 and the comedi and comedilib is installed
correctly (as I can run the test programs and have create a test program
myself).  However, when trying to run my program to read from a single
digital input, I get a segmentation fault.  The following is an strace of
the program running:


hainesca_at_RA7813522:~/RSL-AO/DAQ_Card_6024E$ strace ./digitalRead |more
execve("./digitalRead", ["./digitalRead"], [/* 30 vars */]) = 0
brk(0)                                  = 0x8049ad8
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=36500, ...}) = 0
old_mmap(NULL, 36500, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40015000
close(3)                                = 0
open("/usr/lib/libcomedi.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\250\35"..., 1024)
= 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=31973, ...}) = 0
old_mmap(NULL, 25668, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4001e000
mprotect(0x40024000, 1092, PROT_NONE)   = 0
old_mmap(0x40024000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x5000) = 0x40024000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\\\1\000"...,
1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1435624, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x40025000
old_mmap(NULL, 1256740, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40026000
mprotect(0x40150000, 36132, PROT_NONE)  = 0
old_mmap(0x40150000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
3, 0x12a000) = 0x40150000
old_mmap(0x40155000, 15652, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40155000
close(3)                                = 0
open("/lib/libm.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\0006\0"..., 1024)
= 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=177047, ...}) = 0
old_mmap(NULL, 140416, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40159000
mprotect(0x4017b000, 1152, PROT_NONE)   = 0
old_mmap(0x4017b000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0x21000) = 0x4017b000
close(3)                                = 0
munmap(0x40015000, 36500)               = 0
brk(0)                                  = 0x8049ad8
brk(0x804aad8)                          = 0x804aad8
brk(0x804b000)                          = 0x804b000
open("/dev/comedi0", O_RDWR)            = 3
ioctl(3, DECODER_GET_CAPABILITIES, 0x8049afc) = 0
ioctl(3, DECODER_GET_STATUS, 0x8049bc0) = 0
ioctl(3, 0x8008640b, 0xbffff8c8)        = 1
ioctl(3, 0x8020640c, 0xbffff8d0)        = 2
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, 0x8008640b, 0xbffff8b8)        = 1
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, 0x8008640b, 0xbffff8b8)        = -1 EINVAL (Invalid argument)
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, DEVFSDIOC_RELEASE_EVENT_QUEUE, 0xbffff930) = 0
ioctl(3, 0x80086408, 0xbffff8e0)        = 0
ioctl(3, 0x8008640b, 0xbffff8b8)        = 1
ioctl(3, DECODER_SET_OUTPUT, 0x2)       = 0
ioctl(3, 0x8020640c, 0xbffff950)        = 1
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 7313169
ioctl(3, 0x8020640c, 0xbffff950)        = 1
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

As you can see, it gives an invalid argument to one of my calls.  So I did
some debugging in my program (the program is attached) and found the
following line to be at fault (if i comment out the following line, the
program runs).

nError = comedi_dio_read(card, subdev, chanStart, nBit);

I've attached the program for review.  Any help on this matter would be
much appreciated.

Thanks,
Chuck

====================================
Chuck Haines
chaines_at_wpi.edu
http://www.linux-xtreme.net
====================================
WPI ECE Systems Administrator
WPI Game Development Club Developer
WPI Linux Association Lab Manager
Tau Kappa Epsilon Fraternity
TKE-IT Systems Administrator
====================================
AIM: CyberGrex
YIM: CyberGrex_27
ICQ: 3707881
====================================

Received on 2003-06-03Z09:38:51