A bit of a long post, but I'm wondering if I'm on the right track and if you have any recommended approaches, since I've spent the past few days looking through documentation and other forum posts about Simulink Compiler and haven't found too much information on this subject. The short version is that I would like to display messages in the command prompt while the simulation is running, and once the simulation is over, save those messages to a log file, as well as saving a variety of signals to a different file.
1) I'm working on a simulink project that contains s-functions containing C++ code as well as matlab function blocks. I have been using functions inside my C++ code and matlab code that print messages (sprintf, disp, etc) for the sake of seeing the contents of certain variables, but also as a way to log events occurring inside the blocks. However, it appears that once I've compiled my project into an .exe file and run it from a command prompt window, those printouts don't show up and I haven't found any docs explaining how to print debug/warn/error messages from the .exe file.
2) I know there are a few ways to log signals from the model to the workspace for use during the simulation. From what I gather, doing this by clicking on the signal in the model and selecting 'log signal' doesn't work for Simulink Compiler, so instead I would need to use a block like 'to workspace' or 'record'. I also saw that I can print things to the command prompt in the deploy .m file used by Simulink Compiler, and I can do this during the simulation using a postStepFcn (and other similar callbacks), which lets me print the simulation timestep and state. But for signals, I got this error:
simulink.compiler.getSimulationOutput is not supported with 'LoggingToFile' is set to 'on'"
So it seems like there's a conflict between logging while the sim is running, and saving files containing signals? From what I've seen, there are 3 methods to save signals to a file: set LoggingToFile in the model's import/export settings, use a 'to file' block, or use a 'record' block. Perhaps I should be using the record block? My concern there is that I would like to log a bunch of signals from different blocks, but it seemed like I shouldn't be using more than one record block in a model and so I would need to route many signals into it.