最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

serial port - .Net SerialPort overrun cause? - Stack Overflow

programmeradmin3浏览0评论

I have a .Net Windows desktop application that reads a data packet from an external device via a serial port. This is a very infrequent action (once a minute, if that), and the data packet is approx 300-500 bytes, so it's not like I'm having to keep up with a continuous stream of data.

The application has worked fine for years, but every so often we encounter a customer PC where this read operation refuses to work. The SerialPort raise the ErrorReceived event with the event arg reporting a SerialError.Overrun. The documentation for this enum value doesn't say a lot:

A character-buffer overrun has occurred. The next character is lost.

The SerialPort object's ReceiveBufferSize is set to 32000 and baud rate is 921600. When not periodically reading the above data packet, the software is actually very "chatty", sending and receiving small amounts of data at 100ms intervals (a few 10s of bytes), but we never see any overruns during these requests.

All customer PCs use "Brainboxes" RS422/485 dual serial port PCI cards. Not sure of exact model but something like this. Weirdly, replacing their PCI card with a USB serial adapator seems to sort the problem out.

Any thoughts on what the problem might be? If it was software then I'd assume we would see this on more PCs? Could it be hardware, or OS, e.g if the PC/Windows is under load could that interfere with reading the serial port?

发布评论

评论列表(0)

  1. 暂无评论