Linking a module

classic Classic list List threaded Threaded
6 messages Options
Jorge Jorge
Reply | Threaded
Open this post in threaded view
|

Linking a module

I'm using a mbed board, and need to access the i2c bus (which is unsupported).

I have a gcc4mbed toolchain setup and can build images from c++ that use the mbed libraries to do stuff, including i2c.

Is there a quick and dirty way to have a couple of calls available for my Lua script?

My first attempt was to use the tutorial at http://wiki.eluaproject.net/Tutorials/cmodules, but when I include the headers from mbed the compiling fails because those are c++ and use namespeces and such. I tried to change gcc for g++ in eLua build scripts but seem to missing something. Is this method viable?

Or, perhaps, building a C library using lauxlib / lualib using the gcc4mbed chain and somehow linking to eLua is possible? gcc4mbed is using arm-none-eabi gcc 4.9.3. I'm working with eLua from git.

I know the proper solution would be to implement the i2c support, but i'm a bit overwhelmed right now :)

Thanks for any pointer.
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Linking a module

Hi,

Compiling any kind of C++ code in eLua would be quite a difficult at the moment, I'm afraid. Definitely not trivial. In any case, if you start working on a prototype, I'll try to help with that.

Thanks,
Bogdan
Jorge Jorge
Reply | Threaded
Open this post in threaded view
|

Re: Linking a module

And what about using the lua-c interface? The .so would be built with using g++, but the calls would be plain C as usual. Is that possible?

Thanks,
Jorge

On 26/10/15 10:13, BogdanM [via eLua Development] wrote:
Hi,

Compiling any kind of C++ code in eLua would be quite a difficult at the moment, I'm afraid. Definitely not trivial. In any case, if you start working on a prototype, I'll try to help with that.

Thanks,
Bogdan


If you reply to this email, your message will be added to the discussion below:
http://elua-development.2368040.n2.nabble.com/Linking-a-module-tp7578546p7578547.html
To start a new topic under eLua Development, email [hidden email]
To unsubscribe from eLua Development, click here.
NAML

BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: Linking a module

I've never used lua-c myself, so my answer can only be a strong "maybe" :) Sorry about that.
raman raman
Reply | Threaded
Open this post in threaded view
|

Re: Linking a module

In reply to this post by Jorge

Dear Jorge,

> I'm using a mbed board, and need to access the i2c bus (which
> is unsupported).

Great!

> Is there a quick and dirty way to have a couple of calls
> available for my Lua script?

I understand your problems with the C++ and C interwork. Like
Bogdan says, that might not be very straightforward. But how
about this?

I've never used an mbed but I'm sure eLua must have a port for
mbed.  This should also mean that the platform agnostic layer
already exists for mbed (atleast for gpio). specifically,
functions like `platform_pio_op' must already be implemented for
you.  Please look into src/platform/lpcxx/platform.c.

You can use these functions to write your own bit-banged i2c
driver in C. I'm sure you'll find many bit-banged i2c
implementations. You can then export that function as an eLua
module and use the it from your eLua script.

It's quick and dirty too! Hope that helps. Good luck!

R
Jorge Jorge
Reply | Threaded
Open this post in threaded view
|

Re: Linking a module

Hmmm, I didn't think about that possibility. I looked around for soft based i2c for mbed and din't find any, but I'll look into adapting one.

Thanks for the idea,

Jorge

On 29/10/15 01:59, raman [via eLua Development] wrote:

Dear Jorge,

> I'm using a mbed board, and need to access the i2c bus (which
> is unsupported).

Great!

> Is there a quick and dirty way to have a couple of calls
> available for my Lua script?

I understand your problems with the C++ and C interwork. Like
Bogdan says, that might not be very straightforward. But how
about this?

I've never used an mbed but I'm sure eLua must have a port for
mbed.  This should also mean that the platform agnostic layer
already exists for mbed (atleast for gpio). specifically,
functions like `platform_pio_op' must already be implemented for
you.  Please look into src/platform/lpcxx/platform.c.

You can use these functions to write your own bit-banged i2c
driver in C. I'm sure you'll find many bit-banged i2c
implementations. You can then export that function as an eLua
module and use the it from your eLua script.

It's quick and dirty too! Hope that helps. Good luck!

R


If you reply to this email, your message will be added to the discussion below:
http://elua-development.2368040.n2.nabble.com/Linking-a-module-tp7578546p7578550.html
To start a new topic under eLua Development, email [hidden email]
To unsubscribe from eLua Development, click here.
NAML