aboutsummaryrefslogtreecommitdiff
path: root/libraries/Bridge/examples
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-06-05 20:20:18 +0200
committerCristian Maglie <c.maglie@bug.st>2013-06-05 20:20:18 +0200
commit2f547367fd58582e6f820fbf0bd6a276288bbc4a (patch)
tree55ec99c649759db43297a96f380c9621316ff431 /libraries/Bridge/examples
parent48a4f76e4271567a7c7649c507668e23345190c3 (diff)
Added comment to some examples
Diffstat (limited to 'libraries/Bridge/examples')
-rw-r--r--libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino5
-rw-r--r--libraries/Bridge/examples/Process/Process.ino21
2 files changed, 19 insertions, 7 deletions
diff --git a/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
index d547df7..4cdf4c1 100644
--- a/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
+++ b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino
@@ -29,7 +29,7 @@ void setup() {
Bridge.begin();
Console.begin();
- // Uncomment the followinf line to enable buffering:
+ // Uncomment the following line to enable buffering:
// - better transmission speed and efficiency
// - needs to call Console.flush() to ensure that all
// transmitted data is sent
@@ -81,6 +81,9 @@ void loop() {
// if printed last visible character '~' or 126, stop:
if(thisByte == 126) { // you could also use if (thisByte == '~') {
+ // ensure the latest bit of data is sent
+ Console.flush();
+
// This loop loops forever and does nothing
while(true) {
continue;
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();
}