Leonardo doesn't send to Serial Monitor after software reset

I have Arduino 1.01 and a Leonardo with an Ethernet shield (R3). My sketch is designed to do a reset if there is a communication problem, to test this I just unplug the cable from the Ethernet shield. The Arduino resets using asm volatile (" jmp 0");
The reset works fine and the Arduino continues uploading to COSM.com via the Ethernet shield, but if I had the serial monitor open, I don't see any text after the reset. Even if I close the serial monitor and re-open it, still nothing. I know the Leonardo works a little differently then the UNO with the serial monitor. Is there anything I can do to get the Arduino to recognize the serial monitor after a reset. The serial monitor works fine when I upload a new sketch, it's just after a reset I have a problem. I had also tried resetting with the Watch Dog Timer, and I have the same serial monitor issue with that method also. If I close the serial monitor then do a hard reset (using the PCB pushbutton), the serial monitor works again.

Jumping to the Reset vector does not reset the hardware, it just starts the bootloader.

If you have a spare digital pin you might be able to perform an ACTUAL reset by connecting the digital pin to the Reset pin and setting that pin to LOW and OUTPUT.

If you have a spare digital pin you might be able to perform an ACTUAL reset by connecting the digital pin to the Reset pin and setting that pin to LOW and OUTPUT.

No that will not work. As soon as the reset is activated, the output goes tristate and removes the reset so it will not reset correctly.

@OP :- Is is bad code that requires a hardware reset, you are best writing it correctly.

I'm surprised that it doesn't work when you use the watchdog timer. Can you provide more details (e.g. a sample sketch and the behavior you see)?

On the other hand, a "jmp 0" might not work, because it doesn't necessarily shutdown / re-initialize the registers / peripherals / USB connections. On the Uno, the USB-serial connection is done by a separate chip, so you the connection will stay up regardless of what you do to the main processor (ATmega328). On the Leonardo, there's just one chip, so you have to be more careful about maintaining the USB connection.

I found this small routine that forces the Watchdog Timer to perform a reset:

void SlapTheWatchdog(void) 
{ 
    WDTCR=0x18; 
    WDTCR=0x08; 
    #asm("wdr") 
    while(1); 
}

mellis:
I'm surprised that it doesn't work when you use the watchdog timer. Can you provide more details (e.g. a sample sketch and the behavior you see)?

Attached is my sketch. The watch dog timer is disabled, you'll need to uncomment // #define WDT on line 17 of Humidity_716Basement_v2.ino to enable the WDT.

Humidity_716Basement_v2.ino (8.33 KB)

WDT.ino (3.57 KB)

ScottG, how soon after the reset are you opening the Serial Monitor? If you open the monitor while the bootloader is running it will happily connect but then be orphaned when the bootloader ends and the sketch starts. Unfortunately there is no indication that this has happened, you just end up with a monitor window that is attached to a port that doesn't exist anymore.