mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Changed ShellCommands from Console to Serial
This commit is contained in:
parent
0002863b90
commit
d612a6f2ee
@ -1,26 +1,41 @@
|
|||||||
|
|
||||||
/* Demonstrate shell commands */
|
/*
|
||||||
|
Running shell coommands using Process class.
|
||||||
|
|
||||||
|
This sketch demonstrate how to run linux shell commands
|
||||||
|
using an Arduino Yún.
|
||||||
|
|
||||||
|
The circuit:
|
||||||
|
* Arduino Yun
|
||||||
|
|
||||||
|
created 12 Jun 2013
|
||||||
|
by Cristian Maglie
|
||||||
|
modified 21 June 2013
|
||||||
|
by Tom Igoe
|
||||||
|
|
||||||
|
This example code is in the public domain.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
#include <Process.h>
|
#include <Process.h>
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
// initialize the Bridge and Serial connections:
|
||||||
Bridge.begin();
|
Bridge.begin();
|
||||||
Console.begin();
|
Serial.begin(9600);
|
||||||
Console.buffer(64);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Process p;
|
Process p;
|
||||||
// This command line prints the name of the wireless that the board is connected to or that the board has created
|
// This command line prints the name of the wireless network
|
||||||
|
// that the board is connected to, or the network which the board has created:
|
||||||
p.runShellCommand(F("lua /usr/lib/lua/pretty_wifi_info.lua | grep SSID"));
|
p.runShellCommand(F("lua /usr/lib/lua/pretty_wifi_info.lua | grep SSID"));
|
||||||
|
|
||||||
// Read command output
|
// Read command output
|
||||||
while (p.available()) {
|
while (p.available()) {
|
||||||
char c = p.read();
|
char c = p.read();
|
||||||
Console.print(c);
|
Serial.print(c);
|
||||||
}
|
}
|
||||||
Console.flush();
|
while (true); // do nothing more
|
||||||
|
|
||||||
delay(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user