Discussion:
[libhid-discuss] simple output
Ael Gain
2009-02-11 18:02:35 UTC
Permalink
Hi everyone!
I'm new to USB programming and i'm trying to use libhid to communicate with a PIC18F4550.
I wrote these lines of code (almost the same than in test_libhid :) ) in order to send a byte to my PIC but, even if it produces no errors when i run it, it doesn't seems to work... :)
here is the code:

int main(){
int PATH_OUT[2] = { 0xffa00001, 0xffa00004 };

char write_packet[2] = { 31, 54 };

ret = hid_init();

HIDInterfaceMatcher matcher = { 0x1234, 0x0001, NULL, NULL, 0 };

hid = hid_new_HIDInterface();

ret = hid_force_open(hid, 0, &matcher, 3);

ret = hid_set_output_report(hid, PATH_OUT, 2, write_packet, 2);
if (ret != HID_RET_SUCCESS) {
printf( "dead\n");
}else{ printf("good!\n");}

return 0;
}

I'm wondering about my path, so, I paste you the return of lusb -vvv :

Report Descriptor: (length is 47)
Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
(null)
Item(Local ): Usage, data= [ 0x01 ] 1
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Local ): Usage, data= [ 0x03 ] 3
(null)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x00 0xff ] 65280
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x04 ] 4
(null)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x00 0xff ] 65280
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x05 ] 5
(null)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x00 0xff ] 65280
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x02 ] 2
Item(Main ): Feature, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection, data=none

Is my path allright ? Do you see any (many? :-) ) things wrong in my code ? I'm a bit lost in HID programming...

Thank you very much,
cloud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20090211/7493c32d/attachment.htm
Charles Lepple
2009-02-12 03:23:07 UTC
Permalink
Post by Ael Gain
Is my path allright ? Do you see any (many? :-) ) things wrong in
my code ? I'm a bit lost in HID programming...
The easiest way to tell is from the debug output.
--
Charles Lepple
Ael Gain
2009-02-13 18:27:54 UTC
Permalink
I'm not sure about what is the debug output but I'll paste this:

parse tree of HIDInterface 004/004[0]:
path: 0xffa00001.0xffa00003; type: 0x80
path: 0xffa00001.0xffa00004; type: 0x90
path: 0xffa00001.0xffa00005; type: 0xb0
path: 0xffa00001.0x00000000; type: 0xb0

and this, when i try my program:

TRACE: hid_prepare_parser(): setting up the HID parser for USB device
004/003[0]...
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...
TRACE: hid_prepare_parser(): dumping the raw report descriptor
TRACE: hid_prepare_parser(): 0x000: 0x06 0xa0 0xff 0x09 0x01 0xa1 0x01
0x09
TRACE: hid_prepare_parser(): 0x008: 0x03 0x15 0x00 0x26 0x00 0xff 0x75
0x08
TRACE: hid_prepare_parser(): 0x010: 0x95 0x01 0x81 0x02 0x09 0x04 0x15
0x00
TRACE: hid_prepare_parser(): 0x018: 0x26 0x00 0xff 0x75 0x08 0x95 0x01
0x91
TRACE: hid_prepare_parser(): 0x020: 0x02 0x09 0x05 0x15 0x00 0x26 0x00
0xff
TRACE: hid_prepare_parser(): 0x028: 0x75 0x08 0x95 0x02 0xb1 0x02 0xc0
TRACE: hid_prepare_parser(): parsing the HID tree of USB device
004/003[0]...
NOTICE: hid_prepare_parser(): successfully set up the HID parser for USB
device 004/003[0].

Thank you for your help,
cloud

----- Original Message -----
From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Thursday, February 12, 2009 4:23 AM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
Is my path allright ? Do you see any (many? :-) ) things wrong in my
code ? I'm a bit lost in HID programming...
The easiest way to tell is from the debug output.
--
Charles Lepple
Charles Lepple
2009-02-14 18:46:40 UTC
Permalink
That's what I am referring to.
Post by Ael Gain
path: 0xffa00001.0xffa00003; type: 0x80
This means you have one byte at path { 0xffa00001, 0xffa00003 }
(input)...
Post by Ael Gain
path: 0xffa00001.0xffa00004; type: 0x90
... one byte of output at { 0xffa00001, 0xffa00004 } ...
Post by Ael Gain
path: 0xffa00001.0xffa00005; type: 0xb0
path: 0xffa00001.0x00000000; type: 0xb0
and two feature bytes at { 0xffa00001, 0xffa00005 } (which can be
either input or output).

