diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-07-20 10:19:13 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-07-20 10:19:13 +0000 |
commit | f3c061d5c8ef95a0bd2ec829cc1d7461af94a845 (patch) | |
tree | a65ba678fbd7c82ccef396bea49d71fcd58d6ca6 /Demos/Host/Incomplete/PrinterHost | |
parent | 211712d66d6949941141964341bb937bf1422636 (diff) | |
download | lufa-f3c061d5c8ef95a0bd2ec829cc1d7461af94a845.tar.gz lufa-f3c061d5c8ef95a0bd2ec829cc1d7461af94a845.tar.bz2 lufa-f3c061d5c8ef95a0bd2ec829cc1d7461af94a845.zip |
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).
Diffstat (limited to 'Demos/Host/Incomplete/PrinterHost')
-rw-r--r-- | Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c | 11 | ||||
-rw-r--r-- | Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h | 2 | ||||
-rw-r--r-- | Demos/Host/Incomplete/PrinterHost/PrinterHost.c | 6 |
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)
};
|