X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/5aa2b26261389cfbdfae8e793be4b8150ddc7a0a..d03d6513d0d24cf63225c8d3dfa07675d9107f40:/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c?ds=sidebyside diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c index d35d22af1..e31f9a336 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -36,7 +36,7 @@ #include "RNDISEthernetHost.h" -/** Buffer to hold incomming and outgoing Ethernet packets. */ +/** Buffer to hold incoming and outgoing Ethernet packets. */ uint8_t PacketBuffer[1024]; /** LUFA RNDIS Class driver interface configuration and state information. This structure is @@ -143,10 +143,11 @@ int main(void) printf("Device Vendor ID: 0x%08lX\r\n", VendorID); printf("RNDIS Device Enumerated.\r\n"); + LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: - // TODO + PrintIncomingPackets(); break; } @@ -156,6 +157,27 @@ int main(void) } } +/** Prints incoming packets from the attached RNDIS device to the serial port. */ +void PrintIncomingPackets(void) +{ + if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface)) + { + LEDs_SetAllLEDs(LEDMASK_USB_BUSY); + + uint16_t PacketLength; + RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength); + + printf("***PACKET (Size %d)***\r\n", PacketLength); + + for (uint16_t i = 0; i < PacketLength; i++) + printf("%02x ", PacketBuffer[i]); + + printf("\r\n\r\n"); + + LEDs_SetAllLEDs(LEDMASK_USB_READY); + } +} + /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) {