基于串口通信,循环读取扫码枪数据在UI显示 Task.Run(new Action(async () =>
{
IndustrialBLL bll = new IndustrialBLL();
/// 获取串口配置信息
var si = bll.InitSerialInfo();
if (si.State)
SerialInfo = si.Data;
else
{
//faultAction.Invoke(si.Message);
}
// 初始化ModbusRTU串口通信
var rtu = ASCII.GetInstance(SerialInfo);
ASCII objASCII = new ASCII(SerialInfo);
// 连接串口
if (objASCII.OpenSerialPort())
{
while (SMQ)
{
Dispatcher.Invoke(
new Action(
delegate
{
txtSMQ.Text = objASCII.GetString();
}));
}
}
}));
2021-12-21 09:02:56
2KB
串口扫码枪