It sounds like you were trying to send two bytes to an output that
only expects one byte.
Post by Ael Gain
TRACE: hid_prepare_parser(): setting up the HID parser for USB device
004/003[0]...
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...
TRACE: hid_prepare_parser(): dumping the raw report descriptor
TRACE: hid_prepare_parser(): 0x000: 0x06 0xa0 0xff 0x09 0x01 0xa1 0x01
0x09
TRACE: hid_prepare_parser(): 0x008: 0x03 0x15 0x00 0x26 0x00 0xff 0x75
0x08
TRACE: hid_prepare_parser(): 0x010: 0x95 0x01 0x81 0x02 0x09 0x04 0x15
0x00
TRACE: hid_prepare_parser(): 0x018: 0x26 0x00 0xff 0x75 0x08 0x95 0x01
0x91
TRACE: hid_prepare_parser(): 0x020: 0x02 0x09 0x05 0x15 0x00 0x26 0x00
0xff
TRACE: hid_prepare_parser(): 0x028: 0x75 0x08 0x95 0x02 0xb1 0x02 0xc0
TRACE: hid_prepare_parser(): parsing the HID tree of USB device
004/003[0]...
NOTICE: hid_prepare_parser(): successfully set up the HID parser for USB
device 004/003[0].
Thank you for your help,
cloud
----- Original Message -----
From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Thursday, February 12, 2009 4:23 AM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
Is my path allright ? Do you see any (many? :-) ) things wrong in my
code ? I'm a bit lost in HID programming...
The easiest way to tell is from the debug output.
--
Charles Lepple
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Charles Lepple
2009-02-16 02:49:05 UTC
Permalink
[Please keep the list CC'd.]

The last debug line that you posted was this:

NOTICE: hid_prepare_parser(): successfully set up the HID parser
for USB
device 004/003[0].

There should have been other lines after that, referring to looking
up the path, and attempting to send the message to the device.

Also, the firmware may be expecting a message on an interrupt
endpoint, but you did not include that part of the 'lsusb' output.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
Ok thanks, I tried to send 1 byte instead of 2 at the path
{ 0xffa00001, 0xffa00004 } via the hid_set_output_report function
but i've steel no reactions at the pic level... I don't know what
to do, have you any idea ?
thank you,
----- Original Message ----- From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Saturday, February 14, 2009 7:46 PM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
That's what I am referring to.
Post by Ael Gain
path: 0xffa00001.0xffa00003; type: 0x80
This means you have one byte at path { 0xffa00001, 0xffa00003 }
(input)...
Post by Ael Gain
path: 0xffa00001.0xffa00004; type: 0x90
... one byte of output at { 0xffa00001, 0xffa00004 } ...
Post by Ael Gain
path: 0xffa00001.0xffa00005; type: 0xb0
path: 0xffa00001.0x00000000; type: 0xb0
and two feature bytes at { 0xffa00001, 0xffa00005 } (which can be
either input or output).
It sounds like you were trying to send two bytes to an output
that only expects one byte.
Post by Ael Gain
TRACE: hid_prepare_parser(): setting up the HID parser for USB device
004/003[0]...
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...
TRACE: hid_prepare_parser(): dumping the raw report descriptor
TRACE: hid_prepare_parser(): 0x000: 0x06 0xa0 0xff 0x09 0x01
0xa1 0x01
0x09
TRACE: hid_prepare_parser(): 0x008: 0x03 0x15 0x00 0x26 0x00
0xff 0x75
0x08
TRACE: hid_prepare_parser(): 0x010: 0x95 0x01 0x81 0x02 0x09
0x04 0x15
0x00
TRACE: hid_prepare_parser(): 0x018: 0x26 0x00 0xff 0x75 0x08
0x95 0x01
0x91
TRACE: hid_prepare_parser(): 0x020: 0x02 0x09 0x05 0x15 0x00
0x26 0x00
0xff
TRACE: hid_prepare_parser(): 0x028: 0x75 0x08 0x95 0x02 0xb1
0x02 0xc0
TRACE: hid_prepare_parser(): parsing the HID tree of USB device
004/003[0]...
NOTICE: hid_prepare_parser(): successfully set up the HID
parser for USB
device 004/003[0].
Thank you for your help,
cloud
----- Original Message -----
From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Thursday, February 12, 2009 4:23 AM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
Is my path allright ? Do you see any (many? :-) ) things wrong in my
code ? I'm a bit lost in HID programming...
The easiest way to tell is from the debug output.
--
Charles Lepple
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Ael Gain
2009-02-16 21:32:21 UTC
Permalink
It finaly works!! As you tell me, I simply use interrupt out and it just
worked as i expected!
Thank you very very much!

