X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/7f9f97c792dee6875fbca9806422bdd7d6c5a657..d11ed10c5314c44dc01c06954d1d73d4894cbff8:/LUFA/Drivers/USB/Class/Device/CDC.c?ds=inline diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c index c274853de..b8a673f03 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.c +++ b/LUFA/Drivers/USB/Class/Device/CDC.c @@ -190,10 +190,17 @@ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterface Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); - if (Endpoint_IsOUTReceived() && !(Endpoint_BytesInEndpoint())) - Endpoint_ClearOUT(); + if (Endpoint_IsOUTReceived()) + { + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); - return Endpoint_BytesInEndpoint(); + return Endpoint_BytesInEndpoint(); + } + else + { + return 0; + } } uint8_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* CDCInterfaceInfo) @@ -263,6 +270,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(); }