Configtool: add ability to cancel upload.
In case communications to the bootloader doesn't work as expected, avrdude often takes many many minutes to recognize this, so it's very convenient to be able to abort these fruitless attempts. This should solve issue #131.
This commit is contained in:
parent
610e1d169b
commit
61c1ba182f
|
|
@ -74,6 +74,7 @@ class ScriptThread:
|
||||||
wx.PostEvent(self.win, evt)
|
wx.PostEvent(self.win, evt)
|
||||||
p.kill()
|
p.kill()
|
||||||
self.running = False
|
self.running = False
|
||||||
|
p.wait()
|
||||||
return
|
return
|
||||||
|
|
||||||
rc = p.wait()
|
rc = p.wait()
|
||||||
|
|
@ -310,6 +311,7 @@ class Upload(wx.Dialog):
|
||||||
self.cpu = cpu
|
self.cpu = cpu
|
||||||
self.baud = self.settings.uploadspeed
|
self.baud = self.settings.uploadspeed
|
||||||
self.Bind(wx.EVT_CLOSE, self.onExit)
|
self.Bind(wx.EVT_CLOSE, self.onExit)
|
||||||
|
self.cancelPending = False
|
||||||
|
|
||||||
hsz = wx.BoxSizer(wx.HORIZONTAL)
|
hsz = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
hsz.AddSpacer((10, 10))
|
hsz.AddSpacer((10, 10))
|
||||||
|
|
@ -338,9 +340,9 @@ class Upload(wx.Dialog):
|
||||||
self.active = False
|
self.active = False
|
||||||
else:
|
else:
|
||||||
self.Bind(EVT_SCRIPT_UPDATE, self.uploadUpdate)
|
self.Bind(EVT_SCRIPT_UPDATE, self.uploadUpdate)
|
||||||
t = ScriptThread(self, self.script)
|
self.t = ScriptThread(self, self.script)
|
||||||
self.active = True
|
self.active = True
|
||||||
t.Start()
|
self.t.Start()
|
||||||
|
|
||||||
def generateUploadScript(self):
|
def generateUploadScript(self):
|
||||||
self.script = []
|
self.script = []
|
||||||
|
|
@ -362,15 +364,31 @@ class Upload(wx.Dialog):
|
||||||
|
|
||||||
if evt.state == SCRIPT_RUNNING:
|
if evt.state == SCRIPT_RUNNING:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if evt.state == SCRIPT_CANCELLED:
|
if evt.state == SCRIPT_CANCELLED:
|
||||||
self.log.AppendText("Upload terminated abnormally.\n")
|
|
||||||
self.active = False
|
self.active = False
|
||||||
|
|
||||||
|
if self.cancelPending:
|
||||||
|
self.EndModal(wx.ID_OK)
|
||||||
|
|
||||||
|
self.log.AppendText("Upload terminated abnormally.\n")
|
||||||
|
|
||||||
if evt.state == SCRIPT_FINISHED:
|
if evt.state == SCRIPT_FINISHED:
|
||||||
self.log.AppendText("Upload completed normally.\n")
|
self.log.AppendText("Upload completed normally.\n")
|
||||||
self.active = False
|
self.active = False
|
||||||
|
|
||||||
def onExit(self, evt):
|
def onExit(self, evt):
|
||||||
if self.active:
|
if self.active:
|
||||||
|
dlg = wx.MessageDialog(self, "Are you sure you want to cancel upload?",
|
||||||
|
"Upload active",
|
||||||
|
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_INFORMATION)
|
||||||
|
rc = dlg.ShowModal()
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
if rc == wx.ID_YES:
|
||||||
|
self.cancelPending = True
|
||||||
|
self.log.AppendText("Cancelling...\n")
|
||||||
|
self.t.Stop()
|
||||||
return
|
return
|
||||||
|
|
||||||
self.EndModal(wx.ID_OK)
|
self.EndModal(wx.ID_OK)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue