2 Replies Latest reply on Jan 17, 2017 4:56 PM by Intel Corporation

    Starting Socat, Python script and Arduino sketch on boot

    Matafaka

      Hello,

       

      I have migrated a project of mine from a Raspberry + Arduino to the Edison.

      It was a python script communicating with the Arduino over serial. This worked like a charm, but took too much space.

       

      To migrate it without having to rewrite the code I found Socat as a solution from this guide: http://www.instructables.com/id/Intel-Edison-Arduino-serial-to-Host-process-serial/ .

      This also works like a charm, but... I am not able to get this to run on boot. I need to start it manually to get it to work.

       

      The python script starts fine, but the socat does not start properly and causing the python script to fail when trying to start serial connection.

      Keep in mind that this works fine when starting the python script from command line.

       

      Socat command

      socat pty,link=$HOME/tty0,raw,echo=0 pty,link=$HOME/tty1,raw,echo=0
      

       

      Python connection

      ser = serial.Serial('/home/root/tty1', 115200, timeout=1)
      

       

      Arduino connection

      RingBuffer rx_buffer_S1;
      TTYUARTClass mySerial(&rx_buffer_S1, 3, false);
      mySerial.init_tty("/home/root/tty1");
      mySerial.begin(115200);
      

       

      Systemd script for boot

      [Unit]
      Description=My Script Service
      After=multi-user.target
      
      [Service]
      Type=idle
      ExecStart=/usr/bin/python /home/root/mata.py
      WorkingDirectory=/home/root
      
      [Install]
      WantedBy=multi-user.target
      

       

      Why is it not running on boot?

      I'd be happy to provide more information if needed.

      Any suggestions is appreciated

       

      Thanks