7 Replies Last post: Oct 19, 2009 5:11 PM by Ken Keith  
Ken Keith   5 posts since
Sep 28, 2009
Currently Being Moderated

Sep 28, 2009 11:30 PM

Type errors

I have a SDK with this construction:

 

2.5.2 I1_GetPosition
Description:
     Get the position of the arms of the Eye-One table.
Prototype:
     I1_ErrorType I1_GetPosition(float *positionX, float *positionY)
Parameters:
     positionX: position of the arms in x-direction
     positionY: position of the arms in y-direction
Return value:
     On success: eNoError
     On failure: eException

 

I keep getting this error in Netbeans:

 

Exception in thread "main" com.jniwrapper.FunctionExecutionException: Parameter types or their count are not correct

(see the bold line)

 

Using this:

 

private void setPosition(){
      
        UInt results = new UInt(10);
        SingleFloat yPosition = new SingleFloat(50.0F);
        SingleFloat xPosition = new SingleFloat(0.0F);
        DoubleFloat Null = new DoubleFloat();

        Pointer pXPos = new Pointer(xPosition);
        Pointer pYPos = new Pointer(xPosition);
        Function setPosition = _EyeOneiO.getFunction("I1_SetPosition");
        System.out.println(xPosition.getValue());
      
        setPosition.invoke(null, pXPos, pYPos);

 

    }

 

The machine moves like it is getting direction but then the error comes up.  If I drop the pointers there is no error.

 

Can anyone help?

 

I have included the SDK doc and the java file.

Attachments:
Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
1. Sep 29, 2009 6:01 PM in response to: Ken Keith
Re: Type errors

Hi Ken,

 

I think that in order to get rid of that "FunctionExecutionException: Parameter types or their count are not correct" exception you just need to specify the proper function calling convention, for instance:

private void setPosition(){
  UInt results = new UInt(10);
  SingleFloat yPosition = new SingleFloat(50.0F);
  SingleFloat xPosition = new SingleFloat(0.0F);
  DoubleFloat Null = new DoubleFloat();
 
  Pointer pXPos = new Pointer(xPosition);
  Pointer pYPos = new Pointer(xPosition);
  Function setPosition = _EyeOneiO.getFunction("I1_SetPosition");
  System.out.println(xPosition.getValue());
 
  setPosition.setCallingConvention(Function.CDECL_CALLING_CONVENTION); // or Function.STDCALL_CALLING_CONVENTION
  setPosition.invoke(null, pXPos, pYPos);
}

 

Please try this solution and let me know the resuts.

 

-Serge

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
3. Sep 30, 2009 3:54 PM in response to: Ken Keith
Re: Type errors

Hi Ken,

 

Thanks for the update.

 

To get the data from a Pointer object you need to use its getReferencedObject() method. Or, if you pass some parameter to a constructor of a Pointer (like new Pointer(xPosition)) then you do not need to call the getReferencedObject() method in order to get the updated value. In this case the 'xPosition' variable will be updated automatically after the funciton call, of course if a native function updates it.

 

-Serge

Serge Piletsky TeamDev Ltd. 1,066 posts since
Apr 24, 2006
Currently Being Moderated
5. Oct 16, 2009 10:09 PM in response to: Ken Keith
Re: Type errors

Hi,

 

I thinks that this printing issue has nothing to do with JNIWrapper. In fact the testXPos.getValue() just returns a primitive double value. And if you need to print it out in some specific way then you should use the standard Java utilities, such as MessageFormat or NumberFormat to get these values in readable format.

 

-Serge

More Like This

  • Retrieving data ...