Skip to content

Commit 920afd8

Browse files
committed
fix possible bad cfg
1 parent 694f845 commit 920afd8

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

app/Wissance.Zerial/Wissance.Zerial.Desktop/ViewModels/MainWindowViewModel.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ public MainWindowViewModel()
3535
// these init depends on loaded configuration
3636
foreach (SerialPortShortInfoModel config in DevicesConfigs)
3737
{
38-
if (config.Configuration != null)
38+
// TODO(UMV): this is strange thing and could occur when device.config file was corrupted
39+
if (config.Configuration == null)
3940
{
40-
SerialDeviceModel model = new SerialDeviceModel(config.Configuration);
41-
config.DisplayConfiguration = model.GetDisplayInfo();
42-
_serialDevices.Add(model);
41+
// config looks the following manner: "COM3, 115200 b/s, 8 bit, 1 Sb, 4, 1"
42+
config.Configuration = $"{config.DeviceName}, 115200 b/s, 8 bit, 1 Sb, 4, 1";
4343
}
44+
45+
SerialDeviceModel model = new SerialDeviceModel(config.Configuration);
46+
config.DisplayConfiguration = model.GetDisplayInfo();
47+
_serialDevices.Add(model);
4448
}
4549
// these are defaults values
4650
SetDefaultSelectedOptions();

0 commit comments

Comments
 (0)