Author Topic: NI PCI card and Linux-GPIB  (Read 9374 times)

0 Members and 1 Guest are viewing this topic.

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
NI PCI card and Linux-GPIB
« on: June 19, 2016, 01:18:19 pm »
Hello

Is someone using a NI PCI card together with linux-gpib?

Not sure if my card is broken or not....shows up with lspci, but fails to initialize...

Code: [Select]
0e:07.0 Communication controller: National Instruments Device a1a1 (rev 02)

Code: [Select]
root@debian:/home/me/linux-gpib-4.0.2# gpib_config
failed to bring board online
failed to configure board
main: Operation not permitted

The kernel module is loaded though:

Code: [Select]
root@debian:/home/me/linux-gpib-4.0.2# lsmod | grep tnt
tnt4882                22337  0
nec7210                18012  1 tnt4882
gpib_common            30902  2 nec7210,tnt4882

When configuring with "gpib_config", it fails with:

Code: [Select]
[  832.939284] no NI PCI-GPIB boards found
[  832.939295] gpib: interface attach failed
« Last Edit: June 19, 2016, 01:50:24 pm by davorin »
 

Offline TiN

  • Super Contributor
  • ***
  • Posts: 4543
  • Country: ua
    • xDevs.com
Re: NI PCI card and Linux-GPIB
« Reply #1 on: June 19, 2016, 03:05:47 pm »
What is your /etc/gpib.conf ?
YouTube | Metrology IRC Chat room | Let's share T&M documentation? Upload! No upload limits for firmwares, photos, files.
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #2 on: June 19, 2016, 04:11:11 pm »
The regular configuration for this card:

Code: [Select]
interface {
minor = 0 /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
board_type = "ni_pci" /* type of interface board being used */
name = "gpib" /* optional name, allows you to get a board descriptor using ibfind() */
pad = 0 /* primary address of interface             */
sad = 0 /* secondary address of interface           */
timeout = T3s /* timeout for commands */

eos = 0x0a /* EOS Byte, 0xa is newline and 0xd is carriage return */
set-reos = yes /* Terminate read if EOS */
set-bin = no /* Compare EOS 8-bit */
set-xeos = no /* Assert EOI whenever EOS byte is sent */
set-eot = yes /* Assert EOI with last byte on writes */

/* settings for boards that lack plug-n-play capability */
base = 0 /* Base io ADDRESS                  */
irq  = 0 /* Interrupt request level */
dma  = 0 /* DMA channel (zero disables)      */

/* pci_bus and pci_slot can be used to distinguish two pci boards supported by the same driver */
/* pci_bus = 0 */
/* pci_slot = 7 */

master = yes /* interface board is system controller */
}
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2082
Re: NI PCI card and Linux-GPIB
« Reply #3 on: June 19, 2016, 05:03:49 pm »
I have a vague memory of having problems with a conflicting interrupt when I first started with GPIB card. Having a look at the conf file, I notice that IRQ=0 is commented out:

Code: [Select]

/* settings for boards that lack plug-n-play capability */
        base = 0        /* Base io ADDRESS                  */
/*      irq  = 0*/      /* Interrupt request level */
        dma  = 0        /* DMA channel (zero disables)      */

But it's a very long time since I installed the card, so I could be wrong - very :)


 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: NI PCI card and Linux-GPIB
« Reply #4 on: June 19, 2016, 06:05:32 pm »
I have 2 suggestions , but both are just guesses.
I use Agilent USB controllers.


1:
You might have a card with PCI ID : a1a1
0e:07.0 Communication controller: National Instruments Device a1a1 (rev 02)

That id is NOT recognized in the current source , but according to the below post from the "linux-gpib mailinglist" , should be easy to add to the source.

Code: [Select]
Hej,

newer NI PCIe can easily be included and work well ...
regards
Carsten

diff -crB linux-gpib-3.2.14/drivers/gpib/tnt4882/tnt4882.h
linux-gpib-3.2.14.ni_pcie2/drivers/gpib/tnt4882/tnt4882.h ***
linux-gpib-3.2.14/drivers/gpib/tnt4882/tnt4882.h 2007-04-04
21:33:11.000000000 +0200 ---
linux-gpib-3.2.14.ni_pcie2/drivers/gpib/tnt4882/tnt4882.h 2010-02-23
16:22:20.000000000 +0100 ***************
*** 35,41 ****
  PCI_DEVICE_ID_NI_GPIB_PLUS = 0xc811,
  PCI_DEVICE_ID_NI_PXIGPIB = 0xc821,
  PCI_DEVICE_ID_NI_PMCGPIB = 0xc831,
