Why cannot data be written to a file on Raspberry pi when it is working standalone, i.e when executable, created with the use of simulink, on raspberry pi is run

3 Ansichten (letzte 30 Tage)
When I start real time code on simulink, the data extracted from audio capture block can be written to a file, by using "to file" block, on raspberry pi. ( external mode is selected and simulation stop time is adjusted as "inf") However, when it works standalone, i.e when I run executable, created by simulink, on raspberry pi, no data is written to the file. It is empty in all cases. It appears the executable works but no new data is written to the file, although the file is created on the relevant directory. I also checked the following link but haven't not solved the problem yet http://www.mathworks.com/matlabcentral/answers/112443-build-standalone-application-running-in-raspberry-pi
Any help is appreciated

Akzeptierte Antwort

Murat Belge
Murat Belge am 3 Dez. 2014
The To File block does not generate any code (i.e. a no-op block) when the Simulink model is run as a stand-alone application. This is similar to other sink blocks such as a Scope. This block works only in Simulation. Since External Mode is a simulation mode, the block works in External Mode.
In stand alone mode, the Simulink model runs indefinitely (i.e. there is no stop time) on Raspberry Pi. So a MAT-file cannot be generated.
  1 Kommentar
Saffet
Saffet am 4 Dez. 2014
Thank you Murat for your answer. Can you suggest me any other way (another block or something else) so as to write any data to a file in stadalone mode, or there is no way by using stadalone mode in simulink ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Lara Zubaidia
Lara Zubaidia am 1 Apr. 2016
hello Saffet I wonder If You have solved the problem and what was the solution for it ? Any Suggestion please?

Michael Barbosa
Michael Barbosa am 24 Jul. 2019
Hello,
I have a similar problem. In standalone mode my program not wirite in a created file.
function creatFILE() %#codegen
% Create a Raspberry Pi object
r = raspi('169.254.0.2','pi','matlab');
data_atual = strip(system(r, 'date +"%d_%b_%y_%H_%M_%S"'));
doc_name = "Documents/dataLOG_" + data_atual;
system(r, convertStringsToChars("touch " + doc_name));
system(r, convertStringsToChars("sudo chown pi:pi " + doc_name));
system(r, convertStringsToChars("sudo chmod 777 " + doc_name));
for count = 1:100
system(r, 'sleep 0.5');
nanosegundos = strip(system(r, 'date +"%H_%M_%S_%N"'));
system(r, convertStringsToChars("echo " + nanosegundos + " >> " + doc_name));
system(r, 'sleep 0.5');
nanosegundos = strip(system(r, 'date +"H_%M_%S_%N"'));
system(r, convertStringsToChars("echo " + nanosegundos + " >> " + doc_name));
end
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by