基本屬性:
serialPort.PortName //可用的COM端口号
serialPort.BaudRate //波特率
serialPort.DataBits //資料位
serialPort.StopBits //停止位
serialPort.Parity //奇偶校驗
serialPort.BytesToRead //擷取接收緩沖區的位元組數
serialPort.BytesToWrite //擷取發送緩沖區的位元組數
常用的方法:
DiscardInBuffer //丢棄接收緩存區的内容
DiscardOutBuffer //丢棄發送緩沖區的内容
Open //打開序列槽
read //從輸入緩沖區讀取
write(string) //将制定的字元串寫入串行端口
常用事件:
DataReceived //資料接收事件的方法
從 serialPort 對象接收資料時,将在輔助線程上引發DataReceived 事件,隻要接收緩沖區有資料就觸發。