2

Trying to print to Brother RJ-4230B printer using CPCL Line Mode via the Brother Print SDK.

Printer gets stuck on "Receiving" when I send these bytes using driver.sendRawData(bytes):

! 0 200 200 2596 1
PW 575
TONE 0
SPEED 3
ON-FEED IGNORE
NO-PACE
BAR-SENSE
PCX 190 12 
����
FORM
PRINT

���� represents the 4 bytes of the test PCX image. There are other images I need to send in a similar fashion.

This approach seems to align with the manual and with the examples I have found online, but it isn't working. Here is the manual page for the PCX command:

CPCL manual page for PCX command

The command string is:

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 \r\n{pcx image data bytes}\r\nFORM\r\nPRINT\r\n before it is converted to bytes.

I have also tried without FORM:

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 \r\n{pcx image data bytes}\r\nPRINT\r\n"

and without \r\n on the PCX command line:

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 {pcx image data bytes}\r\nPRINT\r\n"

Also, various combinations using STARTPCX.LBL and/or ENDPCX.LBL:

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 \r\n{pcx image data bytes}\r\nENDPCX.LBL\r\nPRINT\r\n

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 \r\n{pcx image data bytes}ENDPCX.LBL\r\nPRINT\r\n

STARTPCX.LBL\r\n! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 \r\n!{pcx image data bytes}\r\nENDPCX.LBL\r\nPRINT\r\n

STARTPCX.LBL\r\n! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 \r\n{pcx image data bytes}ENDPCX.LBL\r\nPRINT\r\n

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nSTARTPCX.LBL\r\nPCX 190 12 \r\n{pcx image data bytes}ENDPCX.LBL\r\nPRINT\r\n

How can I get the printer to recognize the end of the inline data send?

Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50

2 Answers2

0

See COMMAND LINE CONVERSION OF PCX FILES FOR ZPL PRINTERS.
A PCX upload in ZPL would eg. be ~DYR:ARROW,B,X,268,, (to have something to test).
Also the Camero Printer Command Language (CPCL) reference seems relevant. Make sure that bytes is indeed monochrome. In the example, the size 268 basically tells it when the upload is complete, in advance - alike a HTTP server may report the content-lenght before a download.

When the passed content-lenght is larger than it actually is, it may keep waiting for more at EOF.

Alternatively, for direct printing of PCX file (while supported), the command would eg. be:

! 0 200 200 500 1
PCX 0 30

Probably confused Brother with Zebra, but CPCL (see the reference manual) is all the same.
Line ending \r\n is DOS; the alternative would be \n (not sure which one applies for CPCL).
Disclaimer: I only know the QL series, not the RJ series - and have no test hardware.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I am trying to do direct printing as shown in my post. I am sending the bytes of the bitmap file, which may be the problem. Any suggestions on how to convert the bitmap into a PCX file? – Chuck Krutsinger Mar 01 '22 at 01:02
  • See what a [PCX](https://moddingwiki.shikadi.net/wiki/PCX_Format) even is ...seemingly, inside the PCX part, the `\r\n` appears plausible.... the "bits per pixel per plane field at offset 3" must be `1` and "number of planes field at offset 65" must be `1` ...this means "monochrome"; file header is `0x0a`... "image data comes after the header (starting at offset `0x80`)". – Martin Zeitler Mar 01 '22 at 01:31
  • I have bitmap files captured in my app that I need to send to the Brother printer using CPCL. The Zebra SDK can accept bitmaps and can store images on the printer in flash memory. However, the Brother printer SDK does not save images to the printer and does not support the CISDF* commands for uploading images to the printer. So I'm stuck with direct printing. How can I get bitmap bytes into the format CPCL is expecting? – Chuck Krutsinger Mar 01 '22 at 01:38
  • The required PCX `byte[]` looks about like this - and as stated, only monochrome PCX may be supported (when writing the file header, one probably doesn't have to check for the header, but use compatible values): https://stackoverflow.com/questions/21035662/how-to-convert-bmp-file-to-pcx-file – Martin Zeitler Mar 01 '22 at 02:19
  • I need a definitive answer as to how to convert bitmap to PCX so that I can send the PCX bytes to the printer in a direct print command such as `PCX {x} {y} {data}`. – Chuck Krutsinger Mar 01 '22 at 21:27
0

The issue turned out to be that I was sending the bytes of a bitmap when what was needed was to convert the bitmap to a PCX file and send those bytes instead. Also, make sure that you do not put \r\n between the PCX command and the byte stream.

! 0 200 200 2596 1\r\nPW 575\r\nTONE 0\r\nSPEED 3\r\nON-FEED IGNORE\r\nNO-PACE\r\nBAR-SENSE\r\nPCX 190 12 {pcx image data bytes}\r\nPRINT\r\n"
Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50