mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
moved from Console to Serial output in Yun Process example
This commit is contained in:
parent
42d7b1d85a
commit
f9989cce62
@ -7,22 +7,21 @@
|
|||||||
created 5 Jun 2013
|
created 5 Jun 2013
|
||||||
by Cristian Maglie
|
by Cristian Maglie
|
||||||
|
|
||||||
|
This example code is in the public domain.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Process.h>
|
#include <Process.h>
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Setup Bridge (needed every time we communicate with the Arduino Yún)
|
// Initialize Bridge
|
||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
|
|
||||||
// Setup Console
|
// Initialize Serial
|
||||||
Console.begin();
|
Serial.begin(9600);
|
||||||
// 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.
|
// Wait until a Serial Monitor is connected.
|
||||||
while (!Console);
|
while (!Serial);
|
||||||
|
|
||||||
// run various example processes
|
// run various example processes
|
||||||
runCurl();
|
runCurl();
|
||||||
@ -34,37 +33,38 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void runCurl() {
|
void runCurl() {
|
||||||
// Launch "curl" command and get Arduino asciilogo from the network
|
// Launch "curl" command and get Arduino ascii art logo from the network
|
||||||
|
// curl is command line program for transferring data using different internet protocols
|
||||||
Process p; // Create a process and call it "p"
|
Process p; // Create a process and call it "p"
|
||||||
p.begin("curl"); // Process should launch the "curl" command
|
p.begin("curl"); // Process that launch the "curl" command
|
||||||
p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
|
p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
|
||||||
p.run(); // Run the process and wait for its termination
|
p.run(); // Run the process and wait for its termination
|
||||||
|
|
||||||
// Print arduino logo over the console.
|
// Print arduino logo over the Serial
|
||||||
// A process output can be read with the stream methods
|
// A process output can be read with the stream methods
|
||||||
while (p.available()>0) {
|
while (p.available()>0) {
|
||||||
char c = p.read();
|
char c = p.read();
|
||||||
Console.print(c);
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
// Ensure the latest bit of data is sent.
|
// Ensure the last bit of data is sent.
|
||||||
Console.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runCpuInfo() {
|
void runCpuInfo() {
|
||||||
// Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU)
|
// Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU)
|
||||||
Process p;
|
// cat is a command line utility that shows the content of a file
|
||||||
p.begin("cat");
|
Process p; // Create a process and call it "p"
|
||||||
p.addParameter("/proc/cpuinfo");
|
p.begin("cat"); // Process that launch the "cat" command
|
||||||
p.run();
|
p.addParameter("/proc/cpuinfo"); // Add the cpuifo file path as parameter to cut
|
||||||
|
p.run(); // Run the process and wait for its termination
|
||||||
|
|
||||||
// Print command output on the Console.
|
// Print command output on the Serial.
|
||||||
// A process output can be read with the stream methods
|
// A process output can be read with the stream methods
|
||||||
while (p.available()>0) {
|
while (p.available()>0) {
|
||||||
char c = p.read();
|
char c = p.read();
|
||||||
Console.print(c);
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
// Ensure the latest bit of data is sent.
|
// Ensure the last bit of data is sent.
|
||||||
Console.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user