Software
Java Programming Interface and Examples
(c) Spectrum GmbH
55
Java Programming Interface and Examples
Driver interface
The driver interface contains the following Java files (classes). The files need to be included in your Java project. Please do not edit any of
these files as they are regularily updated if new functions or registers have been included. The driver interface uses the Java Native Access
(JNA) library.
This library is licensed under the LGPL (https://www.gnu.org/licenses/lgpl-3.0.en.html) and has also to be included to your Java project.
To download the latest jna.jar package and to get more information about the JNA project please check the projects GitHub page under:
https://github.com/java-native-access/jna
The following files can be found in the „SpcmDrv“ folder of your Java examples install path.
SpcmDrv32.java / SpcmDrv64.java
The files contain the interface to the driver library and defines some needed constants. All functions of the driver interface are similar to the
above explained standard driver functions. Use the SpcmDrv32.java for 32 bit and the SpcmDrv64.java for 64 bit projects:
SpcmRegs.java
The SpcmRegs class defines all constants that are used for the driver. The constants names are the same names compared to the C/C++
examples. All constant names will be found throughout this hardware manual when certain aspects of the driver usage are explained. It is
recommended to only use these constant names for better readability of the programs:
SpcmErrors.java
The SpcmErrors class contains all error codes that may be returned by the driver.
Examples
Examples for Java can be found on CD in the directory /examples/java. The directory contains the above mentioned header files and some
examples, each of them working with a certain type of card. Please feel free to use these examples as a base for your programs and to modify
them in any kind.
...
public interface SpcmWin64 extends StdCallLibrary {
SpcmWin64 INSTANCE = (SpcmWin64)Native.loadLibrary (("spcm_win64"), SpcmWin64.class);
int spcm_hOpen (String sDeviceName);
void spcm_vClose (int hDevice);
int spcm_dwSetParam_i64 (int hDevice, int lRegister, long llValue);
int spcm_dwGetParam_i64 (int hDevice, int lRegister, LongByReference pllValue);
int spcm_dwDefTransfer_i64 (int hDevice, int lBufType, int lDirection, int lNotifySize,
Pointer pDataBuffer, long llBrdOffs, long llTransferLen);
int spcm_dwInvalidateBuf (int hDevice, int lBufType);
int spcm_dwGetErrorInfo_i32 (int hDevice, IntByReference plErrorReg,
IntByReference plErrorValue, Pointer sErrorTextBuffer);
}
...
...
public static final int SPC_M2CMD = 100;
public static final int M2CMD_CARD_RESET = 0x00000001;
public static final int M2CMD_CARD_WRITESETUP = 0x00000002;
public static final int M2CMD_CARD_START = 0x00000004;
public static final int M2CMD_CARD_ENABLETRIGGER = 0x00000008;
...