----- Original Message -----
From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Monday, February 16, 2009 3:49 AM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
[Please keep the list CC'd.]
NOTICE: hid_prepare_parser(): successfully set up the HID parser for USB
device 004/003[0].
There should have been other lines after that, referring to looking up
the path, and attempting to send the message to the device.
Also, the firmware may be expecting a message on an interrupt endpoint,
but you did not include that part of the 'lsusb' output.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
Ok thanks, I tried to send 1 byte instead of 2 at the path { 0xffa00001,
0xffa00004 } via the hid_set_output_report function but i've steel no
reactions at the pic level... I don't know what to do, have you any idea
?
thank you,
----- Original Message ----- From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Saturday, February 14, 2009 7:46 PM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
That's what I am referring to.
Post by Ael Gain
path: 0xffa00001.0xffa00003; type: 0x80
This means you have one byte at path { 0xffa00001, 0xffa00003 }
(input)...
Post by Ael Gain
path: 0xffa00001.0xffa00004; type: 0x90
... one byte of output at { 0xffa00001, 0xffa00004 } ...
Post by Ael Gain
path: 0xffa00001.0xffa00005; type: 0xb0
path: 0xffa00001.0x00000000; type: 0xb0
and two feature bytes at { 0xffa00001, 0xffa00005 } (which can be
either input or output).
It sounds like you were trying to send two bytes to an output that
only expects one byte.
Post by Ael Gain
TRACE: hid_prepare_parser(): setting up the HID parser for USB device
004/003[0]...
TRACE: hid_reset_parser(): resetting the HID parser for USB device
004/003[0]...
TRACE: hid_prepare_parser(): dumping the raw report descriptor
TRACE: hid_prepare_parser(): 0x000: 0x06 0xa0 0xff 0x09 0x01 0xa1
0x01
0x09
TRACE: hid_prepare_parser(): 0x008: 0x03 0x15 0x00 0x26 0x00 0xff
0x75
0x08
TRACE: hid_prepare_parser(): 0x010: 0x95 0x01 0x81 0x02 0x09 0x04
0x15
0x00
TRACE: hid_prepare_parser(): 0x018: 0x26 0x00 0xff 0x75 0x08 0x95
0x01
0x91
TRACE: hid_prepare_parser(): 0x020: 0x02 0x09 0x05 0x15 0x00 0x26
0x00
0xff
TRACE: hid_prepare_parser(): 0x028: 0x75 0x08 0x95 0x02 0xb1 0x02
0xc0
TRACE: hid_prepare_parser(): parsing the HID tree of USB device
004/003[0]...
NOTICE: hid_prepare_parser(): successfully set up the HID parser for
USB
device 004/003[0].
Thank you for your help,
cloud
----- Original Message -----
From: "Charles Lepple" <clepple at ghz.cc>
To: "Ael Gain" <ael.gain at free.fr>
Cc: "libhid-discuss List" <libhid-discuss at lists.alioth.debian.org>
Sent: Thursday, February 12, 2009 4:23 AM
Subject: Re: [libhid-discuss] simple output
Post by Charles Lepple
Is my path allright ? Do you see any (many? :-) ) things wrong in
my
code ? I'm a bit lost in HID programming...
The easiest way to tell is from the debug output.
--
Charles Lepple
_______________________________________________
libhid-discuss mailing list
libhid-discuss at lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Loading...