Add new error condition to the HID Report Parser for when a report is parsed but...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 22 Sep 2009 08:07:48 +0000 (08:07 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 22 Sep 2009 08:07:48 +0000 (08:07 +0000)
Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.h
Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c
Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c
Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c
Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c
LUFA/Drivers/USB/Class/Host/HIDParser.c
LUFA/Drivers/USB/Class/Host/HIDParser.h

index 89e21bb..3f477ed 100644 (file)
                #define VIRTUAL_MEMORY_BYTES                ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS)\r
 \r
                /** Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying\r
-                *  storage media (Dataflash) using a different native block size.\r
+                *  storage media (Dataflash) using a different native block size. Do not change this value.\r
                 */\r
                #define VIRTUAL_MEMORY_BLOCK_SIZE           512\r
                \r
-               /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. */\r
+               /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not\r
+                *  change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.\r
+                */\r
                #define VIRTUAL_MEMORY_BLOCKS               (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)\r
                \r
        /* Function Prototypes: */\r
index b7b5a1e..cfba56d 100644 (file)
                #define VIRTUAL_MEMORY_BYTES                ((uint32_t)DATAFLASH_PAGES * DATAFLASH_PAGE_SIZE * DATAFLASH_TOTALCHIPS)\r
 \r
                /** Block size of the device. This is kept at 512 to remain compatible with the OS despite the underlying\r
-                *  storage media (Dataflash) using a different native block size.\r
+                *  storage media (Dataflash) using a different native block size. Do not change this value.\r
                 */\r
                #define VIRTUAL_MEMORY_BLOCK_SIZE           512\r
                \r
-               /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. */\r
+               /** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not\r
+                *  change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.\r
+                */\r
                #define VIRTUAL_MEMORY_BLOCKS               (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)\r
                \r
        /* Function Prototypes: */\r
index d898074..e9af0c0 100644 (file)
@@ -106,7 +106,7 @@ int main(void)
 \r
                                if (USB_HID_Host_SetReportProtocol(&Keyboard_HID_Interface) != 0)\r
                                {\r
-                                       printf("Could not Set Report Protocol Mode.\r\n");\r
+                                       printf("Error Setting Report Protocol Mode or Not a Valid Keyboard.\r\n");\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
@@ -114,7 +114,7 @@ int main(void)
                                \r
                                LEDs_SetAllLEDs(LEDS_NO_LEDS);\r
 \r
-                               printf("HID Device Enumerated.\r\n");\r
+                               printf("Keyboard Enumerated.\r\n");\r
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
                        case HOST_STATE_Configured:\r
index c33b2eb..f222eee 100644 (file)
@@ -106,7 +106,7 @@ int main(void)
 \r
                                if (USB_HID_Host_SetReportProtocol(&Mouse_HID_Interface) != 0)\r
                                {\r
-                                       printf("Could not Set Report Protocol Mode.\r\n");\r
+                                       printf("Error Setting Report Protocol Mode or Not a Valid Mouse.\r\n");\r
                                        LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
                                        USB_HostState = HOST_STATE_WaitForDeviceRemoval;\r
                                        break;\r
@@ -114,7 +114,7 @@ int main(void)
                                \r
                                LEDs_SetAllLEDs(LEDS_NO_LEDS);\r
                                \r
-                               printf("HID Device Enumerated.\r\n");\r
+                               printf("Mouse Enumerated.\r\n");\r
                                USB_HostState = HOST_STATE_Configured;\r
                                break;\r
                        case HOST_STATE_Configured:\r
index 3b97ad7..0cba5fc 100644 (file)
@@ -172,7 +172,11 @@ void Keyboard_HID_Task(void)
                        if ((ErrorCode = GetHIDReportData()) != ParseSuccessful)\r
                        {\r
                                puts_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n"));\r
-                               printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+\r
+                               if (!(HIDReportInfo->TotalReportItems))\r
+                                       puts_P(PSTR("Not a valid Keyboard." ESC_FG_WHITE));\r
+                               else\r
+                                       printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
                        \r
                                /* Indicate error via status LEDs */\r
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
@@ -200,7 +204,7 @@ void Keyboard_HID_Task(void)
                                         ((ReportSizeFeatureBits >> 3) + ((ReportSizeFeatureBits & 0x07) != 0)));\r
                        }\r
 \r
-                       puts_P(PSTR("HID Device Enumerated.\r\n"));\r
+                       puts_P(PSTR("Keyboard Enumerated.\r\n"));\r
 \r
                        USB_HostState = HOST_STATE_Configured;\r
                        break;\r
index 4d50ff6..b47858e 100644 (file)
@@ -171,8 +171,12 @@ void Mouse_HID_Task(void)
                        /* Get and process the device's first HID report descriptor */\r
                        if ((ErrorCode = GetHIDReportData()) != ParseSuccessful)\r
                        {\r
-                               printf_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n"\r
-                                                        " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+                               puts_P(PSTR(ESC_FG_RED "Report Parse Error.\r\n"));\r
+\r
+                               if (!(HIDReportInfo->TotalReportItems))\r
+                                       puts_P(PSTR("Not a valid Mouse." ESC_FG_WHITE));\r
+                               else\r
+                                       printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
                        \r
                                /* Indicate error via status LEDs */\r
                                LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
@@ -200,7 +204,7 @@ void Mouse_HID_Task(void)
                                         ((ReportSizeFeatureBits >> 3) + ((ReportSizeFeatureBits & 0x07) != 0)));\r
                        }\r
 \r
-                       puts_P(PSTR("HID Device Enumerated.\r\n"));\r
+                       puts_P(PSTR("Mouse Enumerated.\r\n"));\r
 \r
                        USB_HostState = HOST_STATE_Configured;\r
                        break;\r
index 450f6af..4d433e5 100644 (file)
@@ -296,6 +296,9 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID
                }\r
        }\r
        \r
+       if (!(ParserData->TotalReportItems))\r
+         return HID_PARSE_NoUnfilteredReportItems;\r
+       \r
        return HID_PARSE_Successful;\r
 }\r
 \r
index 2ee3f70..4322c51 100644 (file)
                                HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */\r
                                HID_PARSE_UsageStackOverflow          = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */\r
                                HID_PARSE_InsufficientReportIDItems   = 7, /**< More than \ref HID_MAX_REPORT_IDS report IDs in the device. */\r
+                               HID_PARSE_NoUnfilteredReportItems     = 8, /**< All report items from the device were filtered by the filtering callback routine. */\r
                        };\r
                \r
                /* Type Defines: */             \r