CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB HID, how send/receive more than 2 bytes?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mikrosurfer



Joined: 03 Mar 2009
Posts: 1

View user's profile Send private message

USB HID, how send/receive more than 2 bytes?
PostPosted: Tue Mar 03, 2009 10:34 pm     Reply with quote

Hello, I am studying the example ex_usb_hid.c, the example works fine, The problem is that only two bytes transmitted every time, the comment above says:
Quote:

//// The first byte sent by the PIC is the ADC reading ////
//// on channel 0 (AN0), the second byte is the status of the ////
//// pushbutton. The two bytes sent by the PC are LED on/off ////
//// toggle status. If you want to change the protocol to ////
//// send/receive more than 2 bytes you must change the HID report ////
//// descriptor. ////

as is done to change the number of bytes sent.

Thanks for your help.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 12:35 am     Reply with quote

You may want to consult the HID device class specifications http://www.usb.org/developers/hidpage/
JimmyZ
Guest







PostPosted: Sun Dec 13, 2009 10:52 am     Reply with quote

How to send this to my USB device:

char SomeText = 'This is some text';
int SomeNum = 10;

Jim
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 13, 2009 11:17 am     Reply with quote

A HID report is just a block of data, you have to define it's usage for your application. You define that the first one or
two bytes are used as a type ID, or another location as a length code. Using this arrangement on both sides
(host and device) you get an unequivocal assignment of each data item sent through USB.
JimmyZ
Guest







PostPosted: Sun Dec 13, 2009 11:39 am     Reply with quote

I'm sorry but I don't understand you.
I understand the transfer but have no clue how to make this.

In my PIC program I have those variables and I send the same ones from my PC application. This is all I have.

If I get this OK , then I should make this
Code:
usb_get_packet(1,SomeText);

Problems in my understanding are how to get this data.
I can not write.
Code:
usb_get_packet(1,SomeText);
usb_get_packet(1,SomeNUm);
usb_get_packet(1,SomeThingElse);
....

I search the whole forum for this.
Jim
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 13, 2009 2:02 pm     Reply with quote

Code:
unsigned int16 usb_get_packet(int8 endpoint, int8 * ptr, unsigned int16 max)

The first point is to understand the data types involved with usb_get_packet, the second to understand
what the HID protocol expects in this case.

By function definition, the data object must evaluate to an int8 pointer, this would work with a string of text,
but not with a numerical variable. Also a value for the max packet length parameter must be supplied.

HID is working with "report" packets of fixed or variable length. As long as you don't know in advance, what
kind of data comes in, it's most simple to receive it to a buffer structure and copy it to the respective data
items, or, to declare the buffer as a union of different data items.

The HID protocol also defines a report ID as optional element, but if you don't need to be compatible to a standard
HID device, you can define a packet structure freely.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group