From 48a4f76e4271567a7c7649c507668e23345190c3 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 5 Jun 2013 14:51:15 +0200 Subject: Updated some Bridge examples --- libraries/Bridge/examples/Process/Process.ino | 56 ++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'libraries/Bridge/examples/Process/Process.ino') 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 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(); } + -- cgit v1.2.3-18-g5258