Printing directly to Ethernet printer using 'raster mode': need basic guidance

前端 未结 2 799
孤城傲影
孤城傲影 2021-02-01 10:23

I\'ve stumbled across a problem way beyond my area of expertise, and I don\'t have a mentor to turn to for help with this.

I have a receipt printer I need to in

2条回答
  •  有刺的猬
    2021-02-01 10:45

    I have a hunch this might be the same as the old Seiko printers, only yours is network enabled. If so, have a look at the C code here. It tries to output to a serial port /dev/cua, where it thinks the printer is.

    But if the commands are the same, the code should help you. It takes as input the Portable Bitmap Format, which is plain ASCII text.

    But I don't know. Microsoft indicates Star Micronics works the same as Epson LQ, in which case there is ample documentation.

    Related links:

    • ESC/POS PDF Documentation, hundreds of pages

    • Command codes from the STAR website


    Update! ;-) Try this, totally untested code:

    /* Call with grayscale images of height 256, width 256. */
    
    - (void) outputraster(char* pixels, int rows)
    {
        const char initializeRaster[] =    "\x1B\x2A\x72\x52";
        const char enterRaster[] =         "\x1B\x2A\x72\x41";
        const char formFeed[] =            "\x1B\x0C\x00";
        const char clearRaster[] =         "\x1B\x2A\x72\x43";
        const char exitRaster[] =          "\x1B\x2A\x72\x42";
    
    /* The FF means 255 lines: */
        char setRasterPageLength[]         "\x1B\x2A\x72\x50\xFF\x0";
    
    
    /* The FF FF means 256 lines and 256 rows: */
        char sendRasterData[] =            "\x62\xFF\xFF";
    
        [self sendBytes:initializeRaster ofLength:sizeof(initializeRaster)];
        [self sendBytes:enterRaster ofLength:sizeof(enterRaster)];
        [self sendBytes:clearRaster ofLength:sizeof(clearRaster)];
        [self sendBytes:setRasterPageLength ofLength:sizeof(setRasterPageLength)];
        [self sendBytes:sendRasterData ofLength:sizeof(sendRasterData)];
    
        while (rows)
        {
            for (int x = 0; x < 255; x++)
            {
                [self sendBytes:pixels[x] ofLength:256];
            }
    
            rows --;
        }
    }
    

    Update!


    I was looking at the docs at night, and stumbled upon how you can print out a prestored logo. Then I looked at how to define that logo, and that part of the documentation looked a lot more thorough: alt text alt text alt text

    Explanations of bitmap format for a similar printer: alt text

    Also, look at pages 34 and on for an explanation of the bitmap format of a Star printer.

提交回复
热议问题