Linux Users

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-VISA on Tektronix 2024B scopes

Hello,

Now that we have a dedicated forum for linux users I thought I may give a shot and raise this issue which I have with my Tektronix 2024B oscillioscope. This issue has already been discussed in another post. I was hoping that NI-KAL 1.9 would fix it but I still have this problem. I am running kernel 2.6.25 with the latest NI-KAL and NI-VISA. Short description of the problem is that I could connect to the scope and run any number of commands I like and close the connection. But it only works once. Once I close the connection, it seems like the usb port freezes so that any attempt to write on it fails. I could still see the instrument with NIvisaic. Does anyone know how I can get around this problem? This problem is only on linux. Instrument works perfectly on Windows or even Windows on a virtualbox.

0 Kudos
Message 1 of 7
(13,786 Views)

After talking to the VISA experts I have an idea of what might be happening.  Apparently when closing a usb port, Linux will issue a SET_INTERFACE command to the usb device.  The USB spec says this is supposed to reset all of the endpoints back to zero, but some usb devices overlook that part of the spec.  Windows does not use the SET_INTERFACE command on close and thus does not depend on this behavior.

It may be possible to work around this issue.  Are you using C/C++ or LabVIEW?  If you are using C/C++ you can try setting VI_ATTR_USB_BULK_IN_STATUS, VI_ATTR_USB_BULK_OUT_STATUS, and VI_ATTR_USB_INTR_IN_STATUS, to zero after you re-open your device.  If you are using LabVIEW it might be a little trickier, but you basically want to do the same thing, using a property node.  The problem is LabVIEW won't let you see those properties unless you set the I/O session to USB Raw when you open the device.  So you will probably want to open the device as USB Raw set those properties close the session then open is as USB TMC and continue on.

Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 2 of 7
(6,752 Views)

That's really promising. I am using pyvisa actually. Unfortunately it doesn't have the raw USB attributes. I'm not really familiar with raw USB communication. Is there any command line program I could use or perhaps a pre written C program that I could modify and compile to set these parameters? I really want to get this working. Any help I would really appreciate.

0 Kudos
Message 3 of 7
(6,752 Views)

I think this should be possible from pyVISA:

http://pyvisa.sourceforge.net/pyvisa/node20.html

http://pyvisa.sourceforge.net/vpp43.html#set-attribute

That combined with this snippet from visa.h:

#define VI_ATTR_USB_BULK_OUT_STATUS (0x3FFF01ACUL)
#define VI_ATTR_USB_BULK_IN_STATUS  (0x3FFF01ADUL)
#define VI_ATTR_USB_INTR_IN_STATUS  (0x3FFF01AEUL)

So I would guess something like this might work:

from pyvisa import vpp43

VI_ATTR_USB_BULK_OUT_STATUS = 0x3FFF01AC
VI_ATTR_USB_BULK_IN_STATUS = 0x3FFF01AD
VI_ATTR_USB_INTR_IN_STATUS = 0x3FFF01AE

vpp43.set_attribute(my_instrument.vi, VI_ATTR_USB_BULK_OUT_STATUS, 0)
vpp43.set_attribute(my_instrument.vi, VI_ATTR_USB_BULK_IN_STATUS, 0)
vpp43.set_attribute(my_instrument.vi, VI_ATTR_USB_INTR_IN_STATUS, 0)
Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 4 of 7
(6,752 Views)

The script works and sets the attributes. Thanks alot for that. However it doesn't seem to solve the issue. This is my nispy capture. First time it works (line 1-15). Second time it blocks out. If I change the GPIB address of my scope it starts working again.

1.  viOpenDefaultRM (0x0816BDC8)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.071       Call Duration 00:00:00.005
Status: 0 (VI_SUCCESS)

2.  viParseRsrc (0x0816BDC8, "USB0::0x0699::0x036A::C036065::INSTR", 7, 0)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.076       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

3.  viOpen (0x0816BDC8, "USB0::0x0699::0x036A::C036065::INSTR", 0, 0, 0x08174050)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.077       Call Duration 00:00:00.003
Status: 0 (VI_SUCCESS)

4.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), TMO_VALUE, 5000)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.080       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

5.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), TERMCHAR_EN, VI_FALSE)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.080       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

6.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), SEND_END_EN, VI_TRUE)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.080       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

7.  viGetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), RSRC_CLASS, "INSTR")
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

8.  viGetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), RSRC_CLASS, "INSTR")
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

9.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), USB_BULK_OUT_STATUS, 0)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

10.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), USB_BULK_IN_STATUS, 0)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

11.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), USB_INTR_IN_STATUS, 0)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

12.  viWrite (USB0::0x0699::0x036A::C03...(0x08174050), "*IDN?..", 7, 7)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

13.  viRead (USB0::0x0699::0x036A::C03...(0x08174050), "TEKTRONIX,TDS 2024B,C...", 20480, 48)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.082       Call Duration 00:00:00.064
Status: 0 (VI_SUCCESS)

14.  viClose (USB0::0x0699::0x036A::C03...(0x08174050))
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.146       Call Duration 00:00:00.003
Status: 0 (VI_SUCCESS)

15.  viClose (0x0816BDC8)
Process ID: 0x00001C7B         Thread ID: 0xB7CDC6C0
Start Time: 11:24:29.151       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

16.  viOpenDefaultRM (0x0816BDC8)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.072       Call Duration 00:00:00.004
Status: 0 (VI_SUCCESS)

17.  viParseRsrc (0x0816BDC8, "USB0::0x0699::0x036A::C036065::INSTR", 7, 0)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.077       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

18.  viOpen (0x0816BDC8, "USB0::0x0699::0x036A::C036065::INSTR", 0, 0, 0x08174050)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.077       Call Duration 00:00:00.004
Status: 0 (VI_SUCCESS)

19.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), TMO_VALUE, 5000)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

20.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), TERMCHAR_EN, VI_FALSE)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

21.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), SEND_END_EN, VI_TRUE)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

22.  viGetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), RSRC_CLASS, "INSTR")
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

23.  viGetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), RSRC_CLASS, "INSTR")
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

24.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), USB_BULK_OUT_STATUS, 0)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

25.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), USB_BULK_IN_STATUS, 0)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.081       Call Duration 00:00:00.001
Status: 0 (VI_SUCCESS)

26.  viSetAttribute (USB0::0x0699::0x036A::C03...(0x08174050), USB_INTR_IN_STATUS, 0)
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:37.082       Call Duration 00:00:00.000
Status: 0 (VI_SUCCESS)

> 27.  viWrite (USB0::0x0699::0x036A::C03...(0x08174050), "*IDN?..", 7, 0)
> Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
> Start Time: 11:24:37.082       Call Duration 00:00:20.015
> Status: 0xBFFF0015 (VI_ERROR_TMO)

28.  viClose (USB0::0x0699::0x036A::C03...(0x08174050))
Process ID: 0x00001C7C         Thread ID: 0xB7CEB6C0
Start Time: 11:24:57.100

0 Kudos
Message 5 of 7
(6,752 Views)

That's too bad.  It probably means it is a different issue.

You're a Gentoo user right?  The 2.6.28 kernels actually have a native usbtmc driver, which might be interesting to try.  I don't really know many of the details on how to use it, but if you feel like playing around it could provide another data point.

Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 6 of 7
(6,752 Views)

damn. I guess it is worth trying the 2.6.28-RC kernels. That's a shame. Is there any way to reinitialize a usb port?

0 Kudos
Message 7 of 7
(6,752 Views)