UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2004-09-12 07:51 PM

Anonymous
Member
Registered: 2002-04-16
Posts: 24

Re: Reading from a USB Barcode-Reader on Solaris8

#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); 
	} 
}

Offline

#2 2004-09-12 08:10 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Reading from a USB Barcode-Reader on Solaris8

Please use the

...

tags around code in the future to
preserve formatting...  I added them to the above...

I know nothing about Solaris or the specific ioctl() in question, but
why don't you do perror() or print out strerror(errno) before exit()'ing,
which should hopefully tell you what the problem is?

Offline

Board footer

Powered by FluxBB