Предыдущая тема :: Следующая тема |
Автор |
Сообщение |
Гость
|
Добавлено: Пт Сен 17 2004 16:18 Заголовок сообщения: USB Barcode-Reader Please help! |
|
|
Hi all , I'm trying to read from a USB Barcode-Reader "LX-250" (on Unix) ,
I've written the following code ...
But the program always failes on : ioctl call
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
Code:
Код: | #include <sys/stream.h>
#include <sys/kbio.h>
#include <sys/kbd.h>
#include <sys/types.h>
#include <sys/stropts.h>
#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/hid0" , O_RDWR);
if (fd < 0 ) {
exit (1);
}
printf("open /dev/usb/hid0 O.K\n");
if ((rval = ioctl(fd, I_PUSH,"usbkbm")) < 0 ) {
perror("ioctl failed");
exit (2);
}
while (read(fd, &fe, sizeof(fe))) {
printf("\n");
printf("%d", fe.id);
printf("%d", fe.value);
}
} |
The output is :
Код: | open /dev/usb/hid0 O.K
ioctl failed: Invalid argument |
Please If anyone has any suggestions.... |
|
Вернуться к началу |
|
|
совсем незнакомый
Зарегистрирован: 24.12.2003 Сообщения: 183 Откуда: Israel
|
Добавлено: Пн Сен 20 2004 06:46 Заголовок сообщения: |
|
|
if you have a normal & configured device, you can read from /proc entry all the things that the barcode reader has.
as for ioctl call... i think you should use some ready-to-use library for
barcode devices, try getting some application for this.
i recognise it is not linux that you use - there are several linux barcode reading packages - use them.
why do you have to code at all ?
have you tried to use "select" or "poll" ? |
|
Вернуться к началу |
|
|
Гость
|
Добавлено: Пн Сен 20 2004 14:03 Заголовок сообщения: select ? pull ? |
|
|
Thanks for replying.
What do you mean by select or pull (I'm new to stream programming)
Could you please write an example....
Thank you very much |
|
Вернуться к началу |
|
|
|