LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 12-30-2003, 10:50 AM   #1
ectech
LQ Newbie
 
Registered: Dec 2003
Location: Illinois
Distribution: RH9
Posts: 3

Rep: Reputation: 0
Talking to USB HID


I need to send to and read from a USB device. So far, the hid driver seems to be the choice.

This is what I need to send and receive:
USHORT Buffer[9];

I have the file descriptor from:
if ((fd=open("dev/usb/hiddev0", O_RDONLY)) < 0)
{ perror("hiddev open");
exit(1);
}

I can get the report information from:

struct hiddev_report_info
{ unsigned report_type;
unsigned report_id;
unsigned num_fields;
}

struct hiddev_usage_ref
{ unsigned report_type:
unsigned report_id;
unsigned field_index;
unsigned usage_index;
unsigned usage_code:
_s32 value:
}

struct hiddev_usage_ref usage_ref;
struct hiddev_report_info rep_info;

--------
calling ioctl(fd, HIDIOCGREPORTINFO, &rep_info) and reading the struct
gives me rep_info.report_type = 1 (or 2 or 3)
rep_info.id = 0
rep_info.num_fields = 1

How do I fill in the structures rep_info and usage_ref to handle the nine element buffer? I assume I use:

ioctl(fd, HIDIOCSUSAGE, &usage_ref) and
ioctl(fd, HIDIOCSREPORT, &rep_info)

to send the buffer contents to the device, and

ioctl(fd, HIDIOCGREPORT, rep_info)

to read the device????????????
 
  


Reply



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 06:24 AM
talking to USB 2.0 without root?? deebuv Linux - Hardware 0 06-23-2004 09:27 AM
USB hid.o hijacking my USB Printer Relativity Linux - Hardware 0 12-09-2003 08:56 PM
Usb-hid RanmaPhreak79 Linux - Hardware 1 07-18-2003 08:32 PM
Usb + Hid vexer Slackware 4 05-28-2003 09:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:32 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration