I need to set a couple of vars on the Zebra QLn220 belt printer to get it work as we need it to with our app. The first command below (keepPrinterOn) now works:
const string quote = "\"";
string keepPrinterOn = string.Format("! U1 setvar {0}power.dtr_power_off{0} {0}off{0}\r\n", quote);
string advanceToBlackBar = string.Format("! U1 setvar {0}media.sense_mode{0} {0}bar{0}\r\n", quote);
string advanceToGap = string.Format("! U1 setvar {0}media.sense_mode{0} {0}gap{0}\r\n", quote);
PrintUtils.SendCommandToPrinter(keepPrinterOn);
if (radbtnBar.Checked)
{
//MessageBox.Show("setting label type to bar");
AppSettings.WriteSettingsVal("labelType", "bar");
PrintUtils.SendCommandToPrinter(advanceToBlackBar);
}
else if (radbtnGap.Checked)
{
//MessageBox.Show("setting label type to gap"); <= This is reached, although printer is not being changed to gap mode at any rate
AppSettings.WriteSettingsVal("labelType", "gap");
PrintUtils.SendCommandToPrinter(advanceToGap);
}
Attempting to change the "media.sense_mode" var from bar to gap, though, is failing. Even when radbtnGap is checked, and that (last shown) conditional block of code is entered, the value of the "media.sense_mode" var is not switching from "bar" to "gap" (as seen both empirically, in attempting to print gap (plain) labels, which doesn't work (spews out gazillions of labels after printing one) and by running this command:
! U1 getvar "media.sense_mode"
...in the Zebra Setup Utilities (it returns "bar" even after selecting "gap").
I was previously having problems with these commands because I had neglected to append the crlfs (\r\n) to the commands, as was discussed here [Why would a Zebra QLn220 Printer ignore the first couple of commands sent to it after sending it a command to update some settings?, but now the labels are printed right away after sending the commands above (provided "bar" is selected, and bar (black strip on the back) labels are loaded in the belt printer.
Can anybody make heads or tails (bars or gaps) out of what could be amiss here?
UPDATE
I'm wondering if a low battery can cause commands sent to the printer to not "take." I got a "battery failed" message on the QLn220 (re-charging now). Once I'm able to do so, I'll test it to see if my existing code works (with a charged-up battery). If not, I'll try banno's alternate command in his answer below.
UPDATE 2
So I now have this code (the second two) ready to try, if necessary (the printer is currently dead, and can't even test it):
string advanceToBlackBar = string.Format("! U1 setvar {0}media.sense_mode{0} {0}bar{0}\r\n", quote);
string advanceToGap = string.Format("! U1 setvar {0}media.sense_mode{0} {0}gap{0}\r\n", quote);
// Alternates added 7/29/2014 in case need to attempt them (see https://stackoverflow.com/questions/24966070/why-would-the-zebra-qln220s-media-sense-mode-var-not-be-set-to-gap-with-this-co)
string advanceToBlackBarAlternate = string.Format("! U1 setvar {0}ezpl.media_type{0} {0}mark{0}\r\n", quote);
string advanceToGapAlternate = string.Format("! U1 setvar {0}ezpl.media_type{0} {0}web{0}\r\n\r\n", quote);
Is the second pair preferable to the first, or are they simply synonymous / something to try when the other doesn't work?