This doesn't happen with a Uno target or with IDE v1.0.1 or v1.5.x
I'm on a Mac OS X Lion (10.7.5).
v1.0.1 has a hanging bug with tone() on Leonardo so I need to use either 1.0.2 or 1.5.x, but 1.5.x is still in beta.
Can someone else confirm this bug?
The full message from the IDE is as follows:
Binary sketch size: 4,952 bytes (of a 28,672 byte maximum)
processing.app.SerialException: Serial port '/dev/tty.usbmodemfd1211' already in use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:119)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:201)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
Yes I can confirm the bug. I found it with my own sketch, also tried your sketch.
Error messages are same as yours, verbatim - all the same java line numbers.
I am also on Arduino.app 1.0.2.
I am on Mountain Lion 10.8.2, however.
Also, I am using a Micro instead of a Leonardo. (I believe they are electrically identical?)
I don't get it with every upload, maybe 70% of uploads?
Yes my sketch also runs fine despite the error.
Oh - I just tried again and got a different error:
processing.app.SerialException: Error touching serial port '/dev/tty.usbmodemfd121'.
at processing.app.Serial.touchPort(Serial.java:123)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:201)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171)
at processing.app.Serial.touchPort(Serial.java:113)
... 7 more
Could not repeat that one though. Usually I get your error, and sometimes no error.
Cheers.
P.S. I also have an Uno, and do not get the error with that (everything else the same).
P.P.P.S. Also, Arduino.app 1.5.1 does not produce this exception. (However the Micro is not among the supported boards in 1.5.1 ... I have to select "Leonardo".)
When starting an upload the ide sets the baurate to 1200. When the leonardo observes a DTR drop when the baudrate is 1200, it resets.
In order to avoid unintentional autoresets, the fix sets above sets the baudrate back to the value from the preferences, once the upload completed. For some reason this sometimes fails on your system (different locking scheme on the mac: lock still held by avrdude? the reason should be investigated...). On my system (kubuntu/linux 3.0.0-12) it always works correctly. I'll help think about a proper solution (don't have a mac though) :
Maybe just catch the exception and ignore it (after all, it can also happen the sketches serial port never comes back, this is of coarse ignored too...)
Retry touching a number of times?
...
Fortunately, when the problem occurs, the sketch is already uploaded and works correctly, like you indicated.
I'm seeing the same exception with my Arduino Micro. Arduino is v1.0.2:
Binary sketch size: 15,902 bytes (of a 28,672 byte maximum)
processing.app.SerialException: Serial port '/dev/tty.usbmodemfd111' already in use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:119)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:201)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
I have received the following error message as well running a Leonardo on Mac OS X 10.8.2 and Arduino version 1.03.
processing.app.SerialException: Serial port '/dev/tty.usbmodemfd141' already in use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:119)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:201)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
What is interesting is the sketch will run. If I replace that sketch with a new one (using the OPEN command and a new sketch) I will sometimes get this error or not. In any event the new sketch will run. That is sometimes the IDE will state Upload complete and other times the IDE will state the above error message. I have rebooted the computer to ensure that the port is identified. I have tried all the .tty ports with the same result.
I also get the same thing. I am new to the Arduino.
Blink does work, but I cannot get a servo to work (that could be unrelated to this post).
Here's what I get about 99% of the time when I Upload:
processing.app.SerialException: Serial port '/dev/tty.usbmodem1411' already in use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:119)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:201)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:680)
I am running Arduino 1.0.3
Arduino Micro Board
Mac OS X 10.7.5
I have disabled the Firewall, shut off Bluetooth, and nothing else is connected via USB.