LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 07-23-2004, 01:53 AM   #1
Nightbird
LQ Newbie
 
Registered: May 2004
Posts: 7

Rep: Reputation: 0
Programming on a hid


OK i have a device and its firmware sets it up to use the HID driver built into linux. Now I am responsible for communicating with the device and making it useable for our project. I have been told by the manufacturer that I must use the ioctl() interface. the problem is that the ioctl() interface isn't documented well enough for me to glean the information that I need.

SO I am asking you, neigh begging you please someone help me!!
I need to send the device a two byte string containing 0x06 0x81 then all the following commands and responses I send and receive are to be 64 bytes in length. I have figure out that one of the defined HIDIOxxxxxxx things have something to do with the sending and receiving. I also know that I have to package my information into the hiddev_report_info structure. So can someone show me how this is done with the two byte initalization command and an example of the following 64 byte commands, please. Also, am I shooting myself in the foot here by not sending some already builtin init function, type, command or something. I have seen that one of the HIDIOxxxxxx enumerations is HIDIOINIT. Does this have to be the first thing that I send it? I have asked this device for its version number and application, so I know that it is working. (I was able to do this because I found a weblink to some examples, but that was the only HIDIOxxxx that they talked about, and they didn't show what the hiddev_report_info struct needed to look like.

Please anyone with any ideas on this, just give me anything that you have got!

Many thanks!
Nightbird
 
Old 08-17-2004, 04:26 AM   #2
bast
LQ Newbie
 
Registered: Jul 2004
Posts: 2

Rep: Reputation: 0
Is hid the only driver in our case?

Hi,
We are working for the same project so you can give me your adress 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;

main(){
ssize_t bytesread;
int FILEDES;
hiddev_event *buffer;

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

FILEDES=open("/dev/usb/hiddev0",O_RDONLY);

bytesread=1;
while(bytesread>0){
bytesread=read(FILEDES,buffer,sizeof(hiddev_event));

if(bytesread!=sizeof(hiddev_event)){
exit(1);
}
printf("Unknown event bytes=%d hid=%d value=%d\n",
bytesread,buffer->hid,buffer->value);
}
}

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.

B.GIRAUD<bastgiraud@wanadoo.fr>
 
  


Reply


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
Talking to USB-HID ectech Programming 1 10-24-2005 07:24 AM
HID compliant gamepad bobbens Linux - Hardware 6 10-27-2004 12:04 PM
Talking to USB HID ectech Programming 0 12-30-2003 11:50 AM
Usb-hid RanmaPhreak79 Linux - Hardware 1 07-18-2003 09:32 PM
Usb + Hid vexer Slackware 4 05-28-2003 10:46 PM


All times are GMT -5. The time now is 08:45 PM.

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