I have the Tinkerboard/ROS-Core2 environment. I would like to run system shell commands.
Here’s a simple example. It compiles with no errors. The system command works on the command line.
The IDE allowed the system function. Is there’s a different syntax I need to use ?
If system shell commands work I will eventually configure festival for speech synthesis.
#include
#include
#include “hFramework.h”
#include “hCloudClient.h”
uint16_t v_int;
void send()
{
for (;
{
platform.printf(“asd %d\r\n”, sys.getRefTime());
sys.delay(1000);
}
}
void cfgHandler()
{
auto l = platform.ui.label(“l1”);
l.setText(“label1”);
auto b = platform.ui.button(“btn1”);
b.setText(“button1”);
b.setLocation(100, 100);
platform.ui.video.enable();
}
void onConsoleWrite(hId id, const char* msg)
{
}
void onKeyEvent(KeyEventType type, KeyCode code)
{
LED3.toggle();
UiButton b = platform.ui.button(“btn1”);
if (code == KeyCode::Up)
{
b.setLocation(20, 20);
}
else if (code == KeyCode::Down)
{
b.setLocation(20, 70);
}
}
void onButtonEvent(hId id, ButtonEventType type)
{
static int cnt = 0;
if (id == “btn1”)
{
UiButton b = platform.ui.button(“btn1”);
if (type == ButtonEventType::Pressed)
{
b.setText(“pressed %u”, cnt++);
}
else
{
b.setText(“released %u”, cnt++);
}
LED3.toggle();
}
}
void cloudTask() {
sys.delay(5000); //necessary to boot CORE2-ROS (with ASUS Tinker Board), for CORE2 can be commented
platform.begin(&RPi);
platform.ui.setProjectId("@@@PROJECT_ID@@@");
platform.ui.configHandler = cfgHandler;
platform.ui.onKeyEvent = onKeyEvent;
platform.ui.onButtonEvent = onButtonEvent;
platform.ui.onConsoleWrite = onConsoleWrite;
// UiButton b = platform.ui.button("btn1");
hSens1.pin1.enableADC();
sys.taskCreate(send);
while(1) {
sys.delay(500);
LED3.toggle();
// platform.ui.label("l1").setText("uptime %u", (unsigned int)sys.getRefTime());
v_int = hSens2.pin1.analogReadRaw();
platform.ui.label("l1").setText("Sensor raw output = %d\r\n", v_int);
}
}
void hMain()
{
sys.taskCreate(cloudTask);
for (;;)
{
sys.delay(500);
LED1.toggle();
if ( v_int > 1200 )
{
system ("/usr/bin/mpg123 /home/husarion/Sound/announce/front-left-sensor.mpg");
}
}
}