Giter Site home page Giter Site logo

Comments (23)

pfroud avatar pfroud commented on June 7, 2024

I appreciate your appreciation!

It looks like JVisa should be compatible with macOS. The first step is to fix the NoClassDefFoundError, which means Java can't find JNA. JNA is the library which lets JVisa talk to NI-VISA.

I suggest using NetBeans IDE for testing this. The JVisa git reposority contains files which make it a Netbeans project. If you clone the git reposority then go to Netbeans and click File > Open Project, then Netbeans should recognize the JVisa folder as a Netbeans project. The git reposority also contains a compiled JNA jar file, and the Netbeans project is already configured up to use it.

You are right that JVisa currently points to a dll file, here's the line:

VISA_LIBRARY = (JVisaLibrary) Native.load("nivisa64.dll", JVisaLibrary.class);

On a Mac, it looks like the file extension will be .dylib (dynamic library) or maybe .so (shared object). The file name could be libvisa or libnivisa. You can read the section called "Installed Files and Paths" in the NI-VISA 21.0 for macOS Readme to see where to look for it.

If you get it working, we can update the Java code to check the OS type.

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

Thank you for your quick reply!!!
Ahhh... I had not imported JNA into this project. I thought it was part of JVisa... I have tested my JNA library before in a separate project and I got that example to work (but it had no VISA functions).

After also adding JNA to my project I got the error that I was expecting (.dll file) as shown below:

Couldn't load nivisa.dll
java.lang.UnsatisfiedLinkError: Unable to load library 'nivisa64.dll':
dlopen(libnivisa64.dll.dylib, 9): image not found
dlopen(libnivisa64.dll.dylib, 9): image not found

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

OK good progress.

There's nothing special about these .java files, you should be able to edit them. How did you get the JVisa code on your computer? (Cloned using command-line git? Downloaded a ZIP from github.com?)

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

For this you'll need to get the JVisa source code, which are .java files.

A jar file is a package of compiled java classes. A jar lets you use the contents, but not edit them. Confusingly, your IDE tries to be helpful by automatically decompiling the jar file to show you source code -- but you can't edit it.

To get the JVisa source code you can click this link: https://github.com/pfroud/JVisa/archive/refs/heads/master.zip
It will download a file called JVisa-master.zip. Extract the zip file to a folder called JVisa-master.

NetBeans IDE will recognize the folder JVisa-master as a Netbeans project. It looks like IntelliJ will also be able to open the folder.

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Now you need to go looking for a dylib file that looks like belongs to Visa.

According to this page https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html

The standard locations for dynamic libraries are ~/lib, /usr/local/lib, and /usr/lib.

According to our friends at PyVISA, it will be called one of these:

"visa", "visa32", "visa32.dll", "visa64", "visa64.dll"

See https://github.com/pyvisa/pyvisa/blob/53a1d410f727e8d16212ceae3229e6219443f9aa/pyvisa/ctwrapper/highlevel.py#L95

And it looks like JVisa should load one of those libraries, not the NI-specific one

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

In JVisaResourceManager.java, try setting String nativeLibraryName to visa, visa32, and visa64 then try running SimpleExample.java each time

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Excellent news!

I hard-coded JVisa to only search for USB instruments which was dumb.

Please open JVisaResourceManager.java and edit line 159:

 final ByteBuffer filterExpression = stringToByteBuffer("USB?*");

Change the string from "USB?*" to "?*", so the line is

 final ByteBuffer filterExpression = stringToByteBuffer("?*");

And then run Simple Example again.

If everything works I will publish another release on Github.

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Could you clarify about Experiment number 2: only the Siglent multimeter is connected, but JVisa finds three instruments?

Have you ever used git? If you clone this repository, I can add debug printouts and push them to github so you can pull them to your computer.

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Sounds like we're trying to open random USB stuff which won't work.

Please replace SimpleExample.java with this file which has some debug printouts: SimpleExample.java.txt

Then run experiment number 2 only (one LAN instrument only) and reply with the output.

Git is software to keep track of changes to files. It is not easy to use so I'll just attach file to this issue. It does run on Mac (and Linux).

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Hi Mikael, thanks for running the experiments and sharing more details about your setup.

I think you are right about the ghost instruments, and I think that means JVisa is working correctly on your computer now.

The SimpleExample file tries to open everything it can find, including static ones. When you do have instruments connected, JVisa can open them and the *IDN? query works.

I will publish a new release on GitHub this week.

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

I released JVisa-2022-03-02, please test it...

https://github.com/pfroud/JVisa/releases/tag/JVisa-2022-03-02

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Great news! I will close this GitHub issue, thanks for helping me add that feature to the project.

If you can please try JVisa on Linux too and then post a comment in this issue: #2

from jvisa.

Amaruk2365 avatar Amaruk2365 commented on June 7, 2024

from jvisa.

pfroud avatar pfroud commented on June 7, 2024

Bummer, thanks for trying though.

I also looked into installing NI-VISA on Linux. Their instructions are not great. If you have Ubuntu version 18.04 or 20.04 I think I know how.

Here's the link to documentation for reference:

Download and Install NI Driver Software on Linux Desktop

from jvisa.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.