Avrdude intermittent problem (Mega2560)

Hi

Same issue, sometimes works fine (90% of the time, it works every time).

Here´s the error when I try to flashg when it´s in a non-responsive state.

avrdude -c wiring -P com12 -p atmega2560 -b115200 -U flash:w:minus1.hex:i
avrdude: ser_open(): can't set com-state for "\.\com12"
avrdude: ser_drain(): read error: Controlador no vßlido.

The problem can be resolved by replugging the USB. I was looking into a way with "mountvol com12 /d" "mountvol com12" to mimic this reset everytime, but as the arduino board isn´t a volume I didn´t find a way to do this.

Any ideas appreciated.

Cheers!