1

I have an Epson CW-C6000 that I'm trying to control with ESC commands. I've gotten text to print, so I know I have the IP address, port, etc correct but cannot for the life of me get an image printed.

Here is my code (running from a Ruby on Rails server, with most of the image truncated):

streamSock = TCPSocket.new( "X.X.X.X", 9100 )
str = "~DYR:PRODIMG,B,P,183208,0,89504E470D...4AE426082" + "^XA" + "^FO150,150^IMR:PRODIMG.PNG^FS" + "^XZ"
streamSock.send( str , 0)
streamSock.close

The image is a .png I converted to hexadecimal with this site: http://tomeko.net/online_tools/file_to_hex.php?lang=en

I'm mostly using page 10 of this PDF for reference: https://files.support.epson.com/pdf/pos/bulk/esclabel_apg_en_forcw-c6000series_reve.pdf

Does anyone have a hint? Epson support staff was spectacularly unhelpful.

Also I'm sorry if my formatting is bad; I'm new here and will happily edit my post if something is wrong.

Farmbot26
  • 31
  • 4
  • I'm using a hexadecimal string for the image data. Shouldn't that be (B)inary? – Farmbot26 Jul 28 '21 at 20:25
  • I've read all the documentation and nothing makes it clear to me what the "data" parameter should be. I used the code from the C# question you linked and got the same hexadecimal as before, so I think that's correct but I don't see how ZB64 plays into it. Do I have to compress the image twice somehow? What is PNG hex ZB64, like you said? – Farmbot26 Jul 29 '21 at 13:51
  • I found this command from Zebra, and it works! But when I switch in my own Base64 string and file size the printer just sits blinking. http://support.zebra.com/cpws/docs/zpl/DY_LOGO_PNG.zpl – Farmbot26 Jul 29 '21 at 15:58

4 Answers4

1

Alright I finally got it working. The command for printing a color .PNG is this:

~DYE:[Image Name].PNG,p,p,[Image Size],0,:B64:[Base64 String]:[CRC]

Things that tripped me up:

-You seem to need the .PNG extension on the file name, even though the Epson manual doesn't show that.

-[Image Size] is the number of characters in the Base64 string, even though the Epson manual says it should be the size of the original .PNG image file. If this is wrong the printer will hang and no longer accept input of any kind until restarted.

-There may be other options, but I could only get it working with a CRC of the hex CRC-16/XMODEM type.

Thanks to K J for his/her suggestions and coming along with me!

Farmbot26
  • 31
  • 4
  • Looking at the explanation, it looks like a bug in the printer firmware after all. It's not working as documented. – kunif Jul 30 '21 at 02:22
0

Perhaps this material can be used as an additional reference.
They seem to have a completely different command/data format than ESC/POS.

ESC/Label Command Reference Guide
Page 12

1.3.4 About Saving the Graphics and Label Formats in the Printer

With ESC/Label command, you can save graphics and label formats in the printer. The printer has a file system. Data saved in the printer is handled as files and is managed in the following way.

  • The file system does not have a hierarchy.
  • The printer has a non-volatile saving device, such as Flash ROM, and a volatile saving device, such as RAM, and different drive letters are allocated for each device.
  • Files are designated as
    "<drive letter> colon <:> <file name> dot <.> <extension>".

Page 40-41

2.8 Printing Graphics
...Details have been omitted. Please refer to the actual document...

2.8.1 Registering a Graphic in a Printer and Printing It
...Pick up some from the content. Please refer to the actual document...

  1. Delete the files that remain in the printer (^ID command).
  2. Register the graphic in the printer (~DY command).

When registering a color graphic, you can use the PNG format. When registering a monochrome graphic, you can register the PNG format or the GRF format.

  • PNG format Monochrome and color graphics
  • GRF format Monochrome graphics

The reason to execute the step 1.
To ensure capacity of the storage memory necessary for print which application will perform.

2.8.2 Embedding a Graphic in the Field and Printing It
...Details have been omitted. Please refer to the actual document...


In Addition:

Page 104-106

~DY
[Name]
Save File
[Format]
~DY d: o ,f ,x ,t ,w ,data
...A table detailing the parameters is due, but omitted...

[Function]
...Further detailed explanations and figures of functions and parameters are due, but omitted...

  • Graphic data is handled as follows.
    • If the data format is binary, you can use any binary data as Parameter data. At this time, the size of Parameter data must be matched to the size specified in Parameter t.
    • If the data format is a hexadecimal character string, one character from 1. to 3. below is used as Parameter data. At this time, the size of Parameter data written in binary must be matched to the size specified in Parameter t.
      1. 0 to 9, A to F, and a to f in ASCII can be used as hexadecimal graphic data.
      2. ASCII comma <,>, the parameter separator character, is used to separate lines. If a comma is input, processing is carried out as if ASCII 0 was input for the remainder of the line.
      3. G to Y and g to z in ASCII can be used as repetition characters. For example, if I9 is input, processing is carried out as if 999 were input. The following table indicates the number of repetitions.
        ...Characters and repeat specified number of times table omitted...

