From 0cab7ec5407f96a296b27ead0d22b61585f491f0 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Thu, 4 Jun 2015 20:50:33 +0200 Subject: [PATCH] Configtool: improve search for avrdude.conf. Should now also work for Arduino 1.5.x and up. This is work related to issue #158. --- configtool/build.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/configtool/build.py b/configtool/build.py index 1ca72c4..fa47c72 100644 --- a/configtool/build.py +++ b/configtool/build.py @@ -24,6 +24,10 @@ class ScriptTools: self.settings = settings def figureCommandPath(self, baseCommand): + findConf = False + if baseCommand == "avrdude": + findConf = True + if platform.startswith("win"): baseCommand += ".exe" @@ -42,8 +46,24 @@ class ScriptTools: if os.path.exists(cmdpathTry): cmdpath = "\"" + cmdpathTry + "\"" break + + if findConf: + confpath = cmdpath.strip("\"") + exepos = confpath.rfind(".exe") + if exepos >= 0: + confpath = confpath[0:exepos] + confpath += ".conf" + if not os.path.exists(confpath): + confpath = os.path.split(confpath)[0] + confpath = os.path.split(confpath)[0] + confpath = os.path.join(confpath, "etc") + confpath = os.path.join(confpath, "avrdude.conf") + if os.path.exists(confpath): + cmdpath += " -C \"" + confpath + "\"" + else: cmdpath = baseCommand + # No need to search avrdude.conf in this case. return cmdpath @@ -396,8 +416,6 @@ class Upload(wx.Dialog): cmdpath = ScriptTools(self.settings).figureCommandPath("avrdude") hexpath = "\"" + join(self.root, "teacup.hex") + "\"" - if self.settings.arduinodir: - cmdpath = cmdpath + " -C " + cmdpath.rstrip("\"") + ".conf\"" cmd = cmdpath + " -c %s -b %s -p %s -P %s -U flash:w:%s:i" % \ (self.settings.programmer, self.baud, self.cpu, self.settings.port, hexpath)