! PCI_DEVICE_ID_NI_PCIEGPIB = 0x70cf
  };
 
  // struct which defines private_data for tnt4882 devices
--- 35,42 ----
  PCI_DEVICE_ID_NI_GPIB_PLUS = 0xc811,
  PCI_DEVICE_ID_NI_PXIGPIB = 0xc821,
  PCI_DEVICE_ID_NI_PMCGPIB = 0xc831,
! PCI_DEVICE_ID_NI_PCIEGPIB = 0x70cf,
! PCI_DEVICE_ID_NI_PCIE2GPIB = 0x710e
  };
 
  // struct which defines private_data for tnt4882 devices
diff -crB linux-gpib-3.2.14/drivers/gpib/tnt4882/tnt4882_init.c
linux-gpib-3.2.14.ni_pcie2/drivers/gpib/tnt4882/tnt4882_init.c ***
linux-gpib-3.2.14/drivers/gpib/tnt4882/tnt4882_init.c 2007-10-24
16:12:00.000000000 +0200 ---
linux-gpib-3.2.14.ni_pcie2/drivers/gpib/tnt4882/tnt4882_init.c 2010-02-23
16:12:23.000000000 +0100 ***************
*** 525,530 ****
--- 525,531 ----
  case PCI_DEVICE_ID_NI_PXIGPIB: case PCI_DEVICE_ID_NI_PMCGPIB: case
  PCI_DEVICE_ID_NI_PCIEGPIB:
+ case PCI_DEVICE_ID_NI_PCIE2GPIB:
  found_board = 1;
  break;
  default:
***************
*** 723,728 ****
--- 724,730 ----
  {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PXIGPIB)},
  {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PMCGPIB)},
  {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIEGPIB)},
+ {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIE2GPIB)},
  { 0 }
  };
  MODULE_DEVICE_TABLE(pci, tnt4882_pci_table);


This means


Ie. in / drivers / gpib / tnt4882 / tnt4882.h 

In the enum ,  add an extra line

PCI_DEVICE_ID_NI_PCIE3GPIB = 0xa1a1,

Code: [Select]
enum
{
PCI_DEVICE_ID_NI_GPIB = 0xc801,
PCI_DEVICE_ID_NI_GPIB_PLUS = 0xc811,
PCI_DEVICE_ID_NI_PXIGPIB = 0xc821,
PCI_DEVICE_ID_NI_PMCGPIB = 0xc831,
PCI_DEVICE_ID_NI_PCIEGPIB = 0x70cf,
PCI_DEVICE_ID_NI_PCIE2GPIB = 0x710e,
        PCI_DEVICE_ID_NI_PCIE3GPIB = 0xa1a1,
PCI_DEVICE_ID_CEC_NI_GPIB = 0x7258
};


In / drivers / gpib / tnt4882 / tnt4882_init.c

Search for PCI_DEVICE_ID_NI_PCIE2GPIB , and add PCI_DEVICE_ID_NI_PCIE3GPIB the 2 found places

Code: [Select]
switch(mite_device_id(mite))
{
case PCI_DEVICE_ID_NI_GPIB:
case PCI_DEVICE_ID_NI_GPIB_PLUS:
case PCI_DEVICE_ID_NI_PXIGPIB:
case PCI_DEVICE_ID_NI_PMCGPIB:
case PCI_DEVICE_ID_NI_PCIEGPIB:
case PCI_DEVICE_ID_NI_PCIE2GPIB:
                case PCI_DEVICE_ID_NI_PCIE3GPIB:
case PCI_DEVICE_ID_CEC_NI_GPIB:
found_board = 1;
break;
default:
found_board = 0;
break;
}



And

Code: [Select]
static const struct pci_device_id tnt4882_pci_table[] =
{
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_GPIB_PLUS)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PXIGPIB)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PMCGPIB)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIEGPIB)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIE2GPIB)},
        {PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_NI_PCIE3GPIB)},
{PCI_DEVICE(PCI_VENDOR_ID_NATINST, PCI_DEVICE_ID_CEC_NI_GPIB)},
{ 0 }
};


According to the mailinglist post , this should do it.

And would prob be my best guess , if it's PCI-ID related.





The other was something Dave Penkler wrote , not so long ago.
But i would not expect it to cause the symptoms above.


