Increasing "priority" of serial port access in my VB.NET program
Posted on 2010-11-15
So I have written a VB.NET program that controls hardware over a serial port, and receives feedback from the port, sometimes quickly. I am using the System.IO.Ports.SerialPort class and handling the DataReceived event.
What I find is that the speed at which I receive these updates in my VB.NET program is not that fast, I'm trying to send 10-15 character messages at 30-40 hz, and I find that my VB.NET program itself is a bit of a bottleneck. When I listen in hyperterminal I see every message at a smooth rate, but when I strip down my VB.NET program to just the port and counting the messages, the number tends to ebb and flow, be choppy, slow then fast, like an internal queue is falling behind, catching up, etc.
Does anyone know any tricks to relieve the bottleneck, maybe give my System.IO.Ports.SerialPort a higher priority or something? Somehow hyperterminal achieves a snappiness on serial input that I am unable to achieve with a barebones VB.NET program.
Thanks for any thoughts...