I'm using the Browser Print sample application and have amended it to have one button (button1) that calls the sendThenRead() function with '! U1 getvar "device.languages"' another button (button2) calls sendThenRead() with '! U1 getvar "device.languages"'. Both of these commands return consistently from the Zebra utility.
Line of code :
selected_printer.sendThenRead('! U1 getvar "device.languages"', readComplete, printerError);
When I send either command from the Browser Print sample application it only works about 25% (or less) of the time, the rest of the time the callback function parameter is an empty string.
Sometimes the command will return the result from the previous request. Eg. I click button1 - get empty string response, click button2 - get response that was expected from button1 click.
Printing from the sample application via Browser Print works 100 % of the time.
I'm using an iMZ320 printer connected via USB. I appreciate that this printer is not specified on the list of supported printers on the Browser Print page so I guess the first question is - is this why the command is unreliable?
Am I using the correct function? The end result is to have the page querying the settings and sending settings updates (setvar) if required.
This was simply resolved by adding a carriage return (<CR>) to the end of each command. Thank you Zebra support!