预览加载中,请您耐心等待几秒...
1/3
2/3
3/3

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; usingSystem.IO.Ports; namespace串?口ú发ぁ?送í接ó收?演Y示? { publicpartialclassForm1:Form { publicForm1() { InitializeComponent(); } publicSerialPortport1=newSerialPort("COM2",9600,Parity.None,8,StopBits.One); publicSerialPortport2=newSerialPort("COM3",9600,Parity.None,8,StopBits.One); privatevoidForm1_Load(objectsender,EventArgse) { } privatevoidbutton1_Click(objectsender,EventArgse) { port1.Open(); port1.DiscardInBuffer(); port1.DiscardOutBuffer(); MessageBox.Show("打洙?开aCOM2口ú成é功|!?","系μ统?提?示?"); } privatevoidbutton3_Click(objectsender,EventArgse) { port2.Open(); port2.DiscardInBuffer(); port2.DiscardOutBuffer(); MessageBox.Show("打洙?开aCOM3成é功|!?","系μ统?提?示?"); } privatevoidbutton5_Click(objectsender,EventArgse) { byte[]data=Encoding.Unicode.GetBytes(textBox1.Text); stringstr=Convert.ToBase64String(data); port1.WriteLine(str); MessageBox.Show("数簓据Y发ぁ?送í成é功|!?","系μ统?提?示?"); System.Threading.Thread.Sleep(1000); byte[]data1=Convert.FromBase64String(port2.ReadLine()); textBox2.Text=Encoding.Unicode.GetString(data1); MessageBox.Show("数簓据Y接ó收?成é功|","系μ统?提?示?"); } privatevoidbtnclose_Click(objectsender,EventArgse) { serialPort1.Close(); serialPort2.Close(); Close(); } } }