Windows COM端口问题 [英] Problem with COM Port with Windows

查看:123
本文介绍了Windows COM端口问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



首先,对不起,我所使用的软件不多,因此,如果发帖地点错误,请原谅.我有一位顾问使用MS Visual C ++ 2010编写仪表程序,他无法解决错误,因此我想我可以看看是否有人提出建议.

该应用程序连接到com端口(115200,无握手信号),并显示一个角度.数据有时可能很快到达.他有时会错过最后一组值(发送的最后一个值是最重要的值).他声称这与Windows有关.

当我使用Hyperterm时,它永远不会失败,因此我似乎认为这应该不是问题.

有任何意见/建议吗?

谢谢,

标记

Hi,

First, sorry, I don''t know much software, so please excuse my posting, if this is in the wrong spot. I have a consultant doing a meter program using MS Visual C++ 2010, and he is having trouble fixing a bug, so I thought I would see if anybody has a suggestion.

The application connects to a com port (115200, no handshaking), and displays an angle. The data can come quite fast at times. He occasionally misses the last sets of values (the last value sent is the most important one). He claims it is something to do with Windows.

When I use Hyperterm, it never fails, so I seem to think it shouldn''t be a problem.

Any comments/suggestions?

Thanks,

Mark

推荐答案

正如其他人所说,我怀疑代码当前正在轮询接收队列,而不是有专用线程将其吸干并推送将其放入缓冲区中的某个地方

20年前,我可以轻松地从配备16550UART的30Mhz DOS计算机中获得115k2,因此,如今这对硬件而言已不是问题-但是,如果您不这样做,Windows在性能方面将非常笨拙"不能有效地与硬件对话-即在第二个线程上

我敢打赌那里有一个单线程读取com端口,并写入磁盘-磁盘IO中的延迟正在充分延迟轮询器,以至于UART缓冲区被淹没.
As others have said, I''d suspect that the code is currently polling the receive queue, rather than having a dedicated thread sucking it dry, and pushing it into a buffer somewhere

20 years ago, I was comfortably getting 115k2 out of a 30Mhz DOS machine with a 16550UART, so these days it''s not a problem for the hardware - Windows however, is extremely ''lumpy'' in terms of performance if you don''t talk to hardware effectively - i.e. on a second thread

I''d wager there''s a single thread reading the com port, writing to disk - the latency in disk IO is delaying the poller sufficiently for the UART buffer to get swamped


显然如果Hyperterminal从未遗漏任何值(如您所建议的,Mark),则与Windows无关.

与Windows有关"是应用程序软件中错误的古老经典借口.
Obviously it cannot be to do with Windows if Hyperterminal never misses the values (as you''ve suggested, Mark).

"Something to do with Windows" is the old classic excuse for bugs in app software.


Hi Mark,
如果您的顾问使用的是非托管代码,请确保他使用的是重叠的I/O.几年前,这帮助我解决了类似的问题.
无论如何,请让他搜索串行端口I/O".这些API与文件API相似,但是细节仍然隐藏着魔鬼.

希望这会有所帮助,
巴勃罗.
Hi Mark,
If your consultant is using unmanaged code, make sure he''s using overlapped I/O. This helped me with a similar issue a few years ago.
In any case, have him google ''SERIAL PORT I/O''. The APIs are similar to file APIs, but the devil, as always, hides in the details.

Hope this helps,
Pablo.


这篇关于Windows COM端口问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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