SerialException with Arduino v1.0.2 and Leonardo

I am affraid it is caused by a fix I submitted for the problem described here: Google Code Archive - Long-term storage for Google Code Project Hosting..

Sorry for that.

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.

Could you submit a bug report?