Fix unfinished printer host demo - some printer languages use embedded NULLs and...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 20 Jul 2009 02:59:16 +0000 (02:59 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 20 Jul 2009 02:59:16 +0000 (02:59 +0000)
Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.c
Demos/Host/Incomplete/PrinterHost/Lib/PrinterCommands.h
Demos/Host/Incomplete/PrinterHost/PrinterHost.c
Demos/Host/LowLevel/StillImageHost/StillImageHost.c

index 668421d..03d3070 100644 (file)
  *\r
  *  \return A value from the Pipe_Stream_RW_ErrorCodes_t enum\r
  */\r
  *\r
  *  \return A value from the Pipe_Stream_RW_ErrorCodes_t enum\r
  */\r
-uint8_t Printer_SendData(char* PrinterCommands)\r
+uint8_t Printer_SendData(char* PrinterCommands, uint16_t DataLength)\r
 {\r
        uint8_t ErrorCode;\r
 \r
        Pipe_SelectPipe(PRINTER_DATA_OUT_PIPE);\r
        Pipe_Unfreeze();\r
        \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, strlen(PrinterCommands))) != PIPE_RWSTREAM_NoError)\r
+       if ((ErrorCode = Pipe_Write_Stream_LE(PrinterCommands, DataLength)) != PIPE_RWSTREAM_NoError)\r
          return ErrorCode;\r
 \r
        Pipe_ClearOUT();\r
          return ErrorCode;\r
 \r
        Pipe_ClearOUT();\r
index 01f1f14..b296d86 100644 (file)
@@ -54,7 +54,7 @@
                #define PRINTER_DATA_OUT_PIPE        2\r
                \r
        /* Function Prototypes: */\r
                #define PRINTER_DATA_OUT_PIPE        2\r
                \r
        /* Function Prototypes: */\r
-               uint8_t Printer_SendData(char* PrinterCommands);\r
+               uint8_t Printer_SendData(char* PrinterCommands, uint16_t DataLength);\r
                uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize);\r
                uint8_t Printer_GetPortStatus(uint8_t* PortStatus);\r
                uint8_t Printer_SoftReset(void);\r
                uint8_t Printer_GetDeviceID(char* DeviceIDString, uint8_t BufferSize);\r
                uint8_t Printer_GetPortStatus(uint8_t* PortStatus);\r
                uint8_t Printer_SoftReset(void);\r
index 2200465..bff5e20 100644 (file)
@@ -207,9 +207,9 @@ void USB_Printer_Host(void)
                        char PCL_Test_Page[]   = "\033%-12345X\033E LUFA PCL Test Page \033E\033%-12345X";\r
 //                     char ESCP2_Test_Page[] =  "\033@\033i\001\033X\001\060\000\r\nLUFA ESCP/2 Test Page\r\n";\r
 \r
                        char PCL_Test_Page[]   = "\033%-12345X\033E LUFA PCL Test Page \033E\033%-12345X";\r
 //                     char ESCP2_Test_Page[] =  "\033@\033i\001\033X\001\060\000\r\nLUFA ESCP/2 Test Page\r\n";\r
 \r
-                       printf_P(PSTR("Sending Test Page (%d bytes)...\r\n"), strlen(PCL_Test_Page));\r
+                       printf_P(PSTR("Sending Test Page (%d bytes)...\r\n"), (sizeof(PCL_Test_Page) - 1));\r
 \r
 \r
-                       if ((ErrorCode = Printer_SendData(PCL_Test_Page)) != PIPE_RWSTREAM_NoError)\r
+                       if ((ErrorCode = Printer_SendData(PCL_Test_Page, (sizeof(PCL_Test_Page) - 1))) != PIPE_RWSTREAM_NoError)\r
                        {\r
                                puts_P(PSTR(ESC_FG_RED "Error Sending Test Page.\r\n"));\r
                                printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
                        {\r
                                puts_P(PSTR(ESC_FG_RED "Error Sending Test Page.\r\n"));\r
                                printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);\r
index dfc7cb7..5cfaf46 100644 (file)
@@ -352,7 +352,7 @@ void UnicodeToASCII(uint8_t* UnicodeString, char* Buffer)
        /* Loop through the entire unicode string */\r
        while (CharactersRemaining--)\r
        {\r
        /* Loop through the entire unicode string */\r
        while (CharactersRemaining--)\r
        {\r
-               /* Load in the next unicode character (only the lower byte, only Unicode coded ASCII supported) */\r
+               /* Load in the next unicode character (only the lower byte, as only Unicode coded ASCII is supported) */\r
                *(Buffer++) = *UnicodeString;\r
                \r
                /* Jump to the next unicode character */\r
                *(Buffer++) = *UnicodeString;\r
                \r
                /* Jump to the next unicode character */\r