3 Replies Latest reply on Jan 23, 2018 7:25 AM by Manuel Caicedo-Rivera

    Error after printing a card: SDK: Bad ZMC command echo.

    Diego Meretta

      Greetings.

      I'm developing an aplication based in Java for printing and encoding magnetic cards from a Zebra ZXP Series 3 printer. After printing a card, when i attempt to print the second card the error "SDK: Bad ZMC command echo" appears in the stack trace of a Connection exception when performing a new connection to the printer. Here´s a picture of the stack trace:

       

      Error 1.PNG

       

      Here`s the code of the printing method that i use:

       

      public static void imprimirYMagnetizar(DiscoveredPrinter impresoraEncontrada, String[] tracks,

                  BufferedImage imgFrente, BufferedImage imgDorso) {

       

              ZebraCardPrinter zebrap = null;

              ZebraCardGraphics graphics = null;

              try {

                  zebrap = ZebraCardPrinterFactory.getZxpPrinter(conectoImpresora(impresoraEncontrada));

                  List<GraphicsInfo> graphicsData = new ArrayList<GraphicsInfo>();

                  graphics = new ZebraCardGraphics(zebrap);

       

                  // Front Image

                  graphics.initialize(0, 0, OrientationType.Landscape, PrintType.Color, Color.WHITE);

                  graphics.drawImage(graphics.imageToImageData(imgFrente), 0, 0, 1017, 638, RotationType.Rotate180FlipNone);

       

                  // graphics configuration of the front image

                  GraphicsInfo grInfo = new GraphicsInfo();

                  grInfo.graphicData = graphics.createImage();

                  grInfo.side = CardSide.Front;

                  grInfo.printType = PrintType.Color;

                  grInfo.graphicType = GraphicType.BMP;

                  graphicsData.add(grInfo);

                  graphics.clear();

       

                  // Front overlay

                  grInfo = new GraphicsInfo();

                  grInfo.graphicData = null;

                  grInfo.side = CardSide.Front;

                  grInfo.printType = PrintType.Overlay;

                  grInfo.graphicType = GraphicType.NA;

                  graphicsData.add(grInfo);

       

                  // Back image

       

                  graphics.initialize(0, 0, OrientationType.Landscape, PrintType.Color, Color.WHITE);

                  graphics.drawImage(graphics.imageToImageData(imgDorso), 0, 0, 1017, 638, RotationType.Rotate180FlipNone);

       

                  // Graphics configuration of the back image

       

                  grInfo = new GraphicsInfo();

                  grInfo.graphicData = graphics.createImage();

                  grInfo.side = CardSide.Back;

                  grInfo.printType = PrintType.Color;

                  grInfo.graphicType = GraphicType.BMP;

                  graphicsData.add(grInfo);

                  graphics.clear();

       

                  // Back overlay

       

                  grInfo = new GraphicsInfo();

                  grInfo.graphicData = null;

                  grInfo.side = CardSide.Back;

                  grInfo.printType = PrintType.Overlay;

                  grInfo.graphicType = GraphicType.NA;

                  graphicsData.add(grInfo);

       

                  // Performing the printing job

       

                  int jobId = zebrap.printAndMagEncode(1, graphicsData, tracks[0], tracks[1], "");

       

                  // Method for controlling the printing job (i wait until the job status is "done_ok")

                  controlarTrabajo(zebrap, jobId);

       

                  graphics.close();

                  zebrap.destroy();

                  zebrap.getConnection().close();

       

                  if (zebrap.getConnection().isConnected()) {

                      System.out.println("Sigue abierta la conexion");

                  } else {

                      System.out.println("Se cerro");

                  }

       

              } catch (ConnectionException e) {

                  System.out.println("Error en la conexión.");

                  e.printStackTrace();

              } catch (ZebraCardException e) {

                  System.out.println("Ocurrio un error en la impresora.");

                  e.printStackTrace();

              } catch (SettingsException e) {

                  e.printStackTrace();

              } catch (IllegalArgumentException e) {

                  e.printStackTrace();

              } catch (IOException e) {

                  e.printStackTrace();

              } catch (ZebraIllegalArgumentException e) {

                  e.printStackTrace();

              }

       

          }

       

      What I do first is discover the printer outside this method, and then passing the instance of the Discovered Printer by reference. Then in the printing method that i made, I attempt to open a Connection to the printer and then create a Zebra Card Printer with that connection. Then I instance the Zebra Card Graphics class with the instance of the zebra printer. After the printing job is done, I perform a clean up closing the graphics, destroying the printer and then closing the connection. But I don't know why I'm not able to connect the printer again because of said error. Please if you have some information of what is that error message I would appriciate knowing why it happens. If you need more detail I would happily give it to you. I wait for your response. Best Regards