调整scan

This commit is contained in:
赵正易 2025-05-23 08:53:44 +08:00
parent 6646e6b5e5
commit c02845ddc3
2 changed files with 10 additions and 5 deletions

View File

@ -111,11 +111,11 @@ namespace RIZO_Application.Modules.ModuleName.ViewModels
throw new ObjectDisposedException(nameof(ScanControlViewModel));
//if (SerialConfigs.Current != null)
//{
// comName = SerialConfigs.Current.ComName ?? string.Empty;
// baudRate = SerialConfigs.Current.BaudRate ?? 9600;
//}
if (SerialConfigs.Current != null)
{
comName = SerialConfigs.Current.ComName ?? string.Empty;
baudRate = SerialConfigs.Current.BaudRate ?? 9600;
}
_eventAggregator.GetEvent<SystemLogEvent>().Publish($"串口扫码枪初始化……串口:{comName} 波特率:{baudRate}");

View File

@ -63,6 +63,11 @@ namespace RIZO_Helper.Tools
_serialPort.DataReceived += OnSerialDataReceived;
return true;
}
catch (InvalidOperationException ex)
{
Debug.WriteLine($"打开串口 {_serialPort.PortName} 失败: {ex.Message}");
return false;
}
catch (OperationCanceledException) when (_disposeCts.IsCancellationRequested)
{
return false;