欢迎来到天天文库
浏览记录
ID:37904358
大小:315.50 KB
页数:18页
时间:2019-06-02
《RFID 源代码 ISO15693》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingISO15693DLL;usingSystem.Threading;namespaceISO15693_Reader{publicpartialclassMain:Form{//串口操作类的实例化ISO15693Reader
2、Reader=newISO15693Reader();//IsCommand用来标记当前五个实验中,使用的是那种命令,下面有对应的注释privateInt32IsCommand=0;publicMain(){InitializeComponent();}privatevoidMain_Load(objectsender,EventArgse){//窗体加载时调用RefreshPort();cmb_Baud.SelectedIndex=0;cmb_Reset.SelectedIndex=0;group_Operate.Enabled=false;group_Paramter.
3、Enabled=false;btn_Close.Enabled=false;txt_BlockCount.ReadOnly=true;}//////声明一个委托,用于显示窗体上的List_Info控件的信息//////privatedelegatevoidAddList(stringmsg);//////显示List_Info控件信息的方法//////privatevoidShowList(strin
4、gmsg){//使用委托显示信息,可避免跨线程调用的问题if(list_Info.InvokeRequired){AddListd=newAddList(ShowList);list_Info.Invoke(d,msg);}else{list_Info.Items.Insert(0,DateTime.Now.ToLongTimeString()+":"+msg);}}//打开串口privatevoidbtn_Open_Click(objectsender,EventArgse){if(cmb_Port.SelectedIndex<0){ShowList("打开失败,请选择串
5、口!");return;}Bytevalue=Reader.OpenSerialPort(cmb_Port.Text,Convert.ToInt32(cmb_Baud.Text));if(value==0x00){group_Paramter.Enabled=true;group_Operate.Enabled=true;btn_Open.Enabled=false;btn_Close.Enabled=true;ShowList(string.Format("Port:[{0}],OpenSucceed!,Baud:[{1}]",cmb_Port.Text,cmb_Baud
6、.Text));}else{ShowList(string.Format("Port[{0}],OpenFail!",cmb_Port.Text));}}//刷新串口privatevoidbtn_Refresh_Click(objectsender,EventArgse){RefreshPort();}//////刷新串口的方法///privatevoidRefreshPort(){cmb_Port.Items.Clear();cmb_Port.Text="";string[]Ports=System.IO.Ports.SerialPo
7、rt.GetPortNames();foreach(variteminPorts){cmb_Port.Items.Add(item);}if(Ports.Length>=0){cmb_Port.SelectedIndex=0;}}//关闭串口privatevoidbtn_Close_Click(objectsender,EventArgse){Bytevalue=Reader.CloseSerialPort();if(value==0x00){ShowList(string.Format("Port[{0}],Cl
此文档下载收益归作者所有