-
1. Re: Include a python script in sketch folder
JPMontero_Intel Oct 10, 2014 9:48 AM (in response to X_Y)Hi X_Y,
I’m not following. Just to double check,you want to send a python script by using the IDE from your host computer, is this correct?
Regards,
JPMontero_Intel -
2. Re: Include a python script in sketch folder
mhahn Oct 10, 2014 4:05 PM (in response to X_Y)you can run any Linux process in parallel to the sketch.
However, you should put the native processes on the board and start them e.g. from within the sketch. There is no support to upload something in addition to the sketch. You would have to modify the scripts doing the uploading.
In order to communicate between Arduino and Yocto Linux you might use e.g. the approach described in IoT* - Efficient communication between Arduino* and Linux native processes | Intel® Developer Zone
-
3. Re: Include a python script in sketch folder
X_Y Oct 14, 2014 4:15 AM (in response to JPMontero_Intel)Hi JPMontero,
Yes, I'm wondering if it's possible to streamline the procedures of running native processes. Arduino sketches are uploaded pretty smooth now, but for native process, one needs to get a different cable(Ethernet or serial), install some extra software, go through a complicated setting and then run a bunch of commands. If I want to work on it with beginners or school kids, it's a pretty steep learning curve.
-
4. Re: Include a python script in sketch folder
JPMontero_Intel Oct 21, 2014 6:25 PM (in response to X_Y)Hi X_Y,
I apologize for the delay in my response. Take a look at the sketch below, in this way you can create, write, read and execute a python script from an Arduino sketch. I hope you find this helpful.
void setup() { // put your setup code here, to run once: FILE * fp; fp = fopen("/home/root/hello.py", "w"); fprintf(fp, "print \"Hello World!\"\n"); fprintf(fp, "print \"This is python script\"\n"); fclose(fp); delay(5000); Serial.begin(9600); system("python /home/root/hello.py > /dev/ttyGS0"); } void loop() { // put your main code here, to run repeatedly: }
Regards,
JPMontero_Intel -
5. Re: Include a python script in sketch folder
X_Y Oct 22, 2014 2:07 AM (in response to JPMontero_Intel)Hi JPMontero,
Thanks very much for the solution! Wondering if there're any problems(limitations, disk wearing etc.) associated with this approach?
-
6. Re: Include a python script in sketch folder
mhahn Oct 22, 2014 2:43 AM (in response to X_Y)well, surely you'll write to eMMC here. You might rather write to "/tmp" folder which resides in memory (i.e. "/tmp/hello.py" or so).
-
7. Re: Include a python script in sketch folder
X_Y Oct 22, 2014 3:45 AM (in response to mhahn)Thanks! Very helpful tip