110,533
社区成员
发帖
与我相关
我的任务
分享
public SerialPort m_sp;
// 串口初始化
private void InitializeMy()
{
string strT;
strT = textBox1.Text;
try
{
m_sp = new SerialPort();
m_sp.BaudRate = 57600;
m_sp.StopBits = StopBits.One;
m_sp.Parity = Parity.None;
m_sp.DataBits = 8;
m_sp.Handshake = Handshake.None;
m_sp.DataReceived += OnSerialDataReceived;
m_sp.Encoding = System.Text.Encoding.GetEncoding("GB2312");
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
}
}