2 Replies Latest reply on Jan 15, 2015 8:46 AM by TinkerTailorSolderSpy

    Eclipse, Python and Remote Edison SSH connection

    TinkerTailorSolderSpy

      The tutorials for how to setup Eclipse to build and run C/C++ programs remotely agains Edison is great, has anyone managed to do the same for Python?

      (my assumption is that to move beyond Hello and blink with python it makes sense to develop the code in Eclipse with full Python language support first. Then periodically remotely push it to Edison)

       

      Follow up questions:

           - do I need to install PyDev for Eclipse (I'm guessing yes)

           - what about Edison specific Python libraries? (i.e. mraa)

       

      Thanks...

        • 1. Re: Eclipse, Python and Remote Edison SSH connection
          mhahn

          right now there is no IDE support for Python.

          On PyDev: You might be able to get syntax checking to work (although in the current Eclipse IDE pretty much all python is removed - so you would have to add the required python packages). However, as far as I can see PyDev doesn't support remote execution. I.E. in order to test your code you'd have to execute & test your program outside the PyDev window containing your code.

          • 2. Re: Eclipse, Python and Remote Edison SSH connection
            TinkerTailorSolderSpy

            Thanks, that's what I suspected.

             

            I was thinking last night that I could trick Eclipse to copy over and run my python script rather than the compiled C or C++ binary. After a couple of minutes this morning I've got a pretty clean project setup with my python code in the src folder of the host C project and two run configurations called "hello_gpio (local)" and "hello_gpio (remote)". The local one is using PyDev and the remote one is "parasitizing" on the SSH connection for the C app (I'm using the 1_c_helloword project). I had to create a wrapper module called mraa.py that implements some proxy code to avoid local errors.

            For the remote connection all I did was change the "C/C++ Application" field in the run configuration dialog to: src/hello_gpio.py and the "Remote Absolute File Path for C/C++ Application:" to: /home/root/hellop_gpio.py (no need to run chmod 755 before executing, so leave the "Commands to execute before application" empty).

             

            Is there a simple way to compile and use the actual mraa_master project for Python on your Laptop? (I'm using a MacbookPro)

             

            Meanwhile here's the minimal version of the mraa proxy, just enough to run the hello_gpio.py example from the GitHub mraa project:

             

            #!/usr/bin/env python

            # mraa.py

            # Proxy API module for running python scripts outside of Edison

             

            # gpio_dir_t enums

            DIR_OUT = 0

            DIR_IN = 1

             

            # mraa_result_t enums

            MRAA_SUCCESS = 0

             

            def getVersion():

                return 'v0.5.4-79-gc3e43e5'

              

            # Dummy class to avoid errors when running mraa enabled scipts on your laptop

            class Gpio:

                def __init__(self, pin, owner=True, raw=False):

                    self.m_gpio = None

              

                def dir(self, dir):

                    return MRAA_SUCCESS

              

                def read(self):

                    return 0

              

                def write(self, value):

                    return MRAA_SUCCESS