[comp.sys.hp] Talking to HP-HIL bar code reader

tranter@testeng1.misemi (Jeff Tranter) (02/26/91)

We have been using an HP92916A bar code reader as part of a test
system programmed in BASIC/UX. Under BASIC, the bar code reader
behaved the same as if the input came from the keyboard.

We are now using a software platform written in C under HP-UX, and we
want to talk to the bar code reader. I have been able to read data
when the reader is set up for ASCII transmission, but for
compatibility with the BASIC software, I need to leave it set up for
USASCII keyboard mode.

The man page hil(7) says:

"Hil can only read HP-HIL keyboards in raw keycode mode. Raw keycode
mode means that all keyboard input is read unfiltered. HP-HIL
keyboards return keycodes that represent key press and key release
events".

The data I get agrees with this - it is not ASCII. I have two
questions:

1. Are the raw keycodes documented somewhere, so that I can convert
   them to ASCII? If so , where?

2. Am I going about this the wrong way?

The following is some of the code I am using to read the bar code reader.
This works when the reader was in ASCII mode.
I am running HP-UX 7.0 on a model 360.
The device file for the bar code reader looks like:

crw-rw-rw-   2 root     other     24 0x000030 Aug 14  1990 /dev/bar_code

#include <stdio.h>
#include <fcntl.h>
#include <sys/hilioctl.h>

void get_bar_code(code)
     char *code;
{
  int fd;
  unsigned char packet_length;
  unsigned char time_stamp[4];
  unsigned char poll_record_header;
  unsigned char data[20];

  /* open device file */
  fd = open("/dev/bar_code",O_RDONLY);

    do {
      read(fd, &packet_length, sizeof(packet_length));
      read(fd, time_stamp, sizeof(time_stamp));
      read(fd, &poll_record_header, sizeof(poll_record_header));
      read(fd, code, packet_length-6);
      code += packet_length-6;
    }
    /* carriage return indicates end of bar code */	
    while (*(code-1) != '\r');

    /* terminate string in null (and remove \r) */
    *(code-1) = 0;
  
    /* close device file */
    close(fd);
  }
-- 
Jeff Tranter               uunet: uunet!mitel!testeng1!tranter
Mitel Corporation       internet: Jeff_Tranter@mitel.com
Kanata, Ontario, CANADA      tel: (613) 592-2122 X4957  Fax: (613) 592-4784

steve-t@hpfcso.FC.HP.COM (Steve Taylor) (02/27/91)

In /comp.sys.hp/ tranter@testeng1.misemi (Jeff Tranter) // asks:
| 1. Are the raw keycodes documented somewhere, so that I can convert
|    them to ASCII? If so , where?

Yes.  If it's still available, they're listed in the _HP-HIL Technical
Reference Manual_, HP 45918A.
						Regards, Steve taylor

NOT A STATEMENT, OFFICIAL OR OTHERWISE, OF THE HEWLETT-PACKARD COMPANY.

rjn@hpfcso.FC.HP.COM (Bob Niland) (02/28/91)

re: > We have been using an HP92916A bar code reader as part of a test
    > system programmed in BASIC/UX. Under BASIC, the bar code reader
    > behaved the same as if the input came from the keyboard.

> 1. Are the raw keycodes documented somewhere, so that I can convert
>    them to ASCII? If so , where?

I developed this table as part of a keyboard investigation.  It should
contain what you need.

Scancode info: Downstrokes are even, set LSB (add 0x01) for upstroke

