\r
uint8_t Printer_GetDeviceID(Device_ID_String_t* DeviceIDString)\r
{\r
- uint8_t ErrorCode = HOST_SENDCONTROL_Successful;\r
+ uint8_t ErrorCode = HOST_SENDCONTROL_Successful;\r
+ uint16_t DeviceIDStringLength;\r
\r
USB_ControlRequest = (USB_Request_Header_t)\r
{\r
bRequest: GET_DEVICE_ID,\r
wValue: 0,\r
wIndex: 0,\r
- wLength: sizeof(DeviceIDString),\r
+ wLength: sizeof(DeviceIDString->Length),\r
};\r
\r
- if ((ErrorCode == USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
+ if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
return ErrorCode;\r
- \r
- DeviceIDString->Length = SwapEndian_16(DeviceIDString->Length);\r
\r
+ DeviceIDStringLength = SwapEndian_16(DeviceIDString->Length);\r
+\r
/* Protect against overflow for the null terminator if the string length is equal to or larger than the buffer */\r
- if (DeviceIDString->Length >= sizeof(DeviceIDString->String))\r
- DeviceIDString->Length = sizeof(DeviceIDString->String) - 1;\r
+ if (DeviceIDStringLength >= sizeof(DeviceIDString->String))\r
+ DeviceIDStringLength = sizeof(DeviceIDString->String) - 1;\r
+\r
+ USB_ControlRequest.wLength = DeviceIDStringLength;\r
+ \r
+ if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
\r
- DeviceIDString->String[DeviceIDString->Length] = 0x00;\r
+ DeviceIDString->String[DeviceIDStringLength] = 0x00;\r
\r
return HOST_SENDCONTROL_Successful;\r
}\r