VeeDub Posted May 5, 2009 Posted May 5, 2009 Hi,A friend of my has purchased a second-hand cash drawer to use at point-of-sale. The till works fine, but at the moment he is unable to configure his POS software to open the till for a sale, after doing some searching on the Net we have found that there is a DLL that can be used for this purpose. The DLL is part of an archive that can be downloaded hereThe readme for the DLL********************************************************************* * * * Posiflex USB CashDrawer Series USB CR DLL v1.03 Programming Guide * * * ********************************************************************* The driver required to control the Posiflex USB Cash Draweris called "USBCR.DLL". When the Posiflex USB Cash Drawer TestProgram is installed, this driver is stored in folder"C:\Windows\System" if the default Windows folder is"C:\Windows". Please preserve this file "USBCR.DLL" in thesystem folder for your software to control the Posiflex USBCash Drawer even if you want to uninstall the Posiflex testprogram.The driver "USBCR.DLL" provides 7 function calls: The 1--5 functions are for USB CashDrawer series to use.The 6--7 functions are for USB CashDrawer 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 success2. Public Declare Function CloseUSBcr Lib "usbcr.dll" () As Long ========== ' call this function before exiting your program ' return 0 on success3. 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 74. 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 error5. 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 USB CashDrawer Series to use, ' and it can drive 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 USB CashDrawer Series to use. ' and it can drive USB CashDrawer too.Note : For C++ programs: use __stdcall compiler optionCan someone convert a couple of these calls into DLLCall syntax so that I have a starting point to create a script that his POS program can call to open the cash drawer.ThanksVW
monoceres Posted May 5, 2009 Posted May 5, 2009 Those definitions really didn't look very advanced. You should be able to implement them yourself easily just with the aid of the help file. But since I'm such a nice guy I do the first one for ya' $usbcr=DllOpen("usbcr.dll") $call=DllCall($usbcr,"long","OpenUSBcr") If @error Or $call[0]<>0 Then ConsoleWrite("Fail."&@CRLF) Else ConsoleWrite("Success."&@CRLF) Endif Broken link? PM me and I'll send you the file!
VeeDub Posted May 7, 2009 Author Posted May 7, 2009 @monoceres Thanks for the direction. $call[0] Returns -2 Any idea why this might be? VW
monoceres Posted May 7, 2009 Posted May 7, 2009 @monoceres Thanks for the direction. $call[0] Returns -2 Any idea why this might be? VW Since the small info you posted said 0 is success I assume it is some sort of error code. You have to check the documentation for the library to see what error it is. Broken link? PM me and I'll send you the file!
ProgAndy Posted May 7, 2009 Posted May 7, 2009 (edited) I don't know, what -2 is. But you could try and use OpenUSB instead of OpenUSBcr. The "guide" is a bit confusing... no further information in it and this should be a programming guide... Edited May 7, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
VeeDub Posted May 8, 2009 Author Posted May 8, 2009 I don't know, what -2 is. But you could try and use OpenUSB instead of OpenUSBcr. The "guide" is a bit confusing... no further information in it and this should be a programming guide...I tried OpenUSB instead and no joy.I agree that the available information is limited, which makes the task difficult. In searching on the Net I see that other people have grappled with the same issue in the past with limited success.At this stage I've advised my mate to contact the manufacturer to see whether they can supply an exe that will eject the drawer, that really would seem to be the simplest solution and you would think such a program ought to exist.Failing that, a contact whom I can ask questions, or obtain better documentation on the DLLI have not programmed with DLL's before. There must be tools available that allow you to see what procedures/functions the DLL supports - and I guess there must also be ways of looking even "deeper" into DLL to see the code and thus ascertain what values can be returned ... but that would involve a fair bit of effort ... particularly when I have no experience with this level of programming. So at worst hopefully my mate can obtain some decent documentation to reference instead.Having seen that at different times other people have been looking for a program to eject the drawer, I am hopeful that I might yet be able to post an AutoIt script which others in the future might find when searching for a solution.ThanksVW
BrettF Posted May 8, 2009 Posted May 8, 2009 (edited) Just some stuff I thought of which may help... I take it is a USB draw? Is it like a virtual COM port? Is it possible to use COM to make it open? I also know some are hooked up to printers and when the printer gets the right code it opens the draw. But I don't think you have that setup from what it sounds like. Good luck with working this DLL out... They don't want to make it easy do they? Also, what is your current code? Cheers, Brett Edited May 8, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now