#pragma module ug_barcode_test "X-1" /* ******************************************************************************** ** ** ** © Copyright 1976, 2006 Hewlett-Packard Development Company, L.P. ** ** ** ** Confidential computer software. Valid license from HP and/or ** ** its subsidiaries required for possession, use, or copying. ** ** ** ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, ** ** Computer Software Documentation, and Technical Data for Commercial ** ** Items are licensed to the U.S. Government under vendor's standard ** ** commercial license. ** ** ** ** Neither HP nor any of its subsidiaries shall be liable for technical ** ** or editorial errors or omissions contained herein. The information ** ** in this document is provided "as is" without warranty of any kind and ** ** is subject to change without notice. The warranties for HP products ** ** are set forth in the express limited warranty statements accompanying ** ** such products. Nothing herein should be construed as constituting an ** ** additional warranty. ** ** ** ******************************************************************************** ** ** ** FACILITY: ** ** Example ** ** ABSTRACT: ** ** This module has minimal code to test a USB barcode reader. It needs ** to be linked to the barcode_support code, and possibly ug_hid_decode if ** barcode_support.c is built to display hid data. ** ** To test your barcode reader you will need to perform a couple of steps: ** ** 1) Tell the USB configuration code to create a new log file using the ** command UCM SET LOG.net ** ** 2) Plug the reader in. ** ** 3) Get the vendor, and product ID's, and release number. You get that ** from the command UCM SHOW EVENT/TYPE=ALL ** ** 4) Create and entry like the one blow for the Intermec barcode scanner ** and put it in the the file sys$system:sys$user_config.dat ** ** 5) Potentially delete the keyboard that got associated to the scanner ** do that with the UCM DELETE DEVICE KBD1 ** ** 7) Reboot the system. ** ** 8) Edit this file and change open_barcode and change arguemt 2 ** to match your devices vendor id, and arguemtn 3 to it's ** product id. You may need to change the second argument in ** the get_data call to match the amount of data your reader ** returns in a single burst. There are instructions in here on ** how to get that information. ** ** device = "Intermec barcode scanner" ** name = UG ** driver = sys$ugdriver ** begin_private ** usb_config_type = interface ** vendor_id = 1662 ** product_id = 256 ** release_number = 1 ** begin_interface ** interface_class = 3 ! Hid ** interface_sub_class = 1 ** interface_protocol = 1 ** end_interface ** end_private ** end_device ** ** The vendor and product ID'S also need to be supplied to the open ** barcode routine. They are used as part of a simple sanity check to ** make sure that we have the correct device. ** ** The user will also need to dump the HID data once to get the length ** of the input data from the scanner. A sample report is attached below: ** ** ** Item Hex Value ** -------------------------------------------------------------------------------- ** Usage Page Generic Desktop 05 01 ** Usage (reserved) 09 06 ** Collection Application a1 01 ** Usage Page Keyboard Keypad 05 07 ** Usage Minimum (e0) 19 e0 ** Usage Maximum (e7) 29 e7 ** Logical Minimum (00) 15 00 ** Logical Maximum (01) 25 01 ** Report Size (01) 75 01 ** Report Count (08) 95 08 ** Input (Data, Variable) 81 02 ** Report Count (01) 95 01 ** Report Size (08) 75 08 ** Input (Constant) 81 01 ** Report Count (05) 95 05 ** Report Size (01) 75 01 ** Usage Page LEDs 05 08 ** Usage Minimum (01) 19 01 ** Usage Maximum (05) 29 05 ** Output (Data, Variable) 91 02 ** Report Count (01) 95 01 ** Report Size (03) 75 03 ** Output (Constant) 91 01 ** Report Count (06) 95 06 ** Report Size (08) 75 08 ** Logical Minimum (00) 15 00 ** Logical Maximum (65) 25 65 ** Usage Page Keyboard Keypad 05 07 ** Usage Minimum (00) 19 00 ** Usage Maximum (65) 29 65 ** Input (Data, Array) 81 00 ** End Collection ** ** ** The determine the size of the input data you need to look for report ** count and report size fields that are followed by "Input" items. You will ** see 5 report size and count tags. The first, second and fith instances are ** the ones of interest. The total up to 8 bytes. Big warning this code ** assumes all items fall on byte boundaries. That may not always be the ** case. If so the decode_keys code will need to be rewritten. ** ** To get the report generated you need to compile this module with the ** symbol HID_DISPLAY defined. Then compule and link your code with ** barcode_support, and ug_hid_decode and run it. You can then recompile ** barcode_support and relink with out enabling the disply. ** ** ** AUTHOR: Forrest A. Kenney 08-September-2006 ** ** REVISION HISTORY: ** ** X-1 FAK001 Forrest A. Kenney 29-December-2006 ** Initial check in. **/ #include /* String descriptors */ #include /* Integer definitions */ #include /* LIB$_XXX definitions */ #include #include /* SMG definitions */ #include /* SMG routine prototypes */ #include /* System error codes */ #include /* System routines */ #include /* Stand I/O routines */ #include /* Standard LIB */ #include /* String functions */ #include "ug_barcode.h" #include "ugdef.h" #include DEVICE_DATA device; int main(int argc, char *argv[]) { unsigned char ascii_data[20]; int i; int ret_len; int status; if (argc >= 2) { device.device_name.dsc$b_dtype = DSC$K_DTYPE_T; device.device_name.dsc$b_class = DSC$K_CLASS_S; device.device_name.dsc$w_length = strlen(argv[1]); device.device_name.dsc$a_pointer = argv[1]; status = sys$assign(&device.device_name, &device.channels[0], 0, 0, 0); if (status & SS$_NORMAL) { status = open_barcode(&device, 1662, 256); do { status = get_data(&device, 8, &ascii_data[0], 20, &ret_len); if (status & SS$_NORMAL) { for (i = 0; i < ret_len; i++) { printf("%c", ascii_data[i]); if (ascii_data[i] == 0x0d) { printf("\n\n"); } } } } while (status & SS$_NORMAL); } } else { printf("No device specified\n"); status = SS$_NOSUCHDEV; } exit(status); }