2013-06-12 13:28:24 +02:00
|
|
|
|
2013-06-22 08:03:35 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2013-06-12 13:28:24 +02:00
|
|
|
|
|
|
|
#include <Process.h>
|
|
|
|
|
|
|
|
void setup() {
|
2013-06-22 08:03:35 +02:00
|
|
|
// initialize the Bridge and Serial connections:
|
2013-06-12 13:28:24 +02:00
|
|
|
Bridge.begin();
|
2013-06-22 08:03:35 +02:00
|
|
|
Serial.begin(9600);
|
2013-06-12 13:28:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
Process p;
|
2013-06-22 08:03:35 +02:00
|
|
|
// This command line prints the name of the wireless network
|
|
|
|
// that the board is connected to, or the network which the board has created:
|
2013-06-18 16:42:24 +02:00
|
|
|
p.runShellCommand(F("lua /usr/lib/lua/pretty_wifi_info.lua | grep SSID"));
|
2013-06-12 13:28:24 +02:00
|
|
|
|
|
|
|
// Read command output
|
|
|
|
while (p.available()) {
|
|
|
|
char c = p.read();
|
2013-06-22 08:03:35 +02:00
|
|
|
Serial.print(c);
|
|
|
|
}
|
|
|
|
while (true); // do nothing more
|
2013-06-12 13:28:24 +02:00
|
|
|
}
|
|
|
|
|