using UHFHelper; namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //判断串口是否打开 if (!UHFCardHelper.GetInstance().ComOpen) { Resultoutput resultoutput = UHFCardHelper.GetInstance().OpenPort(); if (resultoutput.Res) { MessageBox.Show(resultoutput.ResMes); } else { MessageBox.Show(resultoutput.ResMes); } } } private void button2_Click(object sender, EventArgs e) { if (!UHFCardHelper.GetInstance().ComOpen) { MessageBox.Show("串口未打开"); return; } string res = UHFCardHelper.GetInstance().ReadCard(); label1.Text = res; } private void button3_Click(object sender, EventArgs e) { UHFCardHelper.GetInstance().ClosePort(); } private void button4_Click(object sender, EventArgs e) { var res = UHFCardHelper.GetInstance().WriteCard(textBox1.Text); MessageBox.Show(res.ResMes); } } }