01-04-2012 09:56 AM
I have a PCI-GPIB card that I was using in a Core2 Quad machine running CentOS 5.7. I bought an ASUS P8Z68-V motherboard with a Core i7 CPU and installed CentOS 6. I installed the NI-488.2 for Linux driver version 2.9. Everything compiled and installed without a problem and the nikal.ko module loads fine. But, when I try to access the GPIB card I get a segmentation fault. I wrote a simple c program as follows:
#include <stdio.h>
#include <ni488.h>
#include <string.h>
int main(){
static int ud;
char *init = "*IDN?";
int er;
if (ud = ibdev(0,22,0,13,1,0)) {
er = ibwrt(ud, init, strlen(init) +1);
}
return 0;
}
When the ibwrt command executes the program exists with the following
Segmentation fault (core dumped)
However, when I use gpibintctrl i can read and write without any problems. This behavior ocurred before I did any updates to CentOS and continues after all the available updates have been installed.
The kernel version I am using at this point is 2.6.32-220.2.1.el6.i686 with mem=512M set as a kernel option.
The device I am connected to is an HP 3457A Multimeter with an address of 22.
I have read that the Asmedia pci bridge can cause some problems with pci devices but I don't think that is a problem here since I can execute the commands just fine inside of gpibintctrl. I have also had success installing and using a NI-PCI-VXI card on this same system.
Any suggestions on what I should do?
01-05-2012 03:47 PM
Segmentation faults can sometimes be caused by a mismatch in array sizes for a particular function. In your ibwrt command, you have the input "strlen(init)+1". So that function is expecting an array of size 6, but is actually receiving an array of size 5. If you take out the '+1', how does that affect the program?
Does the error message say anything beyond "Segmentation Fault (core dumped)"?
Also, you say that the gpibintctrl works correctly, do you have a simple c program using that uses that function so we can compare the two?