Guest
|
Need help for USB HID report descriptor |
Posted: Thu Jun 15, 2006 6:14 am |
|
|
Hi Guys,
I have already search in differents topics of the CCS forum, but I can't find a solution for my problem.
I need your help !!!
I'am building a Thermostat USB with the example provide by CCS (ex_usb_hid.c).
I'am using a PIC 18F2550
I know that my problem come from the HID report descriptor.
I have searched differents example but nothing can't help me.
I can receive my 11 data of one byte from the PIC to my computer.
I am using a Visual Basic application created by Hidmaker (Tracesystems) to communicate with the windows HID driver.
My problem is the other side:
I send 7 data of one byte to the PIC from my computer, my application is saying to me that it's done, but when I look the watches in the debbuger mode, I see that I receive only the last data not all of my data.
_____________________________________________________________
This my main C code:
while (TRUE) {
// Gestion de la sonde et acquisition de la valeur de temp�rature
sonde();
// Gestion du relais
//relay();
// Usb task
usb_task();
// Fonction usb_debug_task qui affiche sur la liaison s�rie les echanges de
// communication du bus USB
usb_debug_task();
// Si l'enumaration est faite alors nous pouvons communiquer
if (usb_enumerated()) {//Si la fonction �num�ration est vraie alors
if (!send_timer) {//Si le timer est different de 0
send_timer=250;
// Envoie des valeurs au PC
out_data[0]=45; // InTempVarLsb valeur du poid faible de la temp�rature
out_data[1]=1; // InTempVarMsb valeur du poid fort de la temp�rature
out_data[2]=1; // IntempLowVarLsb valeur du poid faible de la temp�rature de d�clenchement TL
out_data[3]=1; // IntempLowVarMsb valeur du poid fort de la temp�rature de d�clenchement TL
out_data[4]=2; // InTempHighVarLsb valeur du poid faible de la temp�rature de d�clenchement TH
out_data[5]=2; // InTempHighVarMsb valeur du poid fort de la temp�rature de d�clenchement TH
out_data[6]=19; // InSwitchVar variable non utilis�
out_data[7]=97; // InModeStatus variable de l'etat du mode du relais
out_data[8]=Heater_sensor.ds18b20_status; // InsondeStatus, 0 tout est ok ,1 ligne one wire court-circuit�e,
// 2 pas de capteur et 3 erreur de crc lors de la lecture de la temp�rature;
out_data[9]='c'; // InBootStatus variable dedier au bootloader
out_data[10]=relais; // InEtatRelay variable de l'�tat du relais 0 ou 1
if (usb_put_packet(1, out_data, 11, USB_DTS_TOGGLE))
printf("\r\n<-- Sending 2 bytes: 0x%X 0x%X", out_data[0], out_data[1]);
}
// r�ception des valeurs depuis le PC
if (usb_kbhit(1)) {
usb_get_packet(1, in_data, 7);
printf("\r\n--> Received data: 0x%X 0x%X",in_data[0],in_data[1]);
if (in_data[0]) {LED_ON(LED_RELAY);} else {LED_OFF(LED_RELAY);}
if (in_data[1]) {LED_ON(LED_ERROR);} else {LED_OFF(LED_ERROR);}
test = in_data[0];
test2 = in_data[1];
test3 = in_data[2];
}
send_timer--;
delay_ms(1);
}
}
_____________________________________________________________
This is my report descriptor:
const char USB_CLASS_SPECIFIC_DESC[] = {
6, 0, 255, // Usage Page = Vendor Defined
9, 1, // Usage = IO device
0xa1, 1, // Collection = Application
0x19, 1, // Usage minimum
0x29, 11, // Usage maximum
0x15, 0x80, // Logical minimum (-128)
0x25, 0x7F, // Logical maximum (127)
/////////////////////////////////////////////////////////////
// The input report (PIC to the PC)
0x75, 8, // Report size = 8 (bits)
//
0x95, 11, // Report count = 16 bits (2 bytes)
//
0x81, 2, // Input (Data, Var, Abs)
//////////////////////////////////////////////////////////////
// The output report (PC to the PIC)
0x19, 1, // Usage minimum
0x19, 12, // Usage maximum
0x75, 8, // Report size = 8 (bits)
//
0x95, 7, // Report count = 16 bits (2 bytes)
//
0x91, 2, // Output (Data, Var, Abs)
0xc0 // End Collection
};
//if a class has an extra descriptor not part of the config descriptor,
// this lookup table defines where to look for it in the const
// USB_CLASS_SPECIFIC_DESC[] array.
//first element is the config number (if your device has more than one config)
//second element is which interface number
//set element to 0xFFFF if this config/interface combo doesn't exist
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
{
//config 1
//interface 0
0
};
//if a class has an extra descriptor not part of the config descriptor,
// this lookup table defines the size of that descriptor.
//first element is the config number (if your device has more than one config)
//second element is which interface number
//set element to 0xFFFF if this config/interface combo doesn't exist
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
{
//config 1
//interface 0
32
};
_____________________________________________________________
This is the result of my VB application:
est results: 15.06.2006 13:35:11
Device # 1:
+ + + A Report has just ARRIVED. + + +
Report num in current Interface = 1
Report num in global report list = 0
//It's come from the PIC
InTempVarLsb 45
InTempVarMsb 1
InTempLowVarLsb 1
InTempLowVarMsb 1
InTempHighVarLsb 2
InTempHighVarMsb 2
InTempSwitchVar 19
InModeStatus 97
InSondeStatus 0
InBootStatus 99
InEtatRelay 0
----------------------------------------------------------------
//It's send to the pic
Wrote to device: OutTempLowVarLsb = 0x1
Wrote to device: OutTempLowVarMsb = 0x2
Wrote to device: OutTempHighVarLsb = 0x3
Wrote to device: OutTempHighVarMsb = 0x4
Wrote to device: OutModeRelayVar = 0x5
Wrote to device: OutBootStatus = 0x6
Wrote to device: OutBootVar = 0x7
+ + + A Report has just been SELECTED. + + +
Report num in global report list = 1
Successfully wrote to device
____________________________________________________________
This is my debbuger result :
out_data = (45,1,1,1,2,2,19,97,0,99,0,0,0,0,0,0,0,0,0,0)
in_data = (7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
---->Wrote to device: OutBootVar = 0x7
_____________________________________________________________
I hope there is enough informations to solve my problem.
Thanks in advance.
risou550 |
|