Caterina upload works

This commit is contained in:
Matthias Neeracher 2015-01-02 07:26:10 +01:00 committed by Matthias Neeracher
parent a27334c768
commit ccfaf34129
3 changed files with 9 additions and 7 deletions

View File

@ -138,10 +138,9 @@ class ASBuilder {
logOut.writeData("Opening \(port) at 1200 baud\n".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)
}
if let dummyConnection = ASSerial.openPort(port, withSpeed: 1200) {
ASSerial.restorePort(dummyConnection.fileDescriptor)
dummyConnection.closeFile()
sleep(5)
for (var retry=0; retry < 10; ++retry) {
close(dummyConnection.fileDescriptor)
for (var retry=0; retry < 40; ++retry) {
usleep(250000)
if (NSFileManager.defaultManager().fileExistsAtPath(port)) {
if verbosity > 0 {
logOut.writeData("Found port \(port) after \(retry) attempts.\n".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)

View File

@ -474,7 +474,9 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
ASSerialWin.portAvailableAfterUpload(self.port)
})
}
dispatch_async(dispatch_get_main_queue(), {
self.builder.uploadProject(self.board, programmer:self.programmer, port:ASSerial.fileNameForPort(self.port))
})
}
buildProject(sender)
}

View File

@ -58,9 +58,10 @@ NSString * kASSerialPortsChanged = @"PortsChanged";
newAttr = origAttr;
cfmakeraw(&newAttr);
cfsetspeed(&newAttr, speed);
newAttr.c_cflag |= CS8 | CCTS_OFLOW | CRTS_IFLOW;
newAttr.c_cflag &= ~(PARENB);
newAttr.c_cflag &= ~(PARENB | CSIZE | CSTOPB | CRTSCTS);
newAttr.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &newAttr);
tcsetattr(fd, TCSAFLUSH, &newAttr);
if (!savedAttrs) {
savedAttrs = [NSMutableDictionary dictionary];
}