Python Instrument with latest opentap 9.29

I am attempting to update from OpenTap 9.23.1 to 9.29.1.

The main motivation is to be able to use the new cross platform Editor for Linux.

I installed opentap 9.29.1 on Ubuntu 20.04.

If I install my existing plugins I previously built using net6.0 / opentap 9.23, everything works fine.

If I rebuild my plugins using net9.0 and opentap 9.29 sdk, everything works fine except the one python instrument plugin.

Below is the interface for the instrument in my ‘M9000’ plugin

namespace Jtag
{
    // Interface to JtagInstrument implemented in python.  Python is used for the 
    // instrument because the JTAG library urjtag has an existing python binding
    public interface IJtagInstrument : IInstrument
    {
        void detect(bool force=true);
        void reset();
        void part(int part);
        void svf(string path, int stop, long freq);
        void flashmem(int addr, string path);
        void instruction(string instr);
        void shift_dr();
        string get_dr_in();
        void set_dr_in(string bits);
        void set_signal(int part, string name, int dir, int value);
        int  get_signal(int part, string name);
        int len();
    }
}

And the implementation of the python Instrument

import opentap
from opentap import *
from System import String, Int32, Enum, Boolean
import OpenTap
from OpenTap import Log, DisplayAttribute, Display, FilePathAttribute, FilePath

import urjtag
import clr
clr.AddReference("M9000")
from Jtag import IJtagInstrument # JtagInstrument c# interface we implement


@attribute(OpenTap.Display("JTAG Interface", "JTAG Interface adapter instrument.", "M9000 FCT"))
class JtagInstrument(Instrument, IJtagInstrument):
    Cable = property(String, "m9000-fct")\
        .add_attribute(OpenTap.Display("Cable", "Name of the cable driver"))

    def __init__(self):
        super(JtagInstrument, self).__init__()
        self.Name = "JtagInstrument"
        self.jtag = None
        self._inited=False
         
    def Open(self):
        self.detected = False
        self.jtag = urjtag.chain()
        self.jtag.cable(self.Cable)
        self.reset()

    def Close(self):
        self.jtag.disconnect()
    
    def detect(self, force=True):
        # detect can't be called as part of the instrument open sequence since
        # the DUT is not available at that time.  We track if detection has 
        # happened and allow it to be cached if force is overridden
        if (force or not self.detected):
            self.jtag.tap_detect()
            self.detected = True
    
    def reset(self):
        self.jtag.reset()

    def part(self, part):
        self.jtag.part(part)

    def svf(self, svf, stop, freq):
        self.jtag.run_svf(svf, stop, freq);
    
    def flashmem(self, addr, image):
        self.jtag.detectflash(0)
        self.jtag.flashmem(str(addr), image, 1)

    def instruction(self, inst):
        self.jtag.set_instruction(inst)
        self.jtag.shift_ir()
        self._instruction = inst
    
    def shift_dr(self):
        self.jtag.shift_dr()
    
    def get_dr_in(self):
        return self.jtag.get_dr_in_string();

    def set_dr_in(self, bits):
        self.jtag.set_dr_in(bits);
    
    def set_signal(self, part, sig, out, val):
        self.jtag.set_signal(part, sig, out, val)
    
    def get_signal(self, part, sig):
        return self.jtag.get_signal(part, sig)
    
    def len(self):
        return self.jtag.len()

Again, this works if I build my M9000 plugin using net6.0 and opentap 9.23 sdk, but if I build with net9.0 and opentap 9.29 sdk, I have a python error when the JtagInstrument is installed.

Caught exception loading M9000.JtagInstrument: No module named 'Jtag'

The Python plugin version is 3.1.

The version of python on Ubuntu 20.04 is Python 3.8.10

I’m not very familiar with python dotnet and what things would cause the assembly to load but still fail to find the module.

Both python and opentap are 64bit.

Since the clr.AddReference succeeds, I am assuming this isn’t any kind of python path problem?

Are there requirements on the version of Python / Python plugin that go along with updating to net9.0?

Thanks,

Wittrock

Hi @wittrock,

Thanks for raising the issue.

Since you were already on .net6, its a bit surprising if moving to .net9 would give any issues.

Did you try having a separate OpenTAP installation in another folder and just move your plugin over?

For example, what happens if you copy the opentap 9.23 based build. And then in that folder do tap package install OpenTAP --version 9.29?

  • If that has the same issue. What about updating to 9.28?

Thanks @rolf_madsen ,

Yes, as mentioned, if I just use my existing plugin built against opentap 9.23 sdk / .net6.0, then everything works with opentap 9.29 including the python based instrument.

Likewise, If I just update to 9.29 in place on my existing 9.23 installation folder (and install .net9.0), everything works.

I am only running into a problem if I re-build my plugin using opentap 9.29 sdk / .net9.0. If I do this, everything works except the python instrument. In this case, when the instrument is loaded, it can’t see the ‘Jtag’ ( or other) namespace in my M9000 plugin. From what I can tell, the assembly is found and loaded. For some reason, it just can’t see the instrument interface.

I could just continue to use 9.23/net6 to build my plugins, but I am trying to use a common environment for development and production so trying to find the root problem.

Thanks,

Wittrock

Has anyone else run into problems with using opentap 9.29 / net9 and python?

I still have the same issues. Everything works fine if I build the plugins with 9.23 / net6 then use those plugins with 9.29. I just can’t seem to use the plugins build against 9.29 / net9

Hi @wittrock, which version are you using?

I’d suggest you to try the newest Python plugin RC, there will be a 3.2 release in the not too distant future.