From 794e2e45593d0fde4bda46227d132454bc1bac24 Mon Sep 17 00:00:00 2001 From: sydneyowl <84191144+SydneyOwl@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:39:09 +0800 Subject: [PATCH] :bug: fix baudrate error --- Utils/Serial/MySerialPort.cs | 27 ++++++++++++++++++++- Utils/Serial/WriBootImage.cs | 8 ++++-- Views/Shx8800Pro/ProgressBarWindow.axaml.cs | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Utils/Serial/MySerialPort.cs b/Utils/Serial/MySerialPort.cs index 5fc8cf3..883c478 100644 --- a/Utils/Serial/MySerialPort.cs +++ b/Utils/Serial/MySerialPort.cs @@ -149,7 +149,7 @@ public void OpenSerial() // 8600pro的串口 - public void OpenSerialPro() + public void OpenSerial8600Pro() { _sp.PortName = TargetPort; _sp.BaudRate = 9600; @@ -164,6 +164,31 @@ public void OpenSerialPro() _sp.WriteTimeout = 4000; _sp.Open(); } + + public void OpenSerial8800Pro() + { + // _sp.PortName = TargetPort; + // _sp.BaudRate = 9600; + // _sp.DataBits = 8; + // _sp.StopBits = StopBits.One; + // _sp.Parity = Parity.None; + // _sp.ReadBufferSize = 10240; + // _sp.WriteBufferSize = 10240; + // _sp.DtrEnable = true; + // _sp.RtsEnable = true; + // _sp.ReadTimeout = 4000; + // _sp.WriteTimeout = 4000; + _sp.PortName = TargetPort; + _sp.BaudRate = 115200; + _sp.DataBits = 8; + _sp.Parity = Parity.None; + _sp.StopBits = StopBits.One; + _sp.WriteBufferSize = 102400; + _sp.ReadBufferSize = 102400; + _sp.RtsEnable = true; + _sp.DtrEnable = true; + _sp.Open(); + } public void OpenSerialProWithHigherBaudrate() { diff --git a/Utils/Serial/WriBootImage.cs b/Utils/Serial/WriBootImage.cs index 0c9952e..4e2ac71 100644 --- a/Utils/Serial/WriBootImage.cs +++ b/Utils/Serial/WriBootImage.cs @@ -69,10 +69,14 @@ public WriBootImage(SHX_DEVICE device, SKBitmap img) image = img; comStep = State.HandShakeStep1; NComStep = NImgStep.Step_HandShake; - if (device is SHX_DEVICE.SHX8600PRO or SHX_DEVICE.SHX8800PRO) + if (device is SHX_DEVICE.SHX8600PRO) { TimerInitPro(); - _sp.OpenSerialPro(); + _sp.OpenSerial8600Pro(); + }else if (device is SHX_DEVICE.SHX8800PRO) + { + TimerInitPro(); + _sp.OpenSerial8800Pro(); } else { diff --git a/Views/Shx8800Pro/ProgressBarWindow.axaml.cs b/Views/Shx8800Pro/ProgressBarWindow.axaml.cs index 175b92f..e64bf28 100644 --- a/Views/Shx8800Pro/ProgressBarWindow.axaml.cs +++ b/Views/Shx8800Pro/ProgressBarWindow.axaml.cs @@ -56,7 +56,7 @@ private async void StartButton_OnClick(object? sender, RoutedEventArgs e) progressBar.Value = 0; try { - port.OpenSerial(); + port.OpenSerial8800Pro(); _cancelSource = new CancellationTokenSource(); _threadCommunication = new Thread(() => Task_Communication(_cancelSource.Token)); _threadCommunication.Start();