MATLAB Answers

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

조회 수: 4(최근 30일)
Saffet
Saffet 17 Sep 2014
답변: Michael Barbosa 24 Jul 2019
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

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Murat Belge
Murat Belge 3 Dec 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

Saffet
Saffet 4 Dec 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 ?

댓글을 달려면 로그인하십시오.

추가 답변(2개)

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

  댓글 수: 0

댓글을 달려면 로그인하십시오.


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

  댓글 수: 0

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by