How to use the "compressed binary" `C` arg for the compression type parameter of `^GF` in ZPL?

210 Views Asked by At

I'm trying to use this parameter with value C:

ZPL ^GF -- Graphic Field

Here's a link to the manual page to read more:

https://support.zebra.com/cpws/docs/zpl/zpl_manual.pdf#page=210&zoom=auto,-20,721

Here's an xxd hexdump of my attempt (you can get the original by passing it through xxd -r):

00000000: 5e58 410a 5e4d 4d54 0a5e 5057 3633 390a  ^XA.^MMT.^PW639.
00000010: 5e4c 4c30 3332 300a 5e4c 5330 0a5e 464f  ^LL0320.^LS0.^FO
00000020: 3130 2c31 305e 4746 432c 3032 3533 2c30  10,10^GFC,0253,0
00000030: 3137 3932 2c30 3030 3238 2c78 9ced d231  1792,00028,x...1
00000040: 4e03 3110 05d0 b15c b8f3 5ec0 5aae 3105  N.1....\..^.Z.1.
00000050: 62af e474 1451 0217 c879 b61c c401 3802  b..t.Q...y....8.
00000060: b317 40a6 7381 d68c 8728 0e89 2284 9402  [email protected]....(.."...
00000070: a41d 17bb d22b bcf3 ff02 2cf3 1f86 e500  .....+....,.....
00000080: 4679 8b26 1992 2782 ff95 a149 f6e1 92d9  Fy.&..'....I....
00000090: f1ea 16ec e8e0 d43a c2d8 1104 171c 6ccc  .......:......l.
000000a0: 0bba 5db3 2161 1c92 9a29 8faf 78f3 d66c  ..].!a...)..x..l
000000b0: 9b31 6eb3 9a2d 4f33 0ef3 de4a e17c 8b31  .1n..-O3...J.|.1
000000c0: afc1 cbb8 e729 e1fd a619 078c 1cbe 0c26  .....).........&
000000d0: c6d8 1f6c 228f 2bee d53a 7827 4cfd e13e  ...l".+..:x'L..>
000000e0: 35f2 6a1e 5684 dc76 98ca ac26 9f12 ae66  5.j.V..v...&...f
000000f0: 043f 9a44 3d9e 1983 ee50 ed74 0766 afbb  .?.D=....P.t.f..
00000100: 5793 dda9 ed2e b6cf cc66 9325 33c2 f5dd  W........f.%3...
00000110: 51d6 1f9a b5fc 4a49 b2a6 9675 ed28 6b47  Q.....JI...u.(kG
00000120: d5a4 23fa d651 c7da 6d35 e996 5ab7 cb2c  ..#..Q..m5..Z..,
00000130: f357 e713 afc0 b774 0a5e 4653 5e50 5131  .W.....t.^FS^PQ1
00000140: 2c30 2c31 2c59 5e58 5a0a                 ,0,1,Y^XZ.

The image is a simple rendering of "Hello World". The format for the image is simple compression via DEFLATE, basically Zebra's Z64 without the Base64 encoding and the CRC. You can see the image in a terminal by doing this (with the above file saved as label.zpl.xxd):

xxd -r < label.zpl.xxd \
| sed -E 's/.*\^GF([^,]+,){4}//p;d' \
| head -c-1 \
| ruby -r zlib -e '$>.write Zlib::Inflate.inflate $<.read' \
| xxd -b -c28 \
| awk '{OFS=""; $1 = $NF = ""} 1'

The Zebra S4M printer I'm testing on simply doesn't react when I send that ZPL code. If I switch to using ASCII compression type with Z64, changing the compression type argument from C to A, etc:

b64="$(xxd -r < label.zpl.xxd | sed -E 's/.*\^GF([^,]+,){4}//p;d' | head -c-1 | base64)"
crc="$(reveng -m crc-16/xmodem -c "$(tr -d '\n' <<< "$b64" | xxd -p -u | tr -d '\n')")"
xxd -r < label.zpl.xxd | LC_ALL=C awk -v b64="$b64" -v crc="$crc" '
  {
    if (/\^GF/) {
      $0 = gensub(/(\^GF)([^,]+,){2}([^,]+,)([^,]+,).*/, "\\1A,\\3\\3\\4", "g")
      print
      print ":Z64:"
      print b64
      print ":" crc
    } else {
      print
    }
  }
'

resulting in:

^XA
^MMT
^PW639
^LL0320
^LS0
^FO10,10^GFA,01792,01792,00028,
:Z64:
eJzt0jFOAzEQBdCxXLjzXsBarjEFYq/kdBRRAhfIebYcxAE4ArMXQKZzgdaMhygOiSKElAKkHRe7
0iu88/8CLPMfhuUARnmLJhmSJ4L/laFJ9uGS2fHqFuzo4NQ6wtgRBBccbMwLul2zIWEckpopj694
89ZsmzFus5otTzMO895K4XyLMa/By7jnKeH9phkHjBy+DCbG2B9sIo8r7tU6eCdM/eE+NfJqHlaE
3HaYyqwmnxKuZgQ/mkQ9nhmD7lDtdAdmr7tXk92p7S62z8xmkyUzwvXdUdYfmrX8SkmyppZ17Shr
R9WkI/rWUcfabTXpllq3yyzzV+cTr8C3dA==
:ed50
^FS^PQ1,0,1,Y^XZ

That prints perfectly. So, does anyone have any idea on what I'm doing wrong to get the C argument working?

EDIT: Wondered if the printer was too old to support C. Version seems fine. It should have it. This link shows various versions of the ZPL manual and the firmware versions that support their features:

https://support.zebra.com/cpws/docs/zpl/zpl_manuals.htm

This document is the release notes for the firmware of the S4M:

https://www.zebra.com/content/dam/zebra_new_ia/en-us/software-printer/firmware/en/release-notes/v58-17-12z-releasenotes.pdf

The firmware I'm using is V58.17.12Z released 2012. Even the second oldest manual from 1998 shows ^GF with the C argument available. So, apparently that's not it.

0

There are 0 best solutions below