-
实现serialport测试,包括串口的打开、关闭及所有常用属性的设置
资源介绍
串口链接,通过VS测试
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SerialNameSelect();
SelectPortStopBits();
SelectHandShake();
SelectParity();
SerialNumber.SelectedIndex = 0;
serialBit.SelectedIndex = 2;
SerialDataBits.SelectedIndex = 3;
SerialStopBits.SelectedIndex = 1;
SerialHandShoke.SelectedIndex = 1;
SerialParity.SelectedIndex = 0;
}
private void SerialNameSelect()
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
SerialNumber.Items.Add(port);
}
}
private void SelectPortStopBits()
{
foreach (string s in Enum.GetNames(typeof(StopBits)))
{
SerialStopBits.Items.Add(s);
}
}
private void SelectHandShake()
{
foreach (string s in Enum.GetNames(typeof(Handshake)))
{
SerialHandShoke.Items.Add(s);
}
}
private void SelectParity()
{
foreach (string s in Enum.GetNames(typeof(Parity)))
{
SerialParity.Items.Add(s);
}
}。。。。。。。。。。
- 上一篇: SerialPort控件的使用
- 下一篇: AntiARP