Using rOmnidriver

Create issue
Issue #2 on hold
Nicholas Roberts created an issue

Dear Pedro

I’m really looking forward to using your library with our OO spectrometers.

After installing Omnidriver and then libraries (rJava, rOmniDriver), we always get the following error

w <- init_srs()
Error in .jnew("com/oceanoptics/omnidriver/api/wrapper/Wrapper") :
java.lang.ClassNotFoundException

rJava seems to be working ok - e.g.

s <- .jnew('java.lang.Object')

works fine.

Any help appreciated

Comments (6)

  1. Pedro J. Aphalo repo owner

    Please, let me know what operating system and version you are using. If you get RJava to work then you must have installed the Java JDK. rOmniDriver has been working for me. I haven’t needed to update it for quite some time, but anyway, please tell me which version you are trying to use (I am using 0.1.13 with Omnidriver 2.56). Under Windows during installation of Omnidriver an environment variable is set in the operating system pointing to the folder where Omnidriver is installed. This is used by my package to find the library. Please, check if R can find it by typing at the R console:

    Sys.getenv("OOI_HOME")

    The statement above should display the path to the folder where Omnidriver is installed. (If the value is not correct you could try to set the environment variable to point to the correct folder.)

    What has caused earlier problems with OS X has been the handling by the package of the string with the path which may need different ways of escaping of special characters such as spaces under different operating systems. I have been testing the package only under Windows, and I am planning to start testing under Linux, but I do not have accsess to Apple computers.

    On my PC I get with no spectrometer connected.

    > w <- init_srs()
    > number_srs(w)
    NatUSB_64
    Driver: NatUSBWin_64
    [1] 0
    > get_api_version(w)
    [1] "2.56"
    > 
    

    Please, do let me know any progress or lack of progress. I am very much interested in getting rOmniDriver debugged on as many OSs and hardware as possible.

    Thanks!

  2. Nicholas Roberts reporter

    Thanks so much Pedro.

    Yes we are using OSX - 10.14.5.

    R version 3.5.3 (2019-03-11) -- "Great Truth"
    Platform: x86_64-apple-darwin15.6.0 (64-bit)

    Java 8 version 221

    When rOmniDriver loads

    library(rOmniDriver)
    rOmniDriver
    OmniDriver initialization SUCCEEDED
    OI_HOME:
    Path: /OmniDriver.jar

    Running

    Sys.getenv("OI_HOME")
    [1] ""

    So yes the path to OI_HOME is not set - it is Macintosh HD⁩/⁨Applications⁩/⁨OmniDriverSPAM-2.56/OOI_HOME on this machine. ⁩

    When I set

    Sys.setenv(OI_HOME = "/Applications/OmniDriverSPAM-2.56/OOI_HOME")
    rJava::.jaddClassPath("/Applications/OmniDriverSPAM-2.56/OOI_HOME")

    Then w <- init_srs() works fine.

    The next line then fails with an error of

    n <- number_srs(w)
    Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.NoClassDefFoundError: Could not initialize class com.oceanoptics.uniusb.UniUSB

    I’m still working on this one.

    Many thanks

    Nick

  3. Pedro J. Aphalo repo owner

    This error is probably within the OmniDriver code itself, possibly not finding the USB driver. The function in my own package is coded as:

    open_all_spectrometers <- function(jwrapper){
    return(jwrapper$openAllSpectrometers())
    }

    number_srs <- open_all_spectrometers # add shorter name!

    What is the OmniDriver version you are using?

  4. Nicholas Roberts reporter

    The omnidriver version is the latest from OOs website - OmniDriver+SPAM 2.56

    I’ve noticed in the OOI_HOME folder there is separate UniUSB.jar file - is that needed in addition to OmniDriver.jar? and related to the error of

    Could not initialize class com.oceanoptics.uniusb.UniUSB

    Many Thanks

  5. Pedro J. Aphalo repo owner

    Hi,

    In Windows an USB driver gets installed when one plugs-in an spectrometer for the same time. I think in Linux and possibly Unix or OS X you may need to change permissions to be able to write to an USB port or install the driver. You could first try logged in as root or start R using sudo. This is wild guessing as I only occasionally use Linux.

    Nowadays most of the documentation for OmniDriver is openly available at the OO website, there may be something useful in it.

    Best wishes,

    Pedro.

  6. Pedro J. Aphalo repo owner

    Haven't heard from reporter if he could solve the problem or not. I have no access to OS X for testing myself.

  7. Log in to comment