4 Replies Latest reply on Feb 4, 2015 10:14 AM by CMata_Intel

    Intel Galileo Python Interface - pass data to variable

    Florian_Schuele

      I am working on a gardening system with the Intel Galileo platform. I'm using local sensor data in combination with forecasts from openweathermaps. To display the results, I use Paraimpu to generate Twitter messages containing the sensor data. So far, so good. I'm now looking for a way to let my system react to incoming tweets that contain a certain trigger word. I managed to write a python script using Twython that checks for this trigger word. If there is a new tweet (during the last minute), the python script returns 1, if not 0.

      [...]

      if timedelta<triggertime:

      erg = 1 #New Tweet with trigger word detected

      else:

      erg = 0 #No new Tweet detected

      print erg

      And here I'm stuck: When I call the python script itself, it works just fine. But when using the system function in the arduino code, I don't get the number, just some weird formatted stuff like: |cßBð¿ That's how I call the system function in my arduino code:

      char* checkTweets() {

      char result[1];

      system("python /media/realroot/Files/tweetcheck.py > /media/realroot/result.txt");

      FILE *tempFile; tempFile = fopen("result.txt", "r");

      fgets(result, 1, tempFile);

      fclose(tempFile);

      return (result); }

      I want to store the result of the python script as the value of an integer variable. Is that possible? I'm not very experienced in the Arduino / Python Interface - Thank you for any suggestions!