diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-09-28 15:56:27 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-09-28 15:56:27 +0000 |
commit | e57e08c67237cf73d28afac7f672ec1e74ec308d (patch) | |
tree | fbcde1d11f182543074a13c0ca5b8e6e911c7560 /Demos/Host/LowLevel | |
parent | 409c49f057f2d1cdea1fc2856ac20771bc0089d1 (diff) | |
download | lufa-e57e08c67237cf73d28afac7f672ec1e74ec308d.tar.gz lufa-e57e08c67237cf73d28afac7f672ec1e74ec308d.tar.bz2 lufa-e57e08c67237cf73d28afac7f672ec1e74ec308d.zip |
Fixed PrinterHost demo returning invalid Device ID data when the attached device does not have a device ID (thanks to Andrei Krainev).
Diffstat (limited to 'Demos/Host/LowLevel')
-rw-r--r-- | Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c index 7ed8898e3..c75b7f910 100644 --- a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c +++ b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c @@ -77,7 +77,7 @@ uint8_t Printer_SendData(void* PrinterCommands, uint16_t CommandSize) uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize)
{
uint8_t ErrorCode = HOST_SENDCONTROL_Successful;
- uint16_t DeviceIDStringLength;
+ uint16_t DeviceIDStringLength = 0;
USB_ControlRequest = (USB_Request_Header_t)
{
@@ -92,6 +92,12 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize) if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
+
+ if (!(DeviceIDStringLength))
+ {
+ DeviceIDString[0] = 0x00;
+ return HOST_SENDCONTROL_Successful;
+ }
DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength);
|