From 2f547367fd58582e6f820fbf0bd6a276288bbc4a Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 5 Jun 2013 20:20:18 +0200 Subject: Added comment to some examples --- libraries/Bridge/examples/Process/Process.ino | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'libraries/Bridge/examples/Process') diff --git a/libraries/Bridge/examples/Process/Process.ino b/libraries/Bridge/examples/Process/Process.ino index 25e45c7..919cea7 100644 --- a/libraries/Bridge/examples/Process/Process.ino +++ b/libraries/Bridge/examples/Process/Process.ino @@ -14,9 +14,13 @@ void setup() { // Setup Bridge (needed every time we communicate with the Arduino Yún) Bridge.begin(); + // Setup Console Console.begin(); + // Buffering improves Console performance, but we must remember to + // finish sending using the Console.flush() command. Console.buffer(64); + // Wait until a Network Monitor is connected. while (!Console); @@ -31,16 +35,19 @@ void loop() { 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(); + + Process p; // Create a process and call it "p" + p.begin("curl"); // Process should launch the "curl" command + p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl" + p.run(); // Run the process and wait for its termination - // Print arduino logo over the console + // Print arduino logo over the console. + // A process output can be read with the stream methods while (p.available()>0) { char c = p.read(); Console.print(c); } + // Ensure the latest bit of data is sent. Console.flush(); } @@ -51,11 +58,13 @@ void runCpuInfo() { p.addParameter("/proc/cpuinfo"); p.run(); - // Print command output on the Console + // Print command output on the Console. + // A process output can be read with the stream methods while (p.available()>0) { char c = p.read(); Console.print(c); } + // Ensure the latest bit of data is sent. Console.flush(); } -- cgit v1.2.3-18-g5258