I programmed a CAN Bus logger for the ESP32 with ESP-IDF.
Currently this is just one main program with one loop. In that loop data is read from the CAN-Bus receiver and written to one log file on a SD-Card.
Now I also want to receive data from the UART serial port. And that data should also be written to the same log file on the same SD-Card.
My question is: Should I just add a few lines in the existing loop to read the data from the UART and write it to the log file on the SD-Card? Or would it be better to separate the code in two or more tasks for reading the data from the CAN-Bus, reading the data from the UART, and writing it to the log file on the SD-Card?
I am not sure about the baud rate until now. But the data from the UART will be a lot less than from the CAN-Bus. So there will be maybe 10 or 100 log file lines from the CAN-Bus and then 1 line from the UART.
This question is about the principle if I should use FreeRTOS with multiple task to implement this or just one loop. Until now I think one loop is easier and better because then I control exactly what is happening in which order. And this is not complex, only a few lines. But obviously I ask here to get expert advice if my thinking about this makes sense.