Fixed PrinterHost demo Printer_GetDeviceID() routine not removing the Device ID string length from the start of the returned array (thanks to John Andrews).

Fixed error in new pipe stream function template system not setting the right device token for R/W operations (also thanks to John Andrews).
This commit is contained in:
Dean Camera 2009-07-20 10:19:13 +00:00
parent 211712d66d
commit f3c061d5c8
6 changed files with 31 additions and 17 deletions

View file

@ -63,7 +63,7 @@ uint8_t Printer_SendData(Printer_Data_t* PrinterCommands)
*
* \return A value from the USB_Host_SendControlErrorCodes_t enum
*/
uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize)
uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize)
{
uint8_t ErrorCode = HOST_SENDCONTROL_Successful;
uint16_t DeviceIDStringLength;
@ -85,12 +85,15 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize)
if (DeviceIDStringLength > BufferSize)
DeviceIDStringLength = BufferSize;
USB_ControlRequest.wLength = (DeviceIDStringLength - 1);
USB_ControlRequest.wLength = DeviceIDStringLength;
if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
DeviceIDString[DeviceIDStringLength] = 0x00;
/* Move string back two characters to remove the string length value from the start of the array */
memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2);
DeviceIDString[DeviceIDStringLength - 2] = 0x00;
return HOST_SENDCONTROL_Successful;
}