Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-16-2004, 06:10 AM   #1
LQ Newbie
Registered: Jul 2004
Posts: 3

Rep: Reputation: 0
How i can write to device /dev/usb/hiddev0 ?

Hivoo. Help me with little little question.

I trying to connect my USB keyboard and write data, but....

something like that....
char * dev = "/dev/usb/hiddev0"; /// or char * dev = "/proc/bus/usb/003/001";
fd = open(dev, O_RDWR|O_NONBLOCK))

// and now i try write to fd

unsigned char outbuff[USB_BUFFSIZE];
int bytes = write(fd,&outbuff,USB_BUFFSIZE);

// but bytes returned -1 and errno returned EINVAL.

WHY????? HELP PLEASE!!! ANYBODY HELP elsewhere i did my SUICIDE!
Old 07-23-2004, 01:43 AM   #2
LQ Newbie
Registered: May 2004
Posts: 7

Rep: Reputation: 0
ok odds are that your usb keyboard needs initialization. It may need you to send it some configuration string that turns the device online. Read in the manual search online, etc for your brand of keyboard and programming related to it. Also a possiblity is that, you need to talk through the ioctl() function. THis is the case with the HID that i am working on. I will try to help you with that once i have cracked through that problem.

Old 08-17-2004, 04:16 AM   #3
LQ Newbie
Registered: Jul 2004
Posts: 2

Rep: Reputation: 0
usb hid for linux

We are working on the same project... so give me your email
I would like to read and write informations (just some bytes) with USB.
(For information my device is a pic which works in low speed in interrupt transfer .)
That works properly under windows...
And now reading from device is succeful under linus-2.4.20.

First, I 'd like to know if hid is the only driver for my device?
Secondly how do I use the libusb? where can I find it?

I use the file /dev/usb/hiddev0.
Here is your program:

typedef struct {
unsigned hid;
signed int value;
} hiddev_event;

ssize_t bytesread;
hiddev_event *buffer;

buffer=(hiddev_event *)malloc(sizeof(hiddev_event));



printf("Unknown event bytes=%d hid=%d value=%d\n",

When I try to write in fd (in order to write to the device) errno return me the value 22(EINVAL) although I open fd in O_WRONLY or O_RDWR...

Please help me.


Last edited by bast; 08-17-2004 at 04:17 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
which device in /dev is mapped to an USB device malo_umoran Slackware 4 07-31-2005 02:12 PM
Failed to open device /dev/usb/ttyUSB0: No such device efm Linux - Newbie 2 04-04-2005 09:46 PM
HP Deskjet (USB) & CUPS & Slackware 9.1: Unable to open USB device "usb:/dev/usb/lp0&qu arnostienen Slackware 2 01-29-2004 04:22 PM
write access on usb storage device wincen Linux - Hardware 3 01-20-2004 09:01 AM
/dev location or name of USB device dark_forests Linux - Hardware 3 10-13-2003 12:37 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration