Successfully uploads

This commit is contained in:
Matthias Neeracher 2014-12-08 03:59:47 +01:00 committed by Matthias Neeracher
parent cc3033e01e
commit cd9aae2190
2 changed files with 30 additions and 3 deletions

View File

@ -71,4 +71,29 @@ class ASBuilder {
task!.arguments = args;
task!.launch()
}
func uploadProject(board: String, programmer: String, port: String) {
task = NSTask()
task!.currentDirectoryPath = dir.path!
task!.launchPath = "/usr/local/CrossPack-AVR/bin/avrdude"
let fileManager = NSFileManager.defaultManager()
let logURL = dir.URLByAppendingPathComponent("build/upload.log")
fileManager.createFileAtPath(logURL.path!, contents: NSData(), attributes: nil)
let logOut = NSFileHandle(forWritingAtPath: logURL.path!)!
task!.standardOutput = logOut
task!.standardError = logOut
let libPath = (ASLibraries.instance().directories as NSArray).componentsJoinedByString(":")
let boardProp = ASHardware.instance().boards[board]!
let progProp = ASHardware.instance().programmers[programmer]
let proto = boardProp["upload.protocol"] ?? progProp?["protocol"]
let speed = boardProp["upload.speed"] ?? progProp?["speed"]
var args = ["-v", "-v", "-v", "-v", "-D",
"-C", "/usr/local/CrossPack-AVR/etc/avrdude.conf",
"-p", boardProp["build.mcu"], "-c", proto!, "-P", port, "-b", speed!,
"-U", "flash:w:build/"+board+"/"+dir.lastPathComponent+".hex:i"]
task!.arguments = args;
task!.launch()
}
}

View File

@ -330,9 +330,6 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
// MARK: Build / Upload
@IBAction func uploadProject(AnyObject) {
}
@IBAction func buildProject(AnyObject) {
selectNode(files.buildLog)
builder.buildProject(board, files: files)
@ -429,5 +426,10 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
return ASHardware.instance().boards[board]?["upload.protocol"] != nil
}
}
@IBAction func uploadProject(AnyObject) {
selectNode(files.uploadLog)
builder.uploadProject(board, programmer:programmer, port:port)
}
}