Computing.Net > Forums > Programming > Reading from a USB Barcode-Reader o

Reading from a USB Barcode-Reader o

Reply to Message Icon

Original Message
Name: Yuval76
Date: September 12, 2004 at 04:46:07 Pacific
Subject: Reading from a USB Barcode-Reader o
OS: Solaris8
CPU/Ram: Blade150
Comment:


Hi all , I'm trying to read from a USB Barcode-Reader (on Solaris 8) ,
I've written the following code ...
But the program always exits on : (rval = ioctl(fd, I_PUSH,"usbkbm"))

Please if anyone has any ideas on what causes it to fail ?
Or how should I try to access the Barcode Device ?

Your help is very much appreciated !
Thanks


#include <sys/stream.h>
#include <sys/kbio.h>
#include <sys/kbd.h>

#include <sys/types.h> /*streamio -- STREAMS ioctl commands (for I_PUSH) */
#include <sys/stropts.h> /*streamio -- STREAMS ioctl commands (for I_PUSH) */

#include <sys/vuid_event.h>

#include <time.h>
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <stdlib.h>
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */

main( int argc, char *argv[]){
int fd,rval;
char c;
Firm_event fe;

fd = open("/dev/usb/hid3",O_RDWR);
if (fd < 0 ) {
exit (1);
}
if ((rval = ioctl(fd, I_PUSH,"usbkbm")) < 0 ) {
exit (1); // The program exits here all the time **********
}
while (read(fd, &fe, sizeof(fe))) {
printf("\n");
printf("%d", fe.id);
printf("%d", fe.value);
}
}



Report Offensive Message For Removal

Response Number 1
Name: wizard-fred
Date: September 12, 2004 at 10:50:59 Pacific
Subject: Reading from a USB Barcode-Reader o
Reply: (edit)

Don't know Solaris.

Your documentation should give you your interface.

With most of the commoner IBM_PC types of barcode readers the interface is a keyboard wedge. (Hardware - the device connects between the keyboard port and the keyboard and emulates the keyboard when it has a valid detect (read). Or Software - the device connects to the serial or the USB port. A software interface program captures the input and inserts the data into the keystroke buffer. These methods are used because it requires no modification to the program to capture data. Also in case of a bad read, the data can be simply keyboarded in.

It appears yours is a hardware port driver.
The software either continually reads the port for data or responses to an interrupt that data is available. These require software specifically designed to get the data and process it.

Your are apparently polling for data from the device and exits if not found. May be you should try continually reading the port and try triggering the bar code reader. Or is there a initiate read command. (I have a microscan reader that can be set up to read only on command) A study of both the hardware manual and the driver software documentation is needed.

The "usbkbm" interests me. It appears to be a type of "usb keyboard" interface.


Report Offensive Follow Up For Removal

Response Number 2
Name: Yuval76
Date: September 12, 2004 at 11:20:26 Pacific
Subject: Reading from a USB Barcode-Reader o
Reply: (edit)

Hi Thanks for responding !
Do you have any idea what the command:
rval = ioctl(fd, I_PUSH,"usbkbm")
does ?

What "I_PUSH" & "usbkbm" stands for ?

Thanks again!


Report Offensive Follow Up For Removal

Response Number 3
Name: wizard-fred
Date: September 12, 2004 at 12:48:40 Pacific
Subject: Reading from a USB Barcode-Reader o
Reply: (edit)

rval = returned value
ioctl = function to get staus
fd = file channel
I_PUSH = guess scan button status
usbkbm = module/variable name

fd is then used in read(.... )
fd is got from open(.... )

Read the docs, did the driver come with a SDK. What make/model of scanner, is it an internal decode?


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Reading from a USB Barcode-Reader o

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software