From 3890c434b01e2296d506806a6fb309e3923b0ed8 Mon Sep 17 00:00:00 2001 From: sydneyowl <84191144+SydneyOwl@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:40:33 +0800 Subject: [PATCH] :alembic: Wondering if 8600pro img writer is compatible --- Utils/Serial/MySerialPort.cs | 18 ++++++++++++++++++ Utils/Serial/WriBootImage.cs | 17 ++++++++--------- Views/Common/DeviceSelectWindow.axaml.cs | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Utils/Serial/MySerialPort.cs b/Utils/Serial/MySerialPort.cs index 41bb810..3fdb9c9 100644 --- a/Utils/Serial/MySerialPort.cs +++ b/Utils/Serial/MySerialPort.cs @@ -146,6 +146,24 @@ public void OpenSerial() _sp.Open(); } } + + + // 8600pro的串口 + public void OpenSerialPro() + { + _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.Open(); + } public void CloseSerial() { diff --git a/Utils/Serial/WriBootImage.cs b/Utils/Serial/WriBootImage.cs index 5b0e032..c6cfd7b 100644 --- a/Utils/Serial/WriBootImage.cs +++ b/Utils/Serial/WriBootImage.cs @@ -65,16 +65,18 @@ public WriBootImage(SHX_DEVICE device, SKBitmap img) { _device = device; image = img; + comStep = State.HandShakeStep1; + NComStep = NImgStep.Step_HandShake; if (device != SHX_DEVICE.SHX8600PRO) { TimerInit(); + _sp.OpenSerial(); } else { TimerInitPro(); + _sp.OpenSerialPro(); } - comStep = State.HandShakeStep1; - _sp.OpenSerial(); } @@ -137,6 +139,7 @@ private void OverTimer_Start() public bool WriteImg() { comStep = State.HandShakeStep1; + NComStep = NImgStep.Step_HandShake_Jump1; // Bitmap bitmap2 = new Bitmap(image.Width, image.Height, PixelFormat.Format24bppRgb); // for (int i = 0; i < image.Width; i++) // { @@ -330,10 +333,6 @@ public bool Communication() return false; } - - - - // 迷惑的8600_NEW public bool NHandShake() { byte[] array = new byte[1]; @@ -359,9 +358,9 @@ public bool NHandShake() _sp.WriteByte(bufForData, 0, 1); NComStep = NImgStep.Step_HandShake; overTimer.Stop(); - _sp.CloseSerial(); - _sp.BaudRate = 115200; - _sp.Open(); + // _sp.CloseSerial(); + // _sp.BaudRate = 115200; + // _sp.Open(); Thread.Sleep(100); return true; } diff --git a/Views/Common/DeviceSelectWindow.axaml.cs b/Views/Common/DeviceSelectWindow.axaml.cs index bf35efb..6873882 100644 --- a/Views/Common/DeviceSelectWindow.axaml.cs +++ b/Views/Common/DeviceSelectWindow.axaml.cs @@ -17,7 +17,7 @@ public DeviceSelectWindow() { // if (DebugWindow.HasInstance()) DebugWindow.GetInstance().Close(); InitializeComponent(); - if (HidTools.IsShxGt12HidExist()) DeviceChooseComboBox.SelectedIndex = 2; + if (HidTools.IsShxGt12HidExist()) DeviceChooseComboBox.SelectedIndex = 3; } private async void Device_OnClick(object? sender, RoutedEventArgs e)