使用 usbserial 通过 RxTx 写入数据?
我在 Linux 发行版上通过 usbserial 使用 RxTx 库。 RxTx 库的行为似乎与串行方式的工作方式完全不同(以一种糟糕的方式)。
我最大的问题之一是 RxTx SerialPortEvent.OUTPUT_BUFFER_EMPTY 无法通过 USB 串行在 Linux 上工作。
我如何知道何时应该写入流? 我可能错过了任何指标吗?
到目前为止,我同时写作和阅读的经验并不是很好。 有谁知道我在流上写入时是否应该锁定 DATA_AVAILABLE 处理程序以防止被调用? 或者 RxTx 接受并发读/写?
I'm using the RxTx library over usbserial on a Linux distro. The RxTx lib seems to behave quite differently (in a bad way) than how it works over serial.
One of my biggest problems is that the RxTx SerialPortEvent.OUTPUT_BUFFER_EMPTY
does not work on linux over usb serial.
How do I know when I should write to the stream? Any indicators I might have missed?
So far my experience with writing and reading concurrently have not been great. Does anyone know if I should lock the DATA_AVAILABLE
handler from being invoked while I'm writing on the stream? Or RxTx
accepts concurrent read/writes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(也许有点偏离主题,但这里是)
我不熟悉那个特定的库,但我可以向你保证可怕的经历(我在安全系统中工作(例如:硬件安全设备) )业务,RS-232 被大量使用),并非所有 USB 串行转换器都是生而平等的。 许多此类设备无法正确模拟所有 RS-232 线路,许多设备甚至在没有流量控制的情况下无法处理任何通信。 在指责库之前,请尝试确认硬件确实做了它应该做的事情。
不想认可特定的产品或品牌,我多年来遇到的最好的(例如:最少错误的)USB 串行转换器是 USA-19HS。
(perhaps slightly off-topic, but here goes)
I'm not familiar with that particular library, but I can assure you from dire experience (I work in the security systems (as in: hardware security devices) business, where RS-232 is heavily used) that not all USB-serial converters are born equal. Many such devices so not properly emulate all RS-232 lines, and many don't even handle any comms without flow control. Before blaming the library, try to confirm that the hardware actually does what it's supposed to do.
Without wanting to endorse a particular product or brand, the best (as in: least buggy) USB-serial converter I have come across in years is the USA-19HS.
通过 USB 转串口使用 RxTx 时,您不能将 notificationOnOutput 设置为 true,否则它会完全锁定。
我经历了惨痛的教训才明白这一点。 互联网上的一些网站上记录了此问题。
我在 Linux 上运行它,我相信这是 Linux 独有的问题,尽管我无法确认这一点。
至于您给我的链接...我已经看过 SimpleReader 和 SimpleWriter 示例,但这些并不代表现实世界的应用程序。 它不是多线程的,假设读取具有所需的完整数据,而不是缓冲读取等。
谢谢,
Jeach!
Using RxTx over usb-to-serial you can't set notifyOnOutput to true otherwise it locks up completely.
I've learned this the hard way. This problem is documented on a few web sites over the internet.
I'm running it on Linux and I believe that this is a Linux only issue, although I can't confirm that.
As for the link you've given me... I've seen the SimpleReader and SimpleWriter examples, but these don't represent a real world application. It is not multi-threaded, assumes a read has the full data it needs instead of buffering reads, etc.
Thanks,
Jeach!