diff options
Diffstat (limited to 'libraries/Bridge/examples/Process/Process.ino')
-rw-r--r-- | libraries/Bridge/examples/Process/Process.ino | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/libraries/Bridge/examples/Process/Process.ino b/libraries/Bridge/examples/Process/Process.ino index 248db39..25e45c7 100644 --- a/libraries/Bridge/examples/Process/Process.ino +++ b/libraries/Bridge/examples/Process/Process.ino @@ -1,25 +1,61 @@ +/* + Running process using Process class. + + This sketch demonstrate how to run linux processes + using an Arduino Yún. + + created 5 Jun 2013 + by Cristian Maglie + + */ + #include <Process.h> void setup() { - pinMode(13,OUTPUT); - digitalWrite(13,LOW); - - Serial.begin(9600); + // Setup Bridge (needed every time we communicate with the Arduino Yún) Bridge.begin(); + // Setup Console + Console.begin(); + Console.buffer(64); + // Wait until a Network Monitor is connected. + while (!Console); + + // run various example processes + runCurl(); + runCpuInfo(); +} - digitalWrite(13,HIGH); - delay(2000); - +void loop() { + // Do nothing here. +} + +void runCurl() { + // Launch "curl" command and get Arduino asciilogo from the network Process p; p.begin("curl"); p.addParameter("http://arduino.cc/asciilogo.txt"); p.run(); - + + // Print arduino logo over the console while (p.available()>0) { char c = p.read(); - Serial.print(c); + Console.print(c); } + Console.flush(); } -void loop() { +void runCpuInfo() { + // Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU) + Process p; + p.begin("cat"); + p.addParameter("/proc/cpuinfo"); + p.run(); + + // Print command output on the Console + while (p.available()>0) { + char c = p.read(); + Console.print(c); + } + Console.flush(); } + |