-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEsptoolHandler.cs
47 lines (41 loc) · 1.38 KB
/
EsptoolHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WVR_Glove_Configurator
{
class EsptoolHandler
{
private Process process = new Process();
private string comName;
private int baundRate;
public event EventHandlerPassInt eventHandlerPassInt;
public EsptoolHandler(string comName, int baundRate, string espToolPath)
{
this.comName = comName;
this.baundRate = baundRate;
Directory.SetCurrentDirectory(espToolPath);
}
public void ToolStart()
{
process.StartInfo.FileName = "esptool.exe";
process.StartInfo.Arguments = "--chip esp32 --port " + this.comName + " --baud " + this.baundRate + " write_flash -z 0x110000 settings.bin";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
if(eventHandlerPassInt != null)
{
while(!process.HasExited)
{
int i = process.StandardOutput.Read();
eventHandlerPassInt(this,null,i);
}
process.WaitForExit();
}
}
}
}