我需要设置什么Zebra QLn220设置(以及设置为什么值)才能设置为"stick"? [英] What Zebra QLn220 settings do I need to set (and to what value[s]) to get a setting to "stick"?

查看:135
本文介绍了我需要设置什么Zebra QLn220设置(以及设置为什么值)才能设置为"stick"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以编程方式配置Zebra QLn220打印机,以将其"media.sense_mode"设置为"bar"或"gap"(取决于用户选择的内容).

但是,这些命令正常工作的可靠性似乎很低(有时有效,有时无效).

为测试各种可能的命令,我当然使用了Zebra设置实用程序,并且PC已插入打印机.

我从util发送了此命令:

! U1 setvar "media.sense_mode" "gap"

它奏效了;我知道这一点,因为使用以下命令对其进行了测试:

! U1 getvar "media.sense_mode"

...向我展示了对间隙"的期望/希望(在发送上述命令之前,它是"bar").

但是尝试在代码中完成相同的操作对于"bar"(几乎总是)有效,但对于"gap"却几乎没有作用

代码如下:

const string 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);
. . .
if (radbtnBar.Checked)
{
    PrintUtils.SendCommandToPrinter(advanceToBlackBar);
}
else if (radbtnGap.Checked)
{
    PrintUtils.SendCommandToPrinter(advanceToGap);
}

如您所见,除了"bar"和"gap"之外,代码完全相同

附加的"\ r \ n"是否有可能引起问题?似乎添加了这些命令是必要的,或者使命令更可靠,但是在这一点上,我很乐意接受任何事情.

我一直在测试替代命令来完成同一件事,以查看它们是否更可靠,但其他两种替代方法均无效,即该替代方法不可行:

! U1 setvar "ezpl.media_type" "web"

-也不是这个

{} {"media.sense_mode" "gap"}

...在将这些命令发送到打印机之后,通过getvar检查val继续显示"bar"(设置回"bar"后,发送这两个命令后,"media.sense_mode"的值仍为"bar")命令).

是否可能需要设置某些其他打印机设置,以使打印机对发送的命令更加敏感?不仅通过编程方式设置命令不可靠,而且即使通过Zebra设置实用程序,有时也会在发送和返回命令之前沙漏"很长时间,有时比​​Johnny Quick和Flash组合起来要快. >

浏览此命令的大量输出:

! U1 getvar "allcv"

....以下是最有趣/最有可能的候选人.哪些需要更改,哪些需要更改?

wlan.ip.dhcp.request_timeout : 2 , Choices: 2-30
wlan.ip.dhcp.session_interval : 10 , Choices: 0-60
. . .
wlan.ip.timeout.enable : on , Choices: on,off
wlan.ip.timeout.value : 300 , Choices: 1-3600
. . .
wlan.keep_alive.enable : on , Choices: on,off
wlan.keep_alive.timeout : 15 , Choices: 5-300
. . .
netmanage.avalanche.interval : 60000 , Choices: 0-4294967295
netmanage.avalanche.startup_update : off , Choices: on,off
netmanage.avalanche.interval_update : off , Choices: on,off
. . .
netmanage.avalanche.udp_timeout : 3000 , Choices: 0-4294967295
netmanage.avalanche.tcp_connection_timeout : 3000 , Choices: 0-4294967295
. . .
netmanage.avalanche.realtime_update_int : 300 , Choices: 0-4294967295
. . .
zpl.zpl_mode : zpl II , Choices: zpl II,zpl
. . .
internal_wired.ip.arp_interval : 0 , Choices: 0-30
. . .
internal_wired.ip.dhcp.requests_per_session : 2 , Choices: 1-10
internal_wired.ip.dhcp.request_timeout : 2 , Choices: 2-30
internal_wired.ip.dhcp.session_interval : 10 , Choices: 0-60
. . .
internal_wired.ip.timeout.enable : on , Choices: on,off
internal_wired.ip.timeout.value : 300 , Choices: 1-3600
. . .
internal_wired.ip.wins.permanent_source : off , Choices: on,off
. . .
interface.network.active.arp_interval : 0 
. . .
interface.network.active.speed : 0 
. . .
weblink.printer_reset_required : no 
. . .
weblink.ip.conn1.retry_interval : 10 , Choices: 1-600
. . .
weblink.ip.conn1.maximum_simultaneous_connections : 10 , Choices: 1-100
. . .
weblink.ip.conn1.test.retry_interval : 900 , Choices: 1-1800
weblink.ip.conn1.num_connections : 0 
. . .
capture.channel1.port : off , Choices: serial,usb,bt,parallel,off
capture.channel1.count : 0 , Choices: 0-4294967295

