Raspberry Pi & Visa in OpenTAP?

Installed OpenTAP & TUI on a rPi4B.
Installed pyvisa (and USB). I can see an instrument using pyvisa-shell.

Created the intrument under bench->instruments (tui) and assigned the correct VISA address

Running the program results in an error stating I need to install a VISA provider such as the keysight iolibs. I believe the Linux installation package is Intel based so it won’t install/open on an ARM.

Is there a solution for this?

1 Like

@craig.petku - I created a plugin called PythonVisa that is able to passthru the I/O to pyvisa. The primary target was Raspberry Pi. I’m working on getting it OpenSourced and then I can share it with you (maybe tomorrow? I’m at a technical conference now)

Thank you, I was starting to think I would have to write additional instrument drivers in Python, but I really didn’t want to add another language to my repetroir.

@craig.petku - ok, try this release:

I don’t have it configured to publish to the package repo quite yet; I think I have to wait for someone who’s on vacation right now.

Thank you, I will try it at the office next week.

Struggling to get this to install from source into a TAP installatuin built from source. PythonVisa compiles ok with dotnet, but:

  1. I have yet to find GitVersion for the rPi.
  2. The package command expects the bin directory in the OpenTap root directory. This has to be manually copied due to my directory structure
  3. Here’s the blocker from the package command:

00:00:03.081 : PackageAction : Warning : Package version is 0.0.0 due to blank or missing ‘Version’ XML attribute in ‘Package’ element
00:00:03.094 : Package : Error : Missing plugin to handle XML Element ‘ProjectFile’ on file bin/PythonVisa.Api.dll. (Line 11)
00:00:03.094 : Package : Error : Missing plugin to handle XML Element ‘ProjectFile’ on file README.md. (Line 14)
00:00:03.094 : Package : Error : Missing plugin to handle XML Element ‘PythonRequirements’ on file requirements.txt. (Line 17)
00:00:03.094 : PackageAction : Error : Caught exception: Missing plugins to handle XML elements specified in input package.xml…

Not sure where to try and fix this yet.

Insatlling OpenTAP, TUI, Python, SCPIbase… from the repository and this package from prebuilt, I managed to get an installation completed. However tap package install … always says No Python installations found.

Image configuration:
Generic SCPI-99 Instrument No Error Checking(1.0v1):
Cloud Drive: ^0.2.0+7e7541d6
Runner: ^1.0.4+ab159f02
PythonVisa: ^0.1.0-beta.25+4501b527
NATS Server: ^1.0.0+c7b94bdb
Keysight Licensing: ^1.4.2+8a01b531
Python: ^3.0.2+616d71b3
TUI: ^1.0.0+48ed6e30
OpenTAP: ^9.21.0+795ccc10
Editor X: ^1.5.0+cfca34f6
SDK: ^9.21.0+795ccc10
CSV: ^9.11.0+98498e58

and

pi@PetPi:~/OpenTAP $ pyvisa-shell

Welcome to the VISA shell. Type help or ? to list commands.

(visa) list
( 0) ASRL/dev/ttyAMA0::INSTR
( 1) USB0::11975::34816::800872011777270029::0::INSTR
(visa) xit
*** Unknown syntax: xit
(visa) open 1
USB0::11975::34816::800872011777270029::0::INSTR has been opened.
You can talk to the device using “write”, “read” or “query”.
The default end of message is added to each message.
(open) query *IDN?
Response: B&K Precision., 8600B, 800872011777270029, 1.39-1.42

(open)

So now I need to figure out the python config tab under settings…

Found and implemented the post on configuring the Python plugin for rPi. I noticed the folowing when starting TUI

XML Line 2: Unable to locate type ‘PythonVisa.PyVisa.PyVisaSettings’. Are you missing a plugin?

This is also reported when doing a package verify

XML Line 2: Unable to locate type ‘PythonVisa.PyVisa.PyVisaSettings’. Are you missing a plugin?
Package ‘PythonVisa’ verified.

Open Items:

  1. Any ideas on where I configure this or is this simply an erroneous message?

  2. When configuring the SCPI intrument address, it is marked as invalid (even though its good)

  3. I had to modify PyVisa.Py to avoid the non-implemented error for viClear as shown below

    def viClear(vi):
    return pyvisa.constants.StatusCode.success

The USBTMC instrument to respond to an *IDN? command via SCPI after ignoring the first two issues and patching for the third.

Thank you for the plugin.

Didn’t see your responses before, sorry!

I’ll dig through the issues and clean it up a bit more, thanks for all the detailed feedback.

So far I’ve tested with a Rigol Power supply (SCPI via USB tty) and a B&K (USBTMC) Programmable load. Both seem to work fine. Working on porting other instruments to the rPi, but not all have .NET drivers.

2 Likes

I finally got around to debugging this and as expected System.IO.Ports is not returning ttyS symlinks created in the /dev directory (it’s looking in /sys…).

My workaround in Linux for getting port names (after adding udev rules to create symbolic links/aliases for the serial devices) is to modify the instrument class constructor is as follows:

        if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            const string devDir = "/dev/";

            // Fallback to scanning /dev. 
            // Limit search tio names of interest

            var ports = new List<string>();
            foreach (var portName in Directory.EnumerateFiles(devDir, "tty*"))
            {
                if (portName.StartsWith("/dev/ttyS", StringComparison.Ordinal) ||
                    portName.StartsWith("/dev/ttyUSB", StringComparison.Ordinal) )
                {
                    ports.Add(portName);
                }
            }
            AvailablePorts = ports.ToArray();
        }
        else
        {
            AvailablePorts = SerialPort.GetPortNames();
        }

Hopefully this helps anyone using a ton of Serial devices with OpenTAP and Linux. While one has to map out the devices and name them in the rules.d file, they should enumerate to consistantly with recognizable names afterwards.

1 Like