GeekyOmega
GeekyOmega

Reputation: 1329

How to encode RFID label for Zebra Printer using C# and .NET?

Problem

I am using Visual Studio, C#, and .NET. I am also using ZPL commands to print hello world to a Zebra ZD500R. I have been currently unsuccessful in figuring out how to encode an RFID label using the above. I know a SDK for java exists, but my environment is a strict Microsoft stack.

The RFID label that is printed has VOID printed on the entire label. Something like VOIDVOIDVOIDVOIDVOIDVOID. I have included the updated code below.

Code

Here is the following code I have currently written after studying Zebra documentation and sample code:

  public static void PrintLabels()
        {
            try
            {

                string ipAddress = "127.0.0.1";
                int port = 1337;

                // ZPL Command(s)
                string ZPLString =
                "CT~~CD,~CC^~CT~" +
                "^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR4,4~SD10^JUS^LRN^CI0^XZ" +
                "^XA" +
                "^MMT" +
                "^PW300" +
                "^LL0526" +
                "^LS0" +
                "^FT267,433^A0I,42,40^FH\\^FDHello World^FS" +
                "^RS8" +
                "^RFW,H^FD1234^FS" +
                "^PQ1,0,1,Y^XZ";  






                // Open connection
                System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
                client.Connect(ipAddress, port);

                // Write ZPL String to connection
                System.IO.StreamWriter writer =
                new System.IO.StreamWriter(client.GetStream());
                writer.Write(ZPLString);
                writer.Flush();

                // Close Connection
                writer.Close();
                client.Close();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

This is a rudimentary example, but does the trick by printing hello world. As far as I know, I was thinking the RFID encoding aspect should be a new line in the string ZPLString. Unfortunately, when I looked into the Zebra programming book I did not see any ZPL commands to confirm this thought.

Attempts

I have done the following in an attempt to solve this problem.

Any advice, tips, or comments would be deeply appreciated.

Upvotes: 2

Views: 6812

Answers (1)

Lynn Crumbling
Lynn Crumbling

Reputation: 13357

Some notes -

Check out page 381 (table 18) for a list of commands compatible with that printer.

Pages 400 and 401 contain some writing examples. The first one is:

^XA
^RS8
^RFW,A^FD00 my data^FS
^XZ

Let's dissect this. ^XA (start) and ^XZ (end). Plus two others: ^RS and ^RF.

^RS – Set Up RFID Parameters

UHF Printers
0 = None
1 = EPC Class 0
2 = EPC Class 0 Plus
3 = EPC Class 1 64-bit
4 = EPC Class 1 96-bit
5 = UCODE EPC 1.19
6 = Impinj Class 0 Plus
7 = ISO 18000-06A
8 = EPC Class 1, Generation 2 (Gen 2)
9 = ISO 18000-06B

Not sure which transponder you're using. Adjust accordingly.

Then there's ^RF: Read or Write RFID Format. In this example, they're doing a write operation in ASCII (^RFW,A)

Next, we see

^FD00 my data^FS

Which is the begin and end marker for data.


Another example, this time writing hex:

^XA
^RFW,H^FD1234^FS
^XZ

You see the ,H used, instead of ,A. Again, we see ^FD and ^FS delimiting data.


In Summary...

I'm guessing that you want something like this (let's assume you're writing hex):

^XA
^FO10,10
^A0,100,150
^FDHello, World!^FS
^RS8
^RFW,H^FD1234^FS
^XZ

So, in c#:

string ZPLString = "^XA^FO10,10^A0,100,150^FDHello, World!^FS^RS8^RFW,H^FD1234^FS^XZ";

You MAY need to throw in a ^RS and go off of the above chart. When sending the command string, you don't need to add in any extra line feeds or CR's.

std_disclaimer: I have only used ZPL to print, not for RFID encoding. Make sure that you have the correct transponders for this unit. According to docs, it supports tags compatible with UHF EPC Gen 2 V1.2/ ISO 18000-6C.

I would test out your ZPL using Zebra's utilities first. If it works, then start playing in c#. Just trying to limit the number of variables at play ;)

Upvotes: 2

Related Questions