Path: utzoo!utgpu!cunews!mitel!testeng1!tranter From: tranter@testeng1.misemi (Jeff Tranter) Newsgroups: comp.sys.hp Subject: Talking to HP-HIL bar code reader Message-ID: <6694@testeng1.misemi> Date: 25 Feb 91 20:06:30 GMT Reply-To: tranter@mitel.com Organization: Mitel Corporation Lines: 68 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 #include #include 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 Brought to you by Super Global Mega Corp .com