Yes, you can recover the firmware in 16u2 only with Arduino IDE installed. In subfolder hardware/arduino/avr/firmwares/atmegaxxu2/ of the IDE installation folder is the hex file of the firmware Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex. The README.txt file in that folder has sample command line to upload the firmware with avrdude.
No, only the ATmega328P has access to the external pins of the Uno. You would need to write code for both the '328P and the '16U2 to communicate the pin values and changes over serial since that is the only channel connecting the MCUs.
You have quite a few options available to you as your requirements are filled by quite a few protocols, I am not going to list all. You can use things such as I2C, CAN, RS-485, RS-232.
You can find a few good examples from this EE.SE post from a search.
The CAN option is quite a good one for your application and is easy to set up and there are quite a few ...
Your RESET circuit is wrong.
You have no pullup resistor on the RESET pin of the ATMega3560.
You have an extraneous pulldown resistor on the D7 pin of the 16U2.
That means your 16U2 will not be able to trigger a reset of the ATMega2560 to run the bootloader.
Remove the pulldown on D7 of the 16U2 and add a 10kΩ pullup to the RESET pin of the ATMega2560. ...
A detailed how to is here its for the ATMega16 but check connections with the circuit diagram.
Use this command for backup of flash
avrdude -c avrisp2 -p m16 -P /dev/ttyUSB0 -b 115200 -U flash:r:Old_flash_backup_file.hex:h
Backup EEPROM (just in case there is something stored there)
avrdude -c avrisp2 -p m16 -P /dev/ttyUSB0 -b 115200 -U eeprom:r:...
If you use the appropriate buffering of the 0/5V signal over the long wires, case A, no error detection and correction is needed. RS232, RS485, your data will be just fine (can be up to thousands of feet).
Shorter wires, from Atmega device to Atmega device, I've neved had to use anything, even at 115200 speeds, case B, case C.
16U2 to PC, that will ...
It depends on the exact arduino product. An Arduino Uno has a USB programmer chip, that then programs the AtMega 328 Chip. If the programmer is broken, it will likely not register any device when you plug in an arduino uno to your PC.
if the micro-controller is dead, but the programmer is operational, you will get a device in your device manager, but not ...
As per your diagram, ground the reset pin on both Arduinos and connect TX to RX on the one to RX to TX on the other. Alternatively, if your Unos have a socketed 328P, you can remove it.
(This answer summarized from the comments above in order to take it off the "unanswered" list.)
Without more detail about the system, I won't understand what printf() does; in non-embedded systems, printf() writes to stdout by default, but Arduino systems typically don't use such a device.
That aside, %d is the proper format code for printing an integer value, and %f is proper for a float or double. If you attempt to print an integer value like ...
What I think is happening here is that the HWBE fuse is set (hardware boot enable).
From the datasheet:
The Hardware Boot Enable Fuse (HWBE) can be programmed so that upon
special hardware conditions under reset, the bootloader execution is forced after reset.
What this means is that under normal booting (power-on reset) the bootloader is not entered,...