Hi,
We are implementing a feature to retrieve Alerts from Zebra Printer Link-OS devices, such as ZT231, via USB.
I found the class PrinterAlert in the PC-Java SDK that has a constructor that you can pass various settings about how the Alert will be sent, for example:
PrinterAlert myPrinterAlert = new PrinterAlert(AlertCondition.PAPER_OUT, AlertDestination.USB, true, false, , , false);
and then later you can pass this alert to be configured on the printer calling "ZebraPrinterLinkOs.configureAlert(myPrinterAlert );"
Until that part we found explained on the documentation.
What we couldn't understand is how to listen for the incoming alerts at the other end via USB.
Do you have any sample code that show us how that is meant to work?
Best regards,
Accepted Solution
We don't have sample code on how to receive alerts. For USB, however, you would have to create a USB connection with the API from the Link-OS SDK, and then monitor the alerts sent from the printer over USB (i.e., reading from the USB connection (i.e., connection.read()) in a loop) to receive alerts.
7 Replies
We don't have sample code on how to receive alerts. For USB, however, you would have to create a USB connection with the API from the Link-OS SDK, and then monitor the alerts sent from the printer over USB (i.e., reading from the USB connection (i.e., connection.read()) in a loop) to receive alerts.
Hi,
I will try using the connection.read() loop.
About configuring the Alert, how do we set up the PrinterAlert constructor to configure for a USB connection?
I tried the way below but it did not work, maybe I am passing incorrect values to the constructor?
PrinterAlert alert = new PrinterAlert(AlertCondition.HEAD_OPEN, AlertDestination.USB, false, false, "", 0, false);
I suspect of parameters 5 and 6.
Parameter 5 asks for a String for destinationAddress and parameter 6 for an Int for Port, but we are not sure if this is right since it is a USB connection.
Best regards,
The parameters for the IP address and the port number will be ignored if the alert destination is USB. If you want to get alerts for the HEAD OPEN on set and on clear, you will need to pass true to the onSet and onClear parameter (as shown below)
Hi Steven,
I am trying to run the code below on a ZD230 like this:
but its giving the following error:
Cannot invoke "com.zebra.sdk.printer.ZebraPrinterLinkOs.configureAlert(com.zebra.sdk.printer.PrinterAlert)" because "linkOsPrinter" is null
Running the same code in a ZT231 works as normal, do you know why is that?
Best regards.
The ZD230 is not a Link-OS printer. It's a Link-OS Basic printer. The following statement is only applicable to Link-OS printers. If it used for a non Link-OS printer or a Link-OS Basic printer, a null pointer will be returned.
Does this mean that Link-OS Basic printers do not have the Alerts system that can be captured? or does this mean that for getting the alerts from that device we can't use the above code and therefore if we want to configure and listen for alerts for this device, we need to use other methods? like connecting the printer via network and accessing the MIB?
Alerts are supported on both Link-OS and Link-OS Basic printers. With Link-OS Basic printers, we have to stick with the ZebraPrinter instance to communicate with the printer, as we cannot use the ZebraPrinterLinkOs instance. Unlike the ZebraPrinterLinkOs, which has convenient alert methods, the alert configuration with the ZebraPrinter instance can be done via the SGD commands.