Serial port already in use.

I am using a leonardo and for some reason I can only upload sometimes to it. I've noticed it happens usually only when I have serial communication happening, I am assuming its because leonardo continues to read serial even when window is closed.

I am on OSX and have tried two things:

  1. adding delay in setup of 5seconds so I could try a reboot and upload right after its been rebooted.
  2. this suggestion http://www.baldengineer.com/blog/2012/10/08/arduino-fixing-serial-port-in-use/

not sure what else it could be. any ideas on fixing this? It only happens with leonardo.

hilukasz:
I am assuming its because leonardo continues to read serial even when window is closed

No, that doesn't make sense. "Serial port in use" is on the PC side, not the Leonardo's side.

If you load Blink on the Leonardo and keep trying to reload it, do you still get the serial port in use?

hilukasz:
2. this suggestion http://www.baldengineer.com/blog/2012/10/08/arduino-fixing-serial-port-in-use/

Yeah, I wrote that with the Uno and Mega in mind. The Leonardo is different. Although, it would be good to use lsof to find out what is holding the port open (something has to be).

nope, like i mentioned earlier, it only happens when I have serial communication it seems, simple sketches like blink don't seem to have an affect.

hilukasz:
nope, like i mentioned earlier, it only happens when I have serial communication it seems, simple sketches like blink don't seem to have an affect.

Okay then load something with serial communication and run lsof to find out what is keeping the port open. Again, if you're getting "serial port in use" that means some process is holding it open.