Fixed PrinterHost demo Printer_GetDeviceID() routine not removing the Device ID strin...
[pub/USBasp.git] / Demos / Host / Incomplete / PrinterHost / Lib / PrinterCommands.c
index 87651e9..4e2a0d9 100644 (file)
@@ -63,7 +63,7 @@ uint8_t Printer_SendData(Printer_Data_t* PrinterCommands)
  *\r
  *  \return A value from the USB_Host_SendControlErrorCodes_t enum\r
  */\r
-uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize)\r
+uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize)\r
 {\r
        uint8_t  ErrorCode = HOST_SENDCONTROL_Successful;\r
        uint16_t DeviceIDStringLength;\r
@@ -85,12 +85,15 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize)
        if (DeviceIDStringLength > BufferSize)\r
          DeviceIDStringLength = BufferSize;\r
 \r
-       USB_ControlRequest.wLength = (DeviceIDStringLength - 1);\r
+       USB_ControlRequest.wLength = DeviceIDStringLength;\r
        \r
        if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
          return ErrorCode;\r
-       \r
-       DeviceIDString[DeviceIDStringLength] = 0x00;\r
+         \r
+       /* Move string back two characters to remove the string length value from the start of the array */\r
+       memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2);\r
+\r
+       DeviceIDString[DeviceIDStringLength - 2] = 0x00;\r
        \r
        return HOST_SENDCONTROL_Successful;\r
 }\r