外面有人有线索吗?

更新

以下是发送命令的代码:

public static bool SendCommandToPrinter(string cmd)
{
    bool success; // init'd to false by default
    try
    {
        using (SerialPort serialPort = new SerialPort())
        {
            serialPort.BaudRate = 19200;
            serialPort.Handshake = Handshake.XOnXOff;
            serialPort.Open();
            serialPort.Write(cmd);
            serialPort.Close(); // <= should be redundant within a using statement, but still getting "File 55" err...
        }
        success = true;
    }
    catch // may not need a try/catch block, as success defaults to false
    {
        success = false;
    }
    MessageBox.Show(success.ToString()); //TODO: Remove after testing
    return success;
}

有问题的串行端口来自OpenNETCF.IO.Ports.SerialPort

注意::SerialPort.Write()返回void.

命令:

! U1 getvar "appl.name" 

在Zebra设置实用程序中返回" V68.19.7Z ".

这是否意味着我的固件是最新的(V68.19.7Z> v68.18.0Z),或者这意味着由于我的"appl"是较新的,我需要将固件升级到 V68.19.7Z?如果我需要执行固件更新,该怎么做?是查找并下载最新固件到我的PC,然后在通过USB连接PC和打印​​机时运行其安装应用程序,还是... ???

更新2

此处,在搜索QLn220时,我看到V68.18.0Z是唯一可供下载的固件版本.因此,由于我的打印机上似乎有较新的版本,所以我很困惑……为什么他们不提供看上去是较新的版本(V68.19.7Z)?

更新3

如果我点击上面引用的页面上的"自解压档案"链接,我将得到

更新4

在添加一些调试字符串后,它可以工作;在打印代码中:

MessageBox.Show(success.ToString()); //TODO: Remove after testing
return success;

...以及设置代码中的

if (radbtnBar.Checked)
{
    MessageBox.Show(advanceToBlackBar);
    PrintUtils.SendCommandToPrinter(advanceToBlackBar);
}
else if (radbtnGap.Checked)
{
    MessageBox.Show(advanceToGap);
    PrintUtils.SendCommandToPrinter(advanceToGap);
}

这种小小的突破行动"是否在某种程度上是有益的?

更新5

注意:也许没有"SerialPort.Flush":

serialPort.Close();

...正在完成同一件事?

解决方案

SGD命令格式正确.您所描述的间歇性行为使我认为问题出在打印机实际接收命令的一致性程度,而不是命令本身的语法.通常来说,不,您不必更改其他命令即可使此命令起作用.由于您可以通过Zebra设置实用程序成功发送命令并获得所需的行为,因此您应该可以通过代码执行相同的操作.

  1. 您是通过程序还是通过USB或其他方式(蓝牙,TCP等)发送命令?您在使用Zebra设置实用程序时提到了USB,但是在您的代码中该怎么办?

  2. 能否在PrintUtils.SendCommandToPrinter()的内部提供代码?我不熟悉此API.是哪个API?

  3. 在连接的最低级别,您通常会调用'write()'或'writeData()'或类似的名称.有时,写入"命令返回写入的字节数.如果您可以稍微深入研究一下代码,也许有一个写"命令可以返回该值,并且您可以验证自己返回的值是否等于预期消息的长度(包括换行符).

  4. 根据较低级别的API,还可能存在一个flush()命令,该命令强制将流中的所有数据推到另一端.同样,这取决于您在'PrintUtils'内幕使用的API.

过去,我看到USB通信的行为不一致.您应该确保您的固件是最新的.您的QLn220当前在v68.18.0Z上:

最终,您总是可以在设置打印机后立即查询打印机的间隙/条形模式.这将导致程序执行的额外延迟,但这是确保发送的所有内容实际上都有效的好方法.

