Corrections, improvements and additions to the incomplete RNDISHost demo.
[pub/USBasp.git] / Demos / Host / Incomplete / RNDISEthernetHost / RNDISEthernetHost.c
index a64dfbd..c84f0c0 100644 (file)
@@ -138,31 +138,33 @@ void PrintIncommingPackets(void)
        \r
        puts_P(PSTR("DATA IN\r\n"));\r
 \r
-       uint16_t PacketSize;\r
-       if ((ErrorCode = RNDIS_GetPacketSize(&PacketSize)) != HOST_SENDCONTROL_Successful)\r
+       uint16_t PacketLength;\r
+       if ((ErrorCode = RNDIS_GetPacketLength(&PacketLength)) != HOST_SENDCONTROL_Successful)\r
        {\r
                printf_P(PSTR(ESC_FG_RED "Packet Reception Error.\r\n"\r
-                                                                " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
+                                                                " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);            \r
+               return;\r
        }\r
-       else if (PacketSize > 2048)\r
+\r
+       printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketLength);\r
+\r
+       if (PacketLength > 1024)\r
        {\r
-               printf_P(PSTR(ESC_FG_RED "Packet of Size %d Too Large.\r\n" ESC_FG_WHITE), PacketSize);\r
-               Pipe_Discard_Stream(PacketSize);\r
+               puts_P(PSTR(ESC_FG_RED "Packet too large.\r\n" ESC_FG_WHITE));\r
+               Pipe_Discard_Stream(PacketLength);\r
        }\r
        else\r
        {\r
-               uint8_t PacketBuffer[PacketSize];\r
+               uint8_t PacketBuffer[PacketLength];\r
                \r
-               Pipe_Read_Stream_LE(&PacketBuffer, PacketSize);\r
+               Pipe_Read_Stream_LE(&PacketBuffer, PacketLength);\r
                \r
-               printf("***PACKET (Size %d)***\r\n", PacketSize);\r
-               for (uint16_t i = 0; i < PacketSize; i++)\r
-               {\r
-                       printf("%02x ", PacketBuffer[i]);\r
-               }\r
-               printf("\r\n\r\n");\r
+               for (uint16_t i = 0; i < PacketLength; i++)\r
+                 printf("%02x ", PacketBuffer[i]);\r
        }\r
        \r
+       printf("\r\n\r\n");\r
+\r
        LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
 \r
        Pipe_ClearIN();\r
@@ -213,8 +215,8 @@ void RNDIS_Host_Task(void)
                                break;\r
                        }\r
                        \r
-                       RNDIS_Initialize_Complete_t InitMessageResponse;\r
-                       if ((ErrorCode = RNDIS_InitializeDevice(1024, &InitMessageResponse)) != HOST_SENDCONTROL_Successful)\r
+                       uint16_t DeviceMaxPacketSize;\r
+                       if ((ErrorCode = RNDIS_InitializeDevice(1024, &DeviceMaxPacketSize)) != HOST_SENDCONTROL_Successful)\r
                        {\r
                                printf_P(PSTR(ESC_FG_RED "Error Initializing Device.\r\n"\r
                                                         " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
@@ -227,7 +229,7 @@ void RNDIS_Host_Task(void)
                                break;                  \r
                        }\r
                        \r
-                       printf_P(PSTR("Device Max Transfer Size: %lu bytes.\r\n"), InitMessageResponse.MaxTransferSize);\r
+                       printf_P(PSTR("Device Max Transfer Size: %lu bytes.\r\n"), DeviceMaxPacketSize);\r
                        \r
                        /* We set the default filter to only receive packets we would be interested in */\r
                        uint32_t PacketFilter = (RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST | RNDIS_PACKET_TYPE_ALL_MULTICAST);\r