Hi
I'm trying to write an application to open a cash drawer.
It is a Posiflex USB Cash Drawer model: CR 1405.
A usb driver (usbcr.dll) has been provided.
From the Programmers manual it seem's straight forward
The driver "USBCR.DLL" provides 7 function calls:
The 1--5 functions are for CR-4XX5-II series to use.
The 6--7 functions are for CR-4XX5 series to use.
The examples of Visual Basic are list below.
1. Public Declare Function OpenUSBcr LIB "usbcr.dll" () As Long
=========
' must be called before calling other functions
' return 0 on success
2. Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long
==========
' call this function before exiting your program
' return 0 on success
3. Public Declare Function DrawerOpen Lib "usbcr.dll" (ByVal ID As Long) As Long
==========
' return 0 on sending commands successfully, -1 on error
' 'ID' is the drawer number from 0 to 7
4. Public Declare Function DrawerState Lib "usbcr.dll" (ByVal ID As Long) As Long
===========
' return the drawer status
' high nibble is the drawer ID, and
' low nibble is 0 if drawer is open, 1 if drawer is closed
' return -1 on error
5. Public Declare Function RetrieveStatistics Lib "usbcr.dll" (ByVal ID As Long, ByVal idx As Long, ByRef buf As Any, ByVal size As Long) As Long
==================
' return 0 on sending commands successfully, -1 on error
' 'size' is the number of bytes which can be held by 'buf'
' 'buf' will hold the value read from memory in cash drawer
' This function used to Retrieve the device statistics of Unified POS1.8.
6. Public Declare Function OpenUSB Lib "usbcr.dll" () As Long
=======
' must be called before calling other functions
' return 0 on success
' This function is for CR-4xx5 Series to use,
' and it can drive CR-4xx5-II too.
7. Public Declare Function CloseUSB Lib "usbcr.dll" () As Long
========
' call this function before exiting your program
' return 0 on success
' This function is for CR-4xx5 Series to use.
' and it can drive CR-4xx5-II too.
From the test application, I deduced the drawer id is 7, using the native methods and load libraries I get expceptions
//public native long OpenUSB();
//public native long CloseUSB();
public native long DrawerOpen();
//public native long DrawerState();
//public native long RetrieveStatistics(long ID, long idx, String buf , long size);
static {
System.loadLibrary("USBCR");
}
public static void main(String[] args) {
USBCR d = new USBCR();
d.DrawerOpen();
System.out.println("test");
}
I receive the following exception
Exception in thread "main" java.lang.UnsatisfiedLinkError: USBCR.DrawerOpen(J)J
at USBCR.DrawerOpen(Native Method)
at USBCR.main(USBCR.java:18)
I compiled using javac, then javah -jni and ran with java.
Any advice on what is happening?
Am I on the right path? Completely of the mark? Any help would be greatly appreciated.