简体   繁体   中英

Using Silverlight to send ZPL commands to a Zebra printer works only for limited numbers of labels

I developed an in-browser Silverlight application that consist in a button. When it pressed it open a Socket to send ZPL commands to a Zebra Printer (model RZ400).

I made all the required actions to allow in-browser app to open connection to other hosts.

The printer works well except that it print only a limited number of labels (27) even if the socket send right all the data to the printer (that consist in 48 labels, about 440 bytes each).

To be sure, I check the buffer size of the socket that is 65536 bytes. The amount of data that I send to the printer through the socket is only 21282 bytes.

foreach (Label l in args.Labels)
{
    saea = new SocketAsyncEventArgs();
    printCommand = GetPrintCommandFromLabelAndPRN(l, args.SelectedPrinter.prn);

    buffer = Encoding.UTF8.GetBytes(printCommand);
    saea.SetBuffer(buffer, 0, buffer.Length);

    willRaiseEvent = args.ConnectionSocket.SendAsync(saea);
    totBytes += buffer.Length;

    Log("Pack " + l.data + " inviato al socket di stampa");
}

The method GetPrintCommandFromLabelAndPRN build the PRN command for a single label:

private string GetPrintCommandFromLabelAndPRN(Label l, string prn)
{
    // Codice e RFID
    string aux = prn.Replace("{code}", l.code).Replace("{epc}", l.data);

    // Meta
    foreach (labelMeta meta in l.meta)
    {
        if (meta.key != null && !meta.key.Equals(String.Empty))
        {
            aux = aux.Replace("{" + meta.key + "}", meta.value);
        }
    }

    return aux;
}

And this is the PRN template:

^XA
~SD25
^FO10,70^XGE:LOGO.GRF,1,1^FS
^FT275,65^A0N,29,28^FH\^FDArticolo:^FS
^FT375,65^A0N,29,28^FH\^FD{code}^FS
^FT509,65^A0N,25,24^FH\^FD{description1}^FS
^FT275,99^A0N,25,24^FH\^FD{description2}^FS
^BY2,3,57^FT275,166^BCN,50,Y,N,N^FD>:{code}^FS
^FT50,225^A0N,29,28^FH\^FDLotto:^FS
^BY2,3,35^FT130,225^BCN,30,Y,N,N^FD>:{lotCode}^FS
^PQ1,0,1,Y
^RR2
^RS8,300,50,2,N
^RW20,20
^RFW,H
^FD{epc}^FS
~RVE
^XZ

I try to do the same in Java, with the same PRN, using PrintWriter and it works correctly. So I exclude that is a printer issue.

I would bet that the printer is queuing up your labels and that is what causes it to stop at 27. Have you tried sending one at a time just to test to see if you might need to let the printer 'catch up' with the print jobs you are sending? We used to have an issue similar to this - when we slowed down the loop to the printer it allowed the printer to work at it's own rate just fine, but labels came out at a slower rate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM