Reputation: 25
I want to make a system call out of a Matlab Simulink model running on external hardware. In my case I want to switch the original Raspberry Pi Touch Display (7") off and an.
I tried using a Matlab function with a Matlab "system" command but it just doesn't have any affect on the display (the system calls itself works with the terminal).
function display_backlight(old_status)
coder.extrinsic('system')
if old_status == 1
system('echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power')
else
system('echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power')
end
end
Any ideas how to make this work or do I need to use another block like mentioned here System call from Simulink possible? (Link in the answer doesn't work)
Or do I even have to write this in C and integrate this to Simulink?
Upvotes: 0
Views: 337
Reputation: 21
The MATLAB system
function is not codegen capable. So if you use system
within a MATLAB function block, it will not generate code and so there won't be any effect.
You should create a new block if you want something as mentioned in the question.
Upvotes: 0
Reputation: 25
This is my solution as it won't work directly from a matlab simulink block:
#include <display_backlight_on.h> char command[50]; void display_backlight_on_command(boolean_T turn_on) { if (turn_on == 1) { strcpy( command, "echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power" ); system(command); } }
Upvotes: 1