problem with handing over pointers and generic invoke

Benjamin Sommerfeld <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <[email protected]>
Hi guys,

I already wrote to this list about my problem and after weeks of reading
the latest documentation and trying out the latest development edition
of Jawin I decided to write you guys again, cause I just can't manage to
get the right result.

Here are the C-functions from the DLL I want to use with Jawin:

P100X_SetChannelConfig

Description :
This subroutine will set the AD channel’s configuration code. This
subroutine will set the active AD channel for P100X_AdPolling,
P100X_AdsPolling and P100X_AdsPacer. This function will refer to the
current active PCI-1002 board. Use the P100X_ActiveBoard(….) to select
the active board.

Syntax :
WORD P100X_SetChannelConfig(WORD wChannel, WORD wConfig);

Parameter:
wChannel : [Input] AD channel number
wConfig : [Input] Configuration code. Refer to Sec. 3.1 for details.

Return:
P100X_NoError : OK
P100X_ExceedBoardNumber : invalidate board number
P100X_FindBoardError : cannot find the PCI-1002 board
P100X_AdControllerError : MagicScan controller
hardware handshake error

------------------------------------------------------------------------------

P100X_Polling
Description :
Performs a single A/D conversion on the active channel by software
polling. The P100X_SetChannelConfig subroutine can be used to change
channel or configuration code. Use the P100X_ActiveBoard(….) to select
the active board.

Syntax :
WORD P100X_Polling(word *wAdVal);

Parameter:
wAdVal : [Output] address of wAdVal, which store the AD data
Data is returned as an integer value in the range 0-4095.

Return:
P100X_NoError : OK
P100X_ExceedBoardNumber : invalidate board number
P100X_FindBoardError : cannot find the PCI-1002 board
P100X_AdPollingTimeOut : hardware timeout error

----------------------------------------------------------------------------

My java code looks like this:

public void start() {
int result = 9999;
try {
String wTotalBoards = "0";
FuncPtr driverInit = new FuncPtr("P100X.DLL", "P100X_DriverInit");
result = driverInit.invoke_I(wTotalBoards, ReturnFlags.CHECK_NONE);
System.out.println("DriverInit: "+result);

FuncPtr activeBoard = new FuncPtr("P100X.DLL", "P100X_ActiveBoard");
result = activeBoard.invoke_I(0, ReturnFlags.CHECK_NONE);
System.out.println("ActiveBoard: "+result);

FuncPtr setChannelConfig = new FuncPtr("P100X.DLL",
"P100X_SetChannelConfig");
result = setChannelConfig.invoke_I(0,"0x00", ReturnFlags.CHECK_W32);
System.out.println("SetChannelConfig: "+result);

NakedByteStream nbs = new NakedByteStream();
FuncPtr polling = new FuncPtr("P100X.DLL", "P100X_Polling");
byte[] a = polling.invoke("A:I:n4", 16, nbs, null, ReturnFlags.CHECK_W32);
LittleEndianInputStream leis = new LittleEndianInputStream(new
ByteArrayInputStream(a));
try {
int retVal = leis.readInt();
System.out.println(retVal);
short bla = leis.readShort(); //wether i use readShort or readInt and
"bla" is an int - the result is the same
System.out.println(bla);
} catch (IOException e) {}

FuncPtr driverClose = new FuncPtr("P100X.DLL", "P100X_DriverClose");
driverClose.invoke_I(ReturnFlags.CHECK_NONE);
} catch (COMException e) {
e.printStackTrace();
}


---------------------------------------------------------------------------------------------------

the problem is: i always get the wrong result for "bla". Maybe it's
because of the configuration code in "setChannelConfig" which i hand
over as a string?
In the documentation it is said, that I should use "0x00" in C for
setting +/-10V as Channel Configuration.

"bla" is always 2300 although it should be some value around 500.....

Can anybody help me?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.