2:
What kernel do you use ?

Quote

A patch was incorporated into the kernel between 4.2 and 4.3 that broke
PCI IRQ routing in certain cases by no longer enabling interrupts on
upstream bridges.
This affected the PCI cards supported by the agilent_82350b and tnt4882
drivers in the linux-gpib package running on kernel versions 4.3 through
4.4.6.
If you are affected by this and can't change your kernel, a work-around is
to boot it with the *"pci=routeirq"* option. The problem was fixed in
kernel version 4.5 and later with this commit:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6c777e8799a93e3bdb67bec622429e1b48dc90fb
Thanks to Ansgar Keukes for reporting and helping to resolve the issue.


/Bingo
« Last Edit: June 19, 2016, 06:25:33 pm by bingo600 »
 
The following users thanked this post: lordium

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #5 on: June 19, 2016, 08:34:05 pm »
You're great (o;

Just replaced the PCI ID and:

Code: [Select]
[ 8761.478581] mite: 0xf8304000 mapped to f7e3a000
[ 8761.478605] mite: daq: 0xf8300000 mapped to f83f0000
[ 8761.478647] tnt4882: irq 20

Code: [Select]
root@debian:/home/me/linux-gpib-4.0.2# ibterm -d 5 -s 96
Attempting to open /dev/gpib0
pad = 5, sad = 96, timeout = 10, send_eoi = 1, eos_mode = 0x0000
ibterm>*IDN?
HEWLETT-PACKARD,6632B,0,A.01.04

Still wonder why the MacOS9 driver from NI didn't recognize the card....

