Is it possible to use interrupt on the pin19 (RX Serial1) of Mega2560 to update some global variables, that will be used in various places inside the loop ?
I want update variables as soon they are received from UART.
Yes.
The serial ports on the Mega are already interrupt driven. You will have to disable that if you want to write your own ISR.
If you write non-blocking code, you don't need interrupts to read the serial port in the user code.
Yes. I understand that the serial ports already have interrupts and that the data is stored in the buffer. However, the variables are not updated automatically. I would need to convert the buffer data to the corresponding variable types each time. Furthermore, by the time the conversion was carried out, new data could have arrived that would not be updated as the buffer would already be filled with old data. So, ideally, receiving data and updating variables would occur in the background.
You're overthinking this, in my opinion... because the data received arrives serially, you don't want to be interrupted every time a new byte arrives. You want that function to run everytime A certain byte arrives (the one telling you that the message ended). And for that, you have to create your interrupt routine to check for that character.
Either way, manipulating strings inside an interrupt is a recipe for disaster as it'll block the processor for a while and there's always a chance of corruption or missing characters arriving (because you either don't deactivate the interrupt or you do).