Looking at the contents of this Technical Reference Guide, it seems that you can register images with tools instead of commands.
CW-C6000/C6500 Series Technical Reference Guide
Page 173-174

And page 288 outlines the Epson Inkjet Label Printer SDK and also describes the existence of sample programs.

kunif
  • 4,060
  • 2
  • 10
  • 30
  • I've read through the linked document but my questions are unanswered. It isn't clear from the document why my command isn't working. I suspect that the hexadecimal needs to be in a different format but they don't have an example anywhere in the PDFs – Farmbot26 Jul 28 '21 at 17:21
  • The fact that your command doesn't work is a phenomenon, not a specification, so there shouldn't be a description in the documentation. The details of the command are described later in the PDF, so please refer to it. I added which page to the answer. – kunif Jul 28 '21 at 17:49
  • I read through these documents before posting my question. The details I need are not there. There is almost no information regarding the "data" parameter of the command. – Farmbot26 Jul 28 '21 at 19:09
  • If it's monochrome instead of color, there seems to be such a library. Ruby [bbulpett/zebra-zpl](https://github.com/bbulpett/zebra-zpl), [mtking2/img2zpl](https://github.com/mtking2/img2zpl), C# [BinaryKits/BinaryKits.Zpl](https://github.com/BinaryKits/BinaryKits.Zpl), JavaScript [metafloor/zpl-image](https://github.com/metafloor/zpl-image) Or,there seems to be another SDK like this, so why not contact EPSON? [Epson Inkjet Label Printer SDK](https://download.epson-biz.com/modules/colorworks/index.php?page=single_soft&cid=499&pcat=38&pid=525) – kunif Jul 28 '21 at 23:44
0

@Farmbot26. I have been attempting this same using vb.Net and as you noted Epson support is not helpful. I'm not sure if it's the actual image data that is wrong, CRC, or the ZPL code as nothing helps. Here's 2 examples that have not worked.

`Dim binaryData As Byte() = System.IO.File.ReadAllBytes(txtPNGFile.Text)
        zplImageData = Convert.ToBase64String(binaryData)
        crc = calcrc(binaryData, binaryData.Length).ToString("X4")
        Dim zplToSend As String = "~DYE:" & Path.GetFileName(txtPNGFile.Text).ToUpper & ",P,P," & zplImageData.Length & ",0,:B64:" & zplImageData & ":" & crc & "^XZ"`


`Dim binaryData As Byte() = System.IO.File.ReadAllBytes(txtPNGFile.Text)
        crc = calcrc(binaryData, binaryData.Length).ToString("X4") 'Calculate CRC
        zplImageData = BitConverter.ToString(binaryData).Replace("-", "")
        Dim zplToSend As String = "~DYE:" & Path.GetFileName(txtPNGFile.Text).ToUpper & ",A,P," & zplImageData.Length & ",0,:B64:" & zplImageData & ":" & crc & "^XZ"`

This is the CRC example I have.

`Function calcrc(ByVal data() As Byte, ByVal count As Integer) As Integer
    Dim crc As Integer = 0
    For Each b As Byte In data
        Dim d As Integer = CInt(b)
        crc = crc Xor (d << 8)
        For j = 0 To 7
            If ((crc And &H8000) <> 0) Then
                crc = (crc << 1) Xor &H1021
            Else
                crc = (crc << 1)
            End If
        Next
    Next
    Return crc And &HFFFF
End Function`
1SG Nitro
  • 23
  • 1
  • 5
0

I have figured out another solution. Save the PNG Image using the Binary data. I found this when reading the Saved Backup file of Image data using the Epson Settings Utility.

~DYE:FILENAME.PNG,B,P,BINARYFILESIZE,0, BINARYIMGDATA

` Try
            Dim binaryData As Byte() = System.IO.File.ReadAllBytes(txtPNGFile.Text)
            Dim client As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient()
            client.Connect(IP_TextBox1.Text.Replace(" ", ""), txtPort.Text)
            Dim writer As System.IO.StreamWriter = New System.IO.StreamWriter(client.GetStream(), Encoding.UTF8)
            Using mStream As New MemoryStream(binaryData)
                Dim zplToSend As String = "~DYE:" & Path.GetFileName(txtPNGFile.Text).ToUpper & ",B,P," & mStream.Length & ",0,"
                writer.Write(zplToSend)
                writer.Flush()
                mStream.WriteTo(client.GetStream())
                writer.Flush()
            End Using
            writer.Close()
            client.Close()
            MsgBox("Send Complete", MsgBoxStyle.OkOnly, "Complete")
        Catch ex As Exception
            MsgBox(ex.Message.ToString, MsgBoxStyle.OkOnly, "ERROR")

        End Try`

You can also open the image file in an IMAGE object and resize it as needed. I had to do this for the label size of the printer.

1SG Nitro
  • 23
  • 1
  • 5