Skip to content

Commit

Permalink
🐛 fix baudrate error
Browse files Browse the repository at this point in the history
  • Loading branch information
SydneyOwl committed Aug 13, 2024
1 parent 734e8da commit 794e2e4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
27 changes: 26 additions & 1 deletion Utils/Serial/MySerialPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void OpenSerial()


// 8600pro的串口
public void OpenSerialPro()
public void OpenSerial8600Pro()
{
_sp.PortName = TargetPort;
_sp.BaudRate = 9600;
Expand All @@ -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()
{
Expand Down
8 changes: 6 additions & 2 deletions Utils/Serial/WriBootImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Views/Shx8800Pro/ProgressBarWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 794e2e4

Please sign in to comment.