X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/2a90f66de211627f957c582e8277b7b7e2a940d4..a459f10b0c1a3e02f160ff3a1a2a0b45ae5b69a7:/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c?ds=sidebyside diff --git a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c index 4e2a0d9db..cb051cdf1 100644 --- a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c +++ b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c @@ -28,6 +28,12 @@ this software. */ +/** \file + * + * Printer Device commands, to send/recieve data to and from an attached USB + * printer, and to send and receive Printer Class control requests. + */ + #include "PrinterCommands.h" /** Sends the given data directly to the printer via the data endpoints, for the sending of print commands in printer @@ -48,7 +54,11 @@ uint8_t Printer_SendData(Printer_Data_t* PrinterCommands) return ErrorCode; Pipe_ClearOUT(); - while (!(Pipe_IsOUTReady())); + while (!(Pipe_IsOUTReady())) + { + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + } Pipe_Freeze(); @@ -76,6 +86,8 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize) wIndex: 0, wLength: sizeof(DeviceIDStringLength), }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful) return ErrorCode; @@ -116,6 +128,8 @@ uint8_t Printer_GetPortStatus(uint8_t* PortStatus) wLength: sizeof(uint8_t), }; + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(PortStatus); } @@ -135,6 +149,8 @@ uint8_t Printer_SoftReset(void) wLength: 0, }; + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(NULL); }