<bdo id='bV2DE'></bdo><ul id='bV2DE'></ul>
        <i id='bV2DE'><tr id='bV2DE'><dt id='bV2DE'><q id='bV2DE'><span id='bV2DE'><b id='bV2DE'><form id='bV2DE'><ins id='bV2DE'></ins><ul id='bV2DE'></ul><sub id='bV2DE'></sub></form><legend id='bV2DE'></legend><bdo id='bV2DE'><pre id='bV2DE'><center id='bV2DE'></center></pre></bdo></b><th id='bV2DE'></th></span></q></dt></tr></i><div id='bV2DE'><tfoot id='bV2DE'></tfoot><dl id='bV2DE'><fieldset id='bV2DE'></fieldset></dl></div>
      1. <legend id='bV2DE'><style id='bV2DE'><dir id='bV2DE'><q id='bV2DE'></q></dir></style></legend><tfoot id='bV2DE'></tfoot>
      2. <small id='bV2DE'></small><noframes id='bV2DE'>

      3. RXTX 中是否需要持续轮询?

        Is constant polling in RXTX necessary?(RXTX 中是否需要持续轮询?)
        <legend id='wgrWb'><style id='wgrWb'><dir id='wgrWb'><q id='wgrWb'></q></dir></style></legend>
              <tbody id='wgrWb'></tbody>
              <bdo id='wgrWb'></bdo><ul id='wgrWb'></ul>
              1. <small id='wgrWb'></small><noframes id='wgrWb'>

                <i id='wgrWb'><tr id='wgrWb'><dt id='wgrWb'><q id='wgrWb'><span id='wgrWb'><b id='wgrWb'><form id='wgrWb'><ins id='wgrWb'></ins><ul id='wgrWb'></ul><sub id='wgrWb'></sub></form><legend id='wgrWb'></legend><bdo id='wgrWb'><pre id='wgrWb'><center id='wgrWb'></center></pre></bdo></b><th id='wgrWb'></th></span></q></dt></tr></i><div id='wgrWb'><tfoot id='wgrWb'></tfoot><dl id='wgrWb'><fieldset id='wgrWb'></fieldset></dl></div>
                  <tfoot id='wgrWb'></tfoot>
                  本文介绍了RXTX 中是否需要持续轮询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在试图找出 这个问题(任何帮助表示赞赏)时,我跑了RXTX 在使用 PortMon 监控其活动时注意到 RXTX 不断检查是否数据可用,即使 Java 客户端仅通过 SerialPortEventListener 从 gnu.io.SerialPort 对象读取.

                  While trying to figure out this problem (any help there is appreciated), I ran RXTX while monitoring its activity using PortMon and noticed that RXTX constantly checks if data is available, even when the Java client reads from the gnu.io.SerialPort object only through a SerialPortEventListener.

                  这是为什么?是 RXTX 人的糟糕实现选择,Sun 糟糕的 API 选择(因为 RXTX 遵循 javax.comm API),还是本地代码支持的运行 Java 的限制?

                  Why is this? Is it a poor implementation choice by the RXTX folks, a poor API choice by Sun (since RXTX follows the javax.comm API), or a limitation of running Java supported by native code?

                  另一方面,超级终端不进行轮询(并且可以正常工作).它是否有权访问一些让它执行此操作的隐藏 Windows 系统调用?

                  Hyperterminal, on the other hand, does no polling (and works without a problem). Does it have access to some hidden Windows system calls that let it do this?

                  推荐答案

                  不,这不是由于 javax.xomm API.顺便说一句,Rxtx 可以通过该 API 使用,也可以不使用.

                  No it's not due to the javax.xomm API. Rxtx can be used through that API or not by the way.

                  Rxtx 的内部结构有点不同/奇怪,并且有一些错误.简短版本,它应该是这样工作的:你有两个参数可以使用:超时和阈值.根据源代码将超时设置为 0(无)和阈值设置为 1(在返回之前至少需要 1 个字节)应该给我们正常,由 InputStream 定义,阻塞读取.

                  Rxtx internals are a bit different/weird though and has some bugs. Short version, this is how it is supposed to work: You have two parameters to play with: timeout and threshold. According to the source code setting the timeout to 0 (none) and threshold to 1 (requiring at least 1 byte before returning) should give us normal, by InputStream defined, blocking reads.

                  问题是,即使这样设置,当前稳定版本 (2.1.7r2) 中也存在错误.阈值参数始终设置为 0!来自源代码:

                  The problem is that even when setting it up like this there is a bug in the current stable release (2.1.7r2). The threshold parameter is always set to 0! From the source code:

                  /* 测试 ttyset.c_cc[ VMIN ] = 阈值;*/ttyset.c_cc[ VMIN ] = 0;

                  /* TESTING ttyset.c_cc[ VMIN ] = threshold; */ ttyset.c_cc[ VMIN ] = 0;

                  令人困惑的是,2004 年也是如此,并在邮件列表中报告并修复了,但它要么没有真正修复,要么又回来了(回归).实际上有一个新的错误报告,由于某种原因我一开始找不到.我最终发现它会抛出预发布包的源代码,并找到了一个未发布的更改日志(在最后一个稳定版本之后,网页不显示更改日志,但它在 CVS 中可用).

                  The confusing part is that this was also the case in 2004 and reported on the mailing list and fixed, but it was either not really fixed or has come back again (a regression). There is actually a new bug report that for some reason I couldn’t find at first. I eventually found it going throw the pre-release package source code and found an otherwise not published change log (the web page doesn’t show change logs after the last stable version, its available in CVS though).

                  解决方案

                  1. 已在 HEAD 上修复,因此您可以使用最新的预发布版本(2.2 系列)或从 CVS 编译.
                  2. 按照以下方式制作一个丑陋的解决方法:

                  1. It is fixed on HEAD, so you can use the latest pre-release version (2.2-series) or compile it from CVS.
                  2. Make an ugly workaround along the lines of:

                  int read(InputStream in) throws IOException {
                    int b; 
                    while ((b=in.read()) == -1) { 
                      try { Thread.sleep(10); } catch (InterruptedException e) { }
                    }
                    return b;
                  }
                  

                  然后你这样做:read(in) 而不是 in.read().

                  Then you do: read(in) instead of in.read().

                  我实际上写了 一篇关于此的博客文章以前,所以我不会忘记.

                  I actually wrote a blog entry about this 2 years ago so I wouldn't forget.

                  这篇关于RXTX 中是否需要持续轮询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                • <legend id='oJxtF'><style id='oJxtF'><dir id='oJxtF'><q id='oJxtF'></q></dir></style></legend>
                    <bdo id='oJxtF'></bdo><ul id='oJxtF'></ul>

                    <small id='oJxtF'></small><noframes id='oJxtF'>

                      <tbody id='oJxtF'></tbody>

                        • <i id='oJxtF'><tr id='oJxtF'><dt id='oJxtF'><q id='oJxtF'><span id='oJxtF'><b id='oJxtF'><form id='oJxtF'><ins id='oJxtF'></ins><ul id='oJxtF'></ul><sub id='oJxtF'></sub></form><legend id='oJxtF'></legend><bdo id='oJxtF'><pre id='oJxtF'><center id='oJxtF'></center></pre></bdo></b><th id='oJxtF'></th></span></q></dt></tr></i><div id='oJxtF'><tfoot id='oJxtF'></tfoot><dl id='oJxtF'><fieldset id='oJxtF'></fieldset></dl></div>

                          1. <tfoot id='oJxtF'></tfoot>