I am trying to programatically configure a Zebra QLn220 printer to set its "media.sense_mode" to either "bar" or "gap" (depending on what the user selects).

The reliability of these commands working, though, seems very low (sometimes it works, sometimes it doesn't).

To test the various possible commands, I used the Zebra Setup Utilities, with the PC plugged into the printer, of course.

I sent this command from the util:

! U1 setvar "media.sense_mode" "gap"

It worked; I know this, because testing it with:

! U1 getvar "media.sense_mode"

...showed me the expected/hoped for "gap" (it had been "bar" prior to sending the command above).

But trying to accomplish the same thing in code works for "bar" (almost always) but hardly ever for "gap"

Here's the code:

const string 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);
. . .
if (radbtnBar.Checked)
{
    PrintUtils.SendCommandToPrinter(advanceToBlackBar);
}
else if (radbtnGap.Checked)
{
    PrintUtils.SendCommandToPrinter(advanceToGap);
}

So as you can see, the code is precisely the same except for "bar" vs. "gap"

Is it possible that the appended "\r\n" is causing a problem? It seems adding those were necessary or made the commands more reliable, but I'm open to anything at this point of frustration.

I always tested alternative commands for accomplishing the same thing, to see if they would be any more reliable, but neither of the other two alternatives worked, namely not this one:

! U1 setvar "ezpl.media_type" "web"

-nor this one:

{} {"media.sense_mode" "gap"}

...checking the val via getvar continued to show "bar" following the sending of those commands to the printer (after setting back to "bar" the value of "media.sense_mode" remains "bar" after sending these two commands).

Might it be that certain other printer settings need to be set for the printer to be more responsive to commands sent it? Not only is setting the commands programmatically unreliable, but even via the Zebra Setup Utility, it will sometimes "hourglass" for a LONG time before the command has been sent and returns - and other times it's quicker than Johnny Quick and Flash combined.

Looking through the voluminous output of this command:

! U1 getvar "allcv"

....the following are the most interesting/likely candidates. Which, if any, need to be changed, and to what values?

wlan.ip.dhcp.request_timeout : 2 , Choices: 2-30
wlan.ip.dhcp.session_interval : 10 , Choices: 0-60
. . .
wlan.ip.timeout.enable : on , Choices: on,off
wlan.ip.timeout.value : 300 , Choices: 1-3600
. . .
wlan.keep_alive.enable : on , Choices: on,off
wlan.keep_alive.timeout : 15 , Choices: 5-300
. . .
netmanage.avalanche.interval : 60000 , Choices: 0-4294967295
netmanage.avalanche.startup_update : off , Choices: on,off
netmanage.avalanche.interval_update : off , Choices: on,off
. . .
netmanage.avalanche.udp_timeout : 3000 , Choices: 0-4294967295
netmanage.avalanche.tcp_connection_timeout : 3000 , Choices: 0-4294967295
. . .
netmanage.avalanche.realtime_update_int : 300 , Choices: 0-4294967295
. . .
zpl.zpl_mode : zpl II , Choices: zpl II,zpl
. . .
internal_wired.ip.arp_interval : 0 , Choices: 0-30
. . .
internal_wired.ip.dhcp.requests_per_session : 2 , Choices: 1-10
internal_wired.ip.dhcp.request_timeout : 2 , Choices: 2-30
internal_wired.ip.dhcp.session_interval : 10 , Choices: 0-60
. . .
internal_wired.ip.timeout.enable : on , Choices: on,off
internal_wired.ip.timeout.value : 300 , Choices: 1-3600
. . .
internal_wired.ip.wins.permanent_source : off , Choices: on,off
. . .
interface.network.active.arp_interval : 0 
. . .
interface.network.active.speed : 0 
. . .
weblink.printer_reset_required : no 
. . .
weblink.ip.conn1.retry_interval : 10 , Choices: 1-600
. . .
weblink.ip.conn1.maximum_simultaneous_connections : 10 , Choices: 1-100
. . .
weblink.ip.conn1.test.retry_interval : 900 , Choices: 1-1800
weblink.ip.conn1.num_connections : 0 
. . .
capture.channel1.port : off , Choices: serial,usb,bt,parallel,off
capture.channel1.count : 0 , Choices: 0-4294967295

