[ell-i-developers] Re: Robot Framework Testing: Test Cases Design, Scripting and other Issues

  • From: Pekka Nikander <pekka.nikander@xxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Sun, 27 Apr 2014 16:42:51 +0300

> May I get some help regarding linking the c-python modules against the 
> emulator? I cannot call the Arduino functions directly from c-python code 
> files without linking against emulator and stm32 cores.

I had a brief look at this today.  While I cannot present a full solution, I 
think I made some progress.

The first thing is to get the c-python modules in the 
arduino-functions/Digital-I-O to include the right subdirectories from the 
Runtime.  The following in setup.py seems to work as a first approximation:

---------------
from os import path

runtime='/my/path/to/Runtime'

arduelli   = path.join(runtime, 'cores/arduelli')
system_inc = path.join(runtime, 'system/stm32/inc')
cmsis      = path.join(runtime, 'system/stm32/CMSIS/Include')
variant    = path.join(runtime, 'variants/ellduino')

include_dirs=[arduelli, system_inc, cmsis, variant]

setup(name='digitalRead', version='1.0',
      ext_modules=[Extension('digitalRead',
                             ['Digital-I-O/digitalRead.c'],
                             include_dirs=include_dirs)])
--------------------

The key there is the include_dirs in creating the Extension. See 

  https://docs.python.org/2.7/distutils/setupscript.html

for more information. 

With that you can include <wiring_digital.h> in digitalRead.c, but note that it 
must be included *before* including <Python.h>.  That then allows you to call 
the actual Runtime functions, and it compiles.  Python also tries to load the 
resulting shared library, but that fails.

The next step would then be to actually add the emulator functions to the 
python runtime.  That I don't know yet how to do exactly, but I imagine that it 
would be best to compile the emulator into a shared library, through adding a 
new make target in Runtime/stm32/make, and then including the shared library 
into the (DY)LD_LIBRARY_PATH.  That might suffice.

--Pekka

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Other related posts: