aboutsummaryrefslogtreecommitdiffstats
path: root/Demos
diff options
context:
space:
mode:
Diffstat (limited to 'Demos')
-rw-r--r--Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c11
-rw-r--r--Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h2
-rw-r--r--Demos/Host/Incomplete/PrinterHost/PrinterHost.c6
3 files changed, 11 insertions, 8 deletions
diff --git a/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c b/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c
index 87651e906..4e2a0d9db 100644
--- a/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c
+++ b/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c
@@ -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;
}
diff --git a/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h b/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h
index 9ba6d4d5d..4656d190e 100644
--- a/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h
+++ b/Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h
@@ -62,7 +62,7 @@
/* Function Prototypes: */
uint8_t Printer_SendData(Printer_Data_t* PrinterCommands);
- uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize);
+ uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize);
uint8_t Printer_GetPortStatus(uint8_t* PortStatus);
uint8_t Printer_SoftReset(void);
diff --git a/Demos/Host/Incomplete/PrinterHost/PrinterHost.c b/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
index d9f409e97..79e6f9ee8 100644
--- a/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
+++ b/Demos/Host/Incomplete/PrinterHost/PrinterHost.c
@@ -180,7 +180,7 @@ void USB_Printer_Host(void)
case HOST_STATE_Configured:
puts_P(PSTR("Retrieving Device ID...\r\n"));
- char DeviceIDString[128];
+ char DeviceIDString[256];
if ((ErrorCode = Printer_GetDeviceID(DeviceIDString, sizeof(DeviceIDString))) != HOST_SENDCONTROL_Successful)
{
puts_P(PSTR(ESC_FG_RED "Control Error (Get DeviceID).\r\n"));
@@ -206,8 +206,8 @@ void USB_Printer_Host(void)
Printer_Data_t TestPageData =
{
- "\033%-12345X\033E LUFA PCL Test Page \033E\033%-12345X",
-// "\033@\033i\001\033X\001\060\000\r\nLUFA ESCP/2 Test Page\r\n",
+// "\033%-12345X\033E LUFA PCL Test Page \033E\033%-12345X",
+ "\033@\033i\001\033X\001\060\000\r\nLUFA ESCP/2 Test Page\r\n",
(sizeof(TestPageData.Data) - 1)
};