Anyone out there with a clue?

UPDATE

Here is the code that sends the commands:

public static bool SendCommandToPrinter(string cmd)
{
    bool success; // init'd to false by default
    try
    {
        using (SerialPort serialPort = new SerialPort())
        {
            serialPort.BaudRate = 19200;
            serialPort.Handshake = Handshake.XOnXOff;
            serialPort.Open();
            serialPort.Write(cmd);
            serialPort.Close(); // <= should be redundant within a using statement, but still getting "File 55" err...
        }
        success = true;
    }
    catch // may not need a try/catch block, as success defaults to false
    {
        success = false;
    }
    MessageBox.Show(success.ToString()); //TODO: Remove after testing
    return success;
}

The SerialPort in question is from OpenNETCF.IO.Ports.SerialPort

NOTE: SerialPort.Write() returns void.

The command:

! U1 getvar "appl.name" 

returns "V68.19.7Z" in the Zebra Setup Utility.

So does this mean my firmware is up-to-date (V68.19.7Z > v68.18.0Z), or does it mean since my "appl" is newer, I need to upgrade the firmware to V68.19.7Z? If I do need to update the firmware, how do I do that? Is it a matter of locating and downloading the latest firmware to my PC, then running its install app while the PC and Printer are connected via USB, or...???

UPDATE 2

From here, searching for QLn220, I see V68.18.0Z as the only firmware version available for download. So since I seem to have a newer version on my printer, I'm confused...why do they not offer what would seem to be the newer version (V68.19.7Z)?

UPDATE 3

If I click the "self-extracting archive" link at the page referenced above, I simply get a page with some generic but unactionable (so it seems) directions.

If I click the download link there, I get a page that says, "This webpage has a redirect loop"

UPDATE 4

It works after adding some debug strings; in the print code:

MessageBox.Show(success.ToString()); //TODO: Remove after testing
return success;

...and in the setting code:

if (radbtnBar.Checked)
{
    MessageBox.Show(advanceToBlackBar);
    PrintUtils.SendCommandToPrinter(advanceToBlackBar);
}
else if (radbtnGap.Checked)
{
    MessageBox.Show(advanceToGap);
    PrintUtils.SendCommandToPrinter(advanceToGap);
}

Could it be that this little "break in the action" is beneficial somehow?

UPDATE 5

Note: There is no "SerialPort.Flush" Maybe:

serialPort.Close();

...is accomplishing the same thing?

解决方案

The SGD commands are well-formed. The intermittent behavior that you describe makes me think the problem originates in how consistently the printer actually receives the command, and not the syntax of the command itself. And generally speaking, no, you do not have to change other commands in order to make this command work. Since you can successfully send the command via Zebra Setup Utilities and get the desired behavior, then you should be able to do the same through your code.

  1. Are you programmatically sending the commands over USB or over something else (Bluetooth, TCP, etc.)? You mentioned USB while using Zebra Setup Utilities, but what about in your code?

  2. Can you provide the code underneath the hood of PrintUtils.SendCommandToPrinter()? I am not familiar with this API. Which API is it?

  3. At the lowest levels of a connection you will often be calling 'write()' or 'writeData()' or something like that. Sometimes 'write' commands return the number of bytes written. If you can dig into your code a bit, perhaps there is a 'write' command that returns that value and you can verify yourself that the return value equals the length of the intended message (including new line characters).

  4. Depending on the lower level API, there also may be a flush() command lying around that forcibly pushes all data in a stream to the other end. Again, this depends on what API you're using underneat the hood of 'PrintUtils'.

In the past I have seen inconsistent behavior with USB communication. You should make sure that your firmware is as up-to-date as possible. Your QLn220 is currently on v68.18.0Z: http://www.zebra.com/id/zebra/na/en/index/drivers_downloads/firmware/results.html?productType=6. You can check your current version by sending:

! U1 getvar "appl.name"

At the end of the day, you could always immediately query the printer for its gap/bar mode after setting it. This will cause as an additional delay in your program execution, but it is a good way of making sure that whatever you sent has actually taken effect.

这篇关于我需要设置什么Zebra QLn220设置(以及设置为什么值)才能设置为"stick"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