|
The three Visual C (VC) and three Visual Basic (VB) example programs are intended for the use of programmers. The source code is included. You will need to have the appropriate Visual Studio components in order to take full advantage of these tools. These programs show how to perform bi-directional communication with a Boca Systems printer on a serial, parallel or USB port in VC and again in VB. If you are interested in the sample source code supplied here, download sample_code.zip into a directory (typically c:\boca ). This file was created using WinZip, and should be unzipped using the same (or similar) tool. Unzipping this file will create some subdirectories under the c:\boca directory that contain each project.
DOWNLOAD: [sample_code. zip] Released -
September 2003 Objective The purpose of this document is to assist the programmer in communicating bi-directionally with Boca Systems Ticket Printer using a parallel, serial or USB interface. The sample code and documentation provided offer a starting point for developers wishing to communicate with a Boca Systems Printer. The process of opening a port, writing to a printer, reading from a printer and closing a port is demonstrated in all six example projects. There are three projects each in VB and VC using a parallel, serial or USB interface. Please feel free to borrow whatever code and concepts are applicable to your application.
DescriptionSample_code.zip contains samples of VC and VB code showing techniques for writing to and reading from a Boca Systems Ticket Printer. The VB version has a GUI front end and the VC version is menu driven. To support bi-directional USB communication with Boca Systems printers, both USB sample applications rely on utility programs supplied in a Dynamic Link Library (DLL). Please note that the DLL is only used for USB (not parallel or serial) communications.
EnvironmentThe sample code has been developed and tested in a Windows environment using Microsoft Visual C++ and Visual Basic. It is fully compatible with Windows 98, Millennium, 2000 and XP. Windows 95 and NT do not fully support bi-directional communication on all interfaces. If you need bi-directional parallel or USB communication, we suggest that you consider upgrading to one of the compatible operating systems.
DLL Calls for USBA USB port provides levels of efficiency greater than parallel or serial ports. A USB port is also more complicated to deal with than parallel or serial ports. To simplify this for our customers, a library of routines providing low level USB communication has been provided in the form of a DLL. There is a DLL file named boca.dll included with the VC version of the software and boca_vb.dll with the VB version. These DLLs provide communication routines for multiple Boca Systems Inc. printers on USB ports or hubs. These routines are accessible to developers through calls in VB or VC as displayed in the sample code. The routines provide initialization, communication and determine the total number of Boca USB printers plugged into a PC. Below is an interface description for the DLLs supporting the VB and VC USB projects. There is more detailed inline documentation in the code along with the calls to the DLL routines.
VB USB interface description for boca_vb.dll
When Find_Printers is called, it will perform three tasks. It will scan usb ports and hubs for Boca Systems Printers and populate a table with the information found. It will open the port to the first printer it finds. The function also returns the number of Boca Systems USB printers found and written to the table.
You will notice in the example VB code that the parameters hUSB, and pBuffer are defined as “Any” in the Declare statements. This allows the developer to define these parameters types when the call is actually made. There are many uses of the type called “Any”. One of them is VB's way of getting around the linking problems created when Basic routines are calling C routines and passing pointers to structures. Visual Basic does not support many structure types such as user-defined structures. Also, VB does not support certain types, such as Strings, in the same way as C. In the calls of the routines that use these parameters, you will notice they are all defined as “Long”. These parameters are used as pointers in the C++ subroutines that reside in the DLL file and pointers are passed as “Long” regardless of to what it points.
The globally defined variable known as “ptr_USB” is a pointer. It points to the USB hardware configuration data. This pointer is initialized upon successfully calling “Find_Printers”.
The globally defined variable known as “text” is a byte array used as a buffer to transmit/receive bytes of data to/from a Boca Systems USB printer. The parameter pBuffer points to this buffer and is passed between the VB and VC routines as a Long. When preparing to call “Write_USB” to send data out the USB port, it is necessary to convert any text data entered from a keyboard, etc into ASCII integers stored as bytes. The “Convert” routine performs this function as well as initializes the pointer to the text buffer (ptr_buffer) and the string size variable (Str_Size).
VC USB Interface description for boca.dll
USB Driver Uninstall ProceduresCustomers who have accidentally installed our bi-directional drivers will have difficulty getting the printer to work over the USB interface. In order to restore your computer to working order, you will need to uninstall the bi-directional drivers and re-install the USB Print drivers as shown below:
Contacts, References and UpdatesThis document and the source code supplied has all been written by:
Boca Systems Inc. Voice: (561) 998-9600 1065 South Rogers Circle Fax: (561) 998-9609 Boca Raton FL 33487
For questions, comments and suggestions please email: michael@bocasystems.com Please refer any use of an FGL command to the FGL Programming Guide. |
|
RETURN TO TOP |