c#怎么清除串口接收的数据?

2025-02-05 20:48:10
推荐回答(1个)
回答1:

SerialPort com3 = new SerialPort("COM1" ,9600), System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
com3.DiscardInBuffer();//丢弃来自串行驱动程序的接收缓冲区的数据
每次接收数据后,调用DiscardInBuffer方法就可以把缓存中的数据清除了