- 论坛徽章:
- 0
|
[color=blue]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[/color]
#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);[b] // The program exits here all the time [/b]**********
}
while (read(fd, &fe, sizeof(fe))) {
printf("\n");
printf("%d", fe.id);
printf("%d", fe.value);
}
} |
|