From 71e5bcee3d1121be680990cabe8ae5dff2a78807 Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Mon, 4 Jan 2010 00:14:09 +0000
Subject: [PATCH] Fixed blocking CDC streams not aborting when the host is
 disconnected.

---
 LUFA/Drivers/USB/Class/Device/CDC.c   | 3 +++
 LUFA/ManPages/ChangeLog.txt           | 1 +
 LUFA/ManPages/LUFAPoweredProjects.txt | 5 ++++-
 LUFA/ManPages/WhyUseLUFA.txt          | 2 +-
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c
index c274853de..16bc01549 100644
--- a/LUFA/Drivers/USB/Class/Device/CDC.c
+++ b/LUFA/Drivers/USB/Class/Device/CDC.c
@@ -263,6 +263,9 @@ static int CDC_Device_getchar_Blocking(FILE* Stream)
 {
 	while (!(CDC_Device_BytesReceived((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))))
 	{
+		if (USB_DeviceState == DEVICE_STATE_Unattached)
+		  return _FDEV_EOF;
+	
 		CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));
 		USB_USBTask();
 	}
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index eea1f2b64..03c19b4a4 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -27,6 +27,7 @@
   *  - Fixed AVRISP project not able to enter programming mode when ISP protocol is used
   *  - Fixed AVRISP PDI race condition where the guard time between direction changes could be interpreted as a start bit
   *  - Fixed ADC_IsReadingComplete() returning an inverted result
+  *  - Fixed blocking CDC streams not aborting when the host is disconnected
   *
   *  \section Sec_ChangeLog091223 Version 091223
   *
diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt
index f1b36884d..df31db8e9 100644
--- a/LUFA/ManPages/LUFAPoweredProjects.txt
+++ b/LUFA/ManPages/LUFAPoweredProjects.txt
@@ -34,15 +34,18 @@
  *  - Arcade Controller: http://fletchtronics.net/arcade-controller-made-petunia
  *  - Bicycle POV: http://www.code.google.com/p/bicycleledpov/
  *  - CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig
+ *  - ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/
  *  - "Fingerlicking Wingdinger" (WARNING: Bad Language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/
  *  - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master
- *  - Generic HID Device Creator : http://generichid.sourceforge.net/
+ *  - Generic HID Device Creator: http://generichid.sourceforge.net/
  *  - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm
+ *  - Linux Secure Storage Dongle: http://github.com/TomMD/teensy
  *  - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g
  *  - Opendous-JTAG, an open source JTAG device: http://code.google.com/p/opendous-jtag/
  *  - Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/
  *  - Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm
  *  - Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/
+ *  - Purdue Interactive Kiosk: https://engineering.purdue.edu/477grp4/
  *  - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/
  *  - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398
  *  - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/
diff --git a/LUFA/ManPages/WhyUseLUFA.txt b/LUFA/ManPages/WhyUseLUFA.txt
index 34976ecfe..22ac75f66 100644
--- a/LUFA/ManPages/WhyUseLUFA.txt
+++ b/LUFA/ManPages/WhyUseLUFA.txt
@@ -40,7 +40,7 @@
  *    into difficulties or need some advice. In addition, you can also email the library author to recieve personalised
  *    support when you need it (subject to author's schedule).
  *
- *   <small>* Atmel Stack Mouse Device Demo 4292 bytes, LUFA Mouse Low Level Device Demo 3336 bytes, under identical build
+ *   <small>* Atmel Stack Mouse Device Demo 4292 bytes, LUFA Mouse Low Level Device Demo 3392 bytes, under identical build
  *   environments</small>
  */
  
\ No newline at end of file
-- 
GitLab