I am trying to use Process.h library to run a shell command. Here is my code. I am using Arduino Uno.
#include <Process.h>
#include <Bridge.h>
void setup() {
// Initialize Bridge
//Bridge.begin(115200);
// Initialize Serial
Serial.begin(115200);
// Wait until a Serial Monitor is connected.
while (!Serial);
// run various example processes
runPythonFunction();
}
void loop() {
// Do nothing here.
}
void runPythonFunction() {
Process p; // Create a process and call it "p"
//p.begin("/usr/bin/python /home/kairos/Arduino/codes/sketch_jan26a/tweet.py");
p.runShellCommandAsynchronously("/usr/bin/python -U /path/to/tweet.py"); // Run the process and wait for its termination
//p.run();
// Print command output on the SerialUSB.
// A process output can be read with the stream methods
while(p.available() > 0) {
char c = p.read();
Serial.print(c);
}
// Ensure the last bit of data is sent.
Serial.flush();
delay(300000);
}
If I do not comment the Bridge.begin() line, then in monitor display reverse question marks are displayed. And after commenting that, I am getting some garbage on the serial monitor. Also, my python script makes a new file in the same directory, which runs fine if I run it using a terminal. But if I run it using Arduino code, I am not able to see that new file being generated.
Even using p.begin() and p.run()it does not run. Nor using p.runShellCommandAsynchronously().
So how can I run that python script?