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

5 次查看(过去 30 天)
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

采纳的回答

Murat Belge
Murat Belge 2014-12-3
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 个评论
Saffet
Saffet 2014-12-4
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 ?

请先登录,再进行评论。

更多回答(2 个)

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

Michael Barbosa
Michael Barbosa 2019-7-24
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

类别

Help CenterFile Exchange 中查找有关 Run on Target Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by