Anyway...good starting point for an ethernet2gpib solution based on this cheap card (o;
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: NI PCI card and Linux-GPIB
« Reply #6 on: June 20, 2016, 02:17:11 pm »
@Davorin

Nice to know it worked  :-+
Did you add a new ID , or just replace one of the existing ones with a1a1 ?


Could you post the board definition section , from gpib.conf here for future reference ?
That might help others

/Bingo
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #7 on: June 20, 2016, 02:24:52 pm »
Hello

I was lazy...just replaced the ID (o;

My gpib.conf is posted above...nothing special there....

Code: [Select]
interface {
minor = 0 /* board index, minor = 0 uses /dev/gpib0, minor = 1 uses /dev/gpib1, etc. */
board_type = "ni_pci" /* type of interface board being used */
name = "gpib" /* optional name, allows you to get a board descriptor using ibfind() */
pad = 0 /* primary address of interface             */
sad = 0 /* secondary address of interface           */
timeout = T3s /* timeout for commands */

eos = 0x0a /* EOS Byte, 0xa is newline and 0xd is carriage return */
set-reos = yes /* Terminate read if EOS */
set-bin = no /* Compare EOS 8-bit */
set-xeos = no /* Assert EOI whenever EOS byte is sent */
set-eot = yes /* Assert EOI with last byte on writes */

/* settings for boards that lack plug-n-play capability */
/* base = 0 *//* Base io ADDRESS                  */
/* irq  = 0 *//* Interrupt request level */
/* dma  = 0 *//* DMA channel (zero disables)      */

/* pci_bus and pci_slot can be used to distinguish two pci boards supported by the same driver */
/* pci_bus = 0 */
/* pci_slot = 7 */

master = yes /* interface board is system controller */
}

Now let's see if I can modify the php module easily as it hasn't been updated since 2003 and only works for php4...

 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: NI PCI card and Linux-GPIB
« Reply #8 on: June 20, 2016, 02:46:13 pm »
Anyway...good starting point for an ethernet2gpib solution based on this cheap card (o;

What was the price of the card ?

Too bad the old RPC code has been purged from linux-gpib , ense that would have been a nice starting point for a remote ether-gpib gateway.

I'd still say a Raspi->USB-GPIB based ether gateway would be my preferred solution, fanless & < 10 watt

/Bingo
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #9 on: June 20, 2016, 03:00:04 pm »
Think I paid around Euro 40 for it....was sold as broken..or as is.... (o;

Well...digging now into language/php/gpib.c
to see if this pass by reference can easily be fixed....god I hate those ZEND macros (o;

I would prefer doing everything remotely...a webserver with the php-gpib module would be great....
Using a cheap Fujitsu thin-client PC for US$ 18 with the NI PCI card in it now....

At least I can switch on/off all my devices via http with a simple OSX Xojo application (o;

« Last Edit: June 20, 2016, 03:02:12 pm by davorin »
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #10 on: June 20, 2016, 03:07:15 pm »
Hmm....that was easy....well...the ibrd function for php5 (o;

Code: [Select]
<?php
$string "";
$u ibfind("power1");
ibwrt($u,"*IDN?");
ibrd($u,$string,10000);
echo $string;
?>


Just commented out in gpib.c in function ZEND_FUNCTION(ibrd):

Code: [Select]
// if (!PZVAL_IS_REF(z)) {   
// zend_error(E_WARNING, "Not a reference");
// RETURN_NULL();
// }

Code: [Select]
klingler@debian:~/linux-gpib-4.0.2/language/php$ php -v
PHP 5.6.22-0+deb8u1 (cli) (built: Jun 13 2016 07:55:54)

Output:

Code: [Select]
klingler@debian:~/linux-gpib-4.0.2/language/php$ php test.php
HEWLETT-PACKARD,6632B,0,A.01.04
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: NI PCI card and Linux-GPIB
« Reply #11 on: June 20, 2016, 03:43:54 pm »
Think I paid around Euro 40 for it....was sold as broken..or as is.... (o;

Well...digging now into language/php/gpib.c
to see if this pass by reference can easily be fixed....god I hate those ZEND macros (o;

I would prefer doing everything remotely...a webserver with the php-gpib module would be great....
Using a cheap Fujitsu thin-client PC for US$ 18 with the NI PCI card in it now....

At least I can switch on/off all my devices via http with a simple OSX Xojo application (o;

I'd be interested in that module (relays ?) & sw for my linux
Is that a Pollin NetIO ?

/Bingo
« Last Edit: June 20, 2016, 03:49:43 pm by bingo600 »
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #12 on: June 20, 2016, 03:48:27 pm »
It's called IP Powerbar....think they are also produced under another name...like NetIO 230C....but all have different firmware (o;

They are cheap for a 4-port power outlet...but the chinese controller reset circuitry sucks badly....short outage in AC causes it to beep endlessly ;-)

I use the HTTP CGI interface to switch individual outlets on/off...sad there is no HTTP call to get current status....might be to do with the limited flash space...
Also no SNMP *sniff (o;

 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: NI PCI card and Linux-GPIB
« Reply #13 on: June 20, 2016, 03:53:06 pm »
Ahh ....

Then i have some 8-Chan APC PDU's  : Apc-AP7921-Powerswitch-black
They support HTTP/SNMP , but they're pricey

/Bingo
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #14 on: June 20, 2016, 03:55:36 pm »
Only a APC 3 phase 2m tall Rack-PDU here I got sponsored for my network inventory web application (o;

No switchable ports though...just current measuring with SNMP...

 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #15 on: June 21, 2016, 02:22:13 pm »
Ordered now a cheap Core2Duo PC for EUro 29 with shipping with PCIe and PCI slot for testing my NI PCI card...

Well..there is also some FPGA board lying around with PCIe interface...might be a good starting point for doing an own GPIB implementation in Verilog on Lattice FPGA (o;
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: NI PCI card and Linux-GPIB
« Reply #16 on: June 21, 2016, 05:08:41 pm »
Ordered now a cheap Core2Duo PC for EUro 29 with shipping with PCIe and PCI slot for testing my NI PCI card...

Well..there is also some FPGA board lying around with PCIe interface...might be a good starting point for doing an own GPIB implementation in Verilog on Lattice FPGA (o;

Ahh ... I remember your fpga site  :-+

I'm still a VHDL beginner

/Bingo
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #17 on: June 21, 2016, 07:04:06 pm »
Yeah...have to bring it back online....just extended the registration period for fpga.ch today few days before expiration...

Wasn't aware that besides go daddy name cheap is also evil...they just pull the domain name instead of releasing it to public and put it to auction...


And I prefer Verilog over VHDL...as I'm coming for the electronics world I like the "wire" statement in Verily (o;
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #18 on: July 11, 2016, 04:13:47 pm »
Well a little off-topic...but just received an older NI PCI card....works out of the box on my old Apple G4 MDD running MacOS 9.2.2 (o;

 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: NI PCI card and Linux-GPIB
« Reply #19 on: February 06, 2017, 11:00:18 am »
This is even way far more off-topic (o;

Using now my Amazon echo box to power on/off my measurement equipment...
And now next project is to control the GPIB devices with Alexa (o;

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf