aboutsummaryrefslogtreecommitdiff
path: root/libraries/Bridge/examples/Process/Process.ino
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-06-05 14:51:15 +0200
committerCristian Maglie <c.maglie@bug.st>2013-06-05 14:51:15 +0200
commit48a4f76e4271567a7c7649c507668e23345190c3 (patch)
treebaa90058912d9140b916e2451d8afacf2bb0b49d /libraries/Bridge/examples/Process/Process.ino
parent4306561e25f2a57c5f86f6cde22a1d306101487f (diff)
Updated some Bridge examples
Diffstat (limited to 'libraries/Bridge/examples/Process/Process.ino')
-rw-r--r--libraries/Bridge/examples/Process/Process.ino56
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();
}
+