[USART] Introduce a way to send a file as binary stream
Overview
After a HIL simulation is completed, we would like for the log file to be streamed back to the connected PC for easier post-processing of the simulation.
The project will need an initial brief study of how the HIL communication with the PC works, which should be contained in the src/shared/hil/HILTransceiver.h
file.
After the initial learning phase, a new public member function of the USART
class (not USARTInterface
) should be introduced, with the following signature:
bool USART::writeFile(const std::string& filename) {
...
}
The first implementation of the function should open the file by instantiating an std::ifstream
, read pre-sized chunks of the file onto a temporary buffer, and send the chunks via write()
member function.
The function should return false
if the file was not found or if it could not be opened. It should return true
otherwise.
Testing
Testing should be performed as appropriate to ensure the first implementation can get the file through and can be read on the other side. This also means a way to read that file over USART should be developed, either on a PC or on some other development board.
Further improvements (optional)
To ensure maximum efficiency and transmission speed, new write functions for avoiding intermediate copies may be introduced in the USART driver, as the current ones might not be fit for this job. This will need further research as it might not be needed.