HIL   Cook                       ITF Keycap    
Scan  Mode  Key function         Legend        
Code  Code  is required by       (may differ)  
====  ====  ===================  ================
0x**  0x??  200: PAUSE\RESET,UP  <absent 46021>
0x**  0x00  200: <reserved>      <absent 46021>
0x**  0x04  200: <reserved>      <absent 46021>
0x**  0x1A  200: K0              <absent 46021>
0x**  0x25  200: K9              <absent 46021>
0x**  0x2A  200: RECALL          <absent 46021>
0x**  0x2D  200: CLR->END        <absent 46021>
0x**  0x2F  200: RUN             <absent 46021>
0x**  0x30  200: EDIT\DISP FCTNS <absent 46021>
0x**  0x31  200: ALPHA\DUMP AL.  <absent 46021>
0x**  0x32  200: GRAPHICS\DUMP G <absent 46021>
0x**  0x33  200: STEP\ANY CHAR   <absent 46021>
0x**  0x34  200: CLR LN\CLR SCR  <absent 46021>
0x**  0x35  200: RESULT\SET TAB  <absent 46021>
0x**  0x36  200: PRT ALL\CLR TAB <absent 46021>
0x**  0x37  200: CLR I/O\STOP    <absent 46021>
0x**  0x38  200: PAUSE\RESET,DN  <absent 46021>
0x**  0x3A  200: CONTINUE        <absent 46021>
0x**  0x3B  200: EXECUTE         <absent 46021>
0x**  0x4C  200: E {#pad}        <absent 46021>
0x**  0x4D  200: ( {#pad}        <absent 46021>
0x**  0x4E  200: ) {#pad}        <absent 46021>
0x**  0x4F  200: ^ {#pad}        <absent 46021>
0x**  0x80  Unassigned?          <absent 46021>
0x**  0x94-A8  Unassigned        <absent 46021>
0x**  0xAC-AF  Unassigned        <absent 46021>
0x**  0xB8-FD  Unassigned        <absent 46021>
0x**  =NMI  200: SHIFT[RESET]    <absent 46021>
0x00  0x82  IPC 5+Char           <absent 46021> 
0x00  0x82  IPC 5+Char           <absent 46021> 
0x02  0x**  ITF cursor repeat    <absent 46021>
0x04  0x13  hpterm,ITF           Extend {rt,DN}
0x05  0x93  hpterm,ITF           Extend {rt,UP}
0x06  0x12  hpterm,ITF           Extend {lf,DN}
0x07  0x92  hpterm,ITF           Extend {lf,UP}
0x08  0x**  ***,DOS,hpterm,ITF   Shift {rt}    
0x0A  0x**  ***,DOS,hpterm,ITF   Shift {lft}   
0x0C  0x**  ***,DOS,hpterm,ITF   CTRL          
0x0E  0x05  Unix,hpterm,ITF      Break\Reset   
0x0E  0x05  Unix,hpterm,ITF      Break\Reset   
0x10  0x44  DOS,ITF              4 <only>      
0x12  0x49  DOS,ITF              8 <only>      
0x14  0x45  DOS,ITF              5 {#pad}      
0x16  0x4A  DOS,ITF              9 <only>      
0x18  0x46  DOS,ITF              6 <only>      
0x1A  0x48  DOS,ITF              7 <only>      
0x1C  0x3E  DOS,***; ITF->       , {#pad}      
0x1E  0x08  DOS,hpblkterm,ITF    Enter{#pad}   
0x20  0x40  DOS,ITF              1 <only>      
0x22  0x4B  DOS,ITF              / {#pad}      
0x24  0x41  DOS,ITF              2 <only>      
0x26  0x3F  DOS,ITF              + {#pad}      
0x28  0x42  DOS,ITF              3 <only>      
0x2A  0x47  DOS,ITF              * {#pad}      
0x2C  0x3C  DOS,ITF              0 <only>      
0x2E  0x43  DOS,ITF              - {#pad}      
0x30  0x7C  ***,DOS,hpterm,ITF   b\B           
0x32  0x7B  ***,DOS,hpterm,ITF   v\V           
0x34  0x7A  ***,DOS,hpterm,ITF   c\C           
0x36  0x79  ***,DOS,hpterm,ITF   x\X           
0x38  0x78  ***,DOS,hpterm,ITF   x\Z           
0x3A  0x7E  NLS 16-bit function  <varies>      
0x3B  0xFE  NLS 16-bit function  <varies>      
0x3C  0x**  ITF Reserved         <absent 46021>
0x3E  0x03  ***,DOS,hpterm,ITF   ESC \ DEL     
0x40  0x83  IPC 6-Char           <absent 46021>
0x40  0x83  IPC 6-Char           <absent 46021>
0x42  0x0B  ***,DOS,ITF          <blank>  "f10"
0x44  0x81  IPC 3\Prev           <absent 46021>
0x46  0x0C  ***,DOS,ITF          <blank>  "f11"
0x48  0x3D  ***,DOS,ITF          . <only>      
0x4A  0x0A  ***,DOS,ITF          <blank>  "f9" 
0x4C  0x09  ***;    ITF->        |<Tab>| {#pad}
0x4E  0x0D  ***,DOS,ITF          <blank>  "f12"
0x50  0x75  ***,DOS,hpterm,ITF   h\H           
0x52  0x74  ***,DOS,hpterm,ITF   g\G           
0x54  0x73  ***,DOS,hpterm,ITF   f\F           
0x56  0x72  ***,DOS,hpterm,ITF   d\D           
0x58  0x71  ***,DOS,hpterm,ITF   s\S           
0x5A  0x70  ***,DOS,hpterm,ITF   a\A           
0x5C  0xA9  ITF Reserved         <absent 46021>
0x5C  0xA9  <used by X today for mode switch>  
0x5E  0x18  ***,DOS,hpterm,ITF   Caps          
0x60  0x6E  ***,DOS,hpterm,ITF   u\U           
0x62  0x6D  ***,DOS,hpterm,ITF   y\Y           
0x64  0x6C  ***,DOS,hpterm,ITF   t\T           
0x66  0x6B  ***,DOS,hpterm,ITF   r\R           
0x68  0x6A  ***,DOS,hpterm,ITF   e\E           
0x6A  0x69  ***,DOS,hpterm,ITF   w\W           
0x6C  0x68  ***,DOS,hpterm,ITF   q\Q           
0x6E  0x19  ***,DOS,hpterm,ITF   Tab>| \ |<Tab 
0x70  0x56  ***,DOS,hpterm,ITF   7\&           
0x72  0x55  ***,DOS,hpterm,ITF   6\^           
0x74  0x54  ***,DOS,hpterm,ITF   5\%           
0x76  0x53  ***,DOS,hpterm,ITF   4\$           
0x78  0x52  ***,DOS,hpterm,ITF   3\#           
0x7A  0x51  ***,DOS,hpterm,ITF   2\@           
0x7C  0x50  ***,DOS,hpterm,ITF   1\!           
0x7E  0x01  ***,DOS,hpterm,ITF   `\~           
0x80  0xB0  ITF Button 0         <absent 46021>
0x82  0xB1  ITF Button 1         <absent 46021>
0x84  0xB2  ITF Button 2         <absent 46021>
0x86  0xB3  ITF Button 3         <absent 46021>
0x88  0xB4  ITF Button 4         <absent 46021>
0x8A  0xB5  ITF Button 5         <absent 46021>
0x8C  0xB6  ITF Button 6         <absent 46021>
0x8E  0xB7  ITF Proximity(touch) <absent 46021>
0x90  0x15  ***,hpterm,ITF       Menu          
0x92  0x21  ***,DOS,hpterm,ITF   f4            
0x94  0x20  ***,DOS,hpterm,ITF   f3            
0x96  0x1C  ***,DOS,hpterm,ITF   f2            
0x98  0x1B  ***,DOS,hpterm,ITF   f1            
0x9A  0x84  IPC 8+Line           <absent 46021>
0x9C  0x06  DOS                  Stop          
0x9C  0x06  ITF                  Stop          
0x9E  0x11  ITF                  Enter\Print   
0xA0  0x14  DOS                  System\User   
0xA0  0x14  ITF                  System\User   
0xA2  0x1D  ***,DOS,hpterm,ITF   f5            
0xA4  0x1E  ***,DOS,hpterm,ITF   f6            
0xA6  0x1F  ***,DOS,hpterm,ITF   f7            
0xA8  0x24  ***,DOS,hpterm,ITF   f8            
0xAA  0x85  IPC 9-Line           <absent 46021>
0xAC  0x16  ITF->                Clear Line    
0xAE  0x17  ITF                  Clear Display 
0xB0  0x57  ***,DOS,hpterm,ITF   8\*           
0xB2  0x58  ***,DOS,hpterm,ITF   9\(           
0xB4  0x59  ***,DOS,hpterm,ITF   0\)           
0xB6  0x5A  ***,DOS,hpterm,ITF   -\_           
0xB8  0x5B  ***,DOS,hpterm,ITF   =\+           
0xBA  0x2E  ***,DOS,hpterm,ITF   Backspace     
0xBC  0x28  ITF->                Insert Line   
0xBE  0x29  ITF->                Delete Line   
0xC0  0x6F  ***,DOS,hpterm,ITF   i\I           
0xC2  0x64  ***,DOS,hpterm,ITF   o\O           
0xC4  0x65  ***,DOS,hpterm,ITF   p\P           
0xC6  0x5C  ***,DOS,hpterm,ITF   [\{           
0xC8  0x5D  ***,DOS,hpterm,ITF   ]\}           
0xCA  0x02  ***,DOS,hpterm,ITF   \ |           
0xCC  0x2B  ***,DOS,hpterm,ITF   Insert Char   
0xCE  0x2C  ***,DOS,hpterm,ITF   Delete Char   
0xD0  0x76  ***,DOS,hpterm,ITF   j\J           
0xD2  0x66  ***,DOS,hpterm,ITF   k\K           
0xD4  0x67  ***,DOS,hpterm,ITF   l\L           
0xD6  0x5E  ***,DOS,hpterm,ITF   ;\:           
0xD8  0x5F  ***,DOS,hpterm,ITF   '\"           
0xDA  0x39  ***,DOS,hpterm,ITF   Return        
0xDC  0x0E  ***,DOS,hpterm,ITF   <home arrow>  
0xDE  0x0F  ***,DOS,hpterm,ITF   Prev          
0xE0  0x77  ***,DOS,hpterm,ITF   m\M           
0xE2  0x60  ***,DOS,hpterm,ITF   ,\<           
0xE4  0x61  ***,DOS,hpterm,ITF   .\>           
0xE6  0x62  ***,DOS,hpterm,ITF   ?\/           
0xE8  0xAA  ITF Reserved         <absent 46021>
0xE8  0xAA  ITF Reserved         <absent 46021>
0xEA  0x07  ***,ITF              Select        
0xEC  0xAB  ITF Reserved         <absent 46021>
0xEC  0xAB  ITF Reserved         <absent 46021>
0xEE  0x10  ***,DOS,hpterm,ITF   Next          
0xF0  0x7D  ***,DOS,hpterm,ITF   n\N           
0xF2  0x63  ***,DOS,hpterm,ITF   <spacebar>    
0xF4  0x86  IPC .\Next           <absent 46021>
0xF6  0x7F  NLS 16-bit function  <varies>      
0xF7  0xFF  NLS 16-bit function  <varies>      
0xF8  0x26  ***,DOS,hpterm,ITF   <arrowleft>   
0xFA  0x22  ***,DOS,hpterm,ITF   <arrowdown>   
0xFC  0x23  ***,DOS,hpterm,ITF   <arrowup>     
0xFE  0x27  ***,DOS,hpterm,ITF   <arrowright>  

Regards,                                              Hewlett-Packard
Bob Niland      Internet: rjn@FC.HP.COM               3404 East Harmony Road
                UUCP: [hplabs|hpfcse]!hpfcrjn!rjn     Ft Collins CO 80525-9599

This response does not represent the official position of, or statement by,
the Hewlett-Packard Company.  The above data is provided for informational
purposes only.  It is supplied without warranty of any kind.