\r
/** \file\r
*\r
- * Printer Device commands, to send/recieve data to and from an attached USB\r
+ * Printer Device commands, to send/receive data to and from an attached USB\r
* printer, and to send and receive Printer Class control requests.\r
*/\r
\r
/** Sends the given data directly to the printer via the data endpoints, for the sending of print commands in printer\r
* languages accepted by the attached printer (e.g. PCL).\r
*\r
- * \param[in] PrinterCommands Pointer to a structure containing the commands and length of the data to send\r
+ * \param[in] PrinterCommands Pointer to the data to send to the attached printer\r
+ * \param[in] CommandSize Size of the data to send to the attached printer\r
*\r
* \return A value from the Pipe_Stream_RW_ErrorCodes_t enum\r
*/\r
-uint8_t Printer_SendData(Printer_Data_t* PrinterCommands)\r
+uint8_t Printer_SendData(void* PrinterCommands, uint16_t CommandSize)\r
{\r
uint8_t ErrorCode;\r
\r
Pipe_SelectPipe(PRINTER_DATA_OUT_PIPE);\r
Pipe_Unfreeze();\r
\r
- if ((ErrorCode = Pipe_Write_Stream_LE(PrinterCommands->Data, PrinterCommands->Length)) != PIPE_RWSTREAM_NoError)\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(PrinterCommands, CommandSize)) != PIPE_RWSTREAM_NoError)\r
return ErrorCode;\r
\r
Pipe_ClearOUT();\r
- while (!(Pipe_IsOUTReady()));\r
+ while (!(Pipe_IsOUTReady()))\r
+ {\r
+ if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+ }\r
\r
Pipe_Freeze();\r
\r
wIndex: 0,\r
wLength: sizeof(DeviceIDStringLength),\r
};\r
+ \r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
\r
if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful)\r
return ErrorCode;\r
wLength: sizeof(uint8_t),\r
};\r
\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
return USB_Host_SendControlRequest(PortStatus);\r
}\r
\r
wLength: 0,\r
};\r
\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
return USB_Host_SendControlRequest(NULL);\r
}\r
\r