A few notes:
First off, I understand that Thread.Sleep()
is much maligned, but I don't have many other choices. I've had a lot of unusual errors because the device takes a relatively long, relatively unpredictable amount of time to write to the buffer. Currently I try to sleep and discard the buffer whenever possible. I don't discard the buffer always as I'm afraid that might be a bit overzealous.
I'm worried as I've never used the SerialPortSerialPort
class before. I don't know if there's anything I'm missing here. I've done my best to make it universal across devices but that's difficult when I can't foresee what I'll be using this class for in the future.
ReadLineReadLine
does not wipe the buffer. I've seen this firsthand when Rts and Dtr aren't enabled. Say I issue the command: *IDN?
normally this returns: FLUKE,5500A,8030005,2.61+1.3+2.0+* 66>
but sometimes issuing it and then calling ReadLine()
doesn't give the machine a chance to completely write to the buffer. Due to this, stale data will be left in the buffer. Say I then issue another command, OUT 30V, 60KHZ
and call ReadLine()
again, if there's still stale data, ReadLine()
will receive FLUKE,5500A,8030005,2.61+1.3+2.0+* 66>
from the last command that was issued instead of the expected output.