Adding C module to rom in eLua 0.10

classic Classic list List threaded Threaded
5 messages Options
grahams grahams
Reply | Threaded
Open this post in threaded view
|

Adding C module to rom in eLua 0.10

Hi All,

I'm trying to add a C module to my 0.10 eLua rom image.  I've used the instructions at http://wiki.eluaproject.net/Tutorials/cmodules as a guide but I do not understand how to add my module to the rom.  I can see that my module has been compiled and has an entry in the .map file.  When I try and access it on my development board though I get an "attempt to index global 'json' (a nil value)" error.  Can anyone point out what I've failed todo?

Thanks,

Graham.
jbsnyder jbsnyder
Reply | Threaded
Open this post in threaded view
|

Re: Adding C module to rom in eLua 0.10

Hi,

That tutorial needs to be updated since it is written for the older SCons-based build system.  The newer Lua-based build system handles things a bit differently.

At this point I believe you may only need to extend the elua_generic_modules table in conf/modules.lua (https://github.com/elua/elua/blob/master/config/modules.lua#L25), by adding, a line like:
json = {},

Let me know if that works.

Best.

-jsnyder

On Tue, Mar 24, 2015 at 11:30 AM, grahams [via eLua Development] <[hidden email]> wrote:
Hi All,

I'm trying to add a C module to my 0.10 eLua rom image.  I've used the instructions at http://wiki.eluaproject.net/Tutorials/cmodules as a guide but I do not understand how to add my module to the rom.  I can see that my module has been compiled and has an entry in the .map file.  When I try and access it on my development board though I get an "attempt to index global 'json' (a nil value)" error.  Can anyone point out what I've failed todo?

Thanks,

Graham.


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



--
James Snyder
ph: (847) 448-0386
grahams grahams
Reply | Threaded
Open this post in threaded view
|

Re: Adding C module to rom in eLua 0.10

I think I may be nearly there,

Adding "json = {}" made a difference but has not fixed it.  When I start lua from the terminal I now get "lua: attempt to index a function value" output and the lua interrupter fails to start.

Graham
jbsnyder jbsnyder
Reply | Threaded
Open this post in threaded view
|

Re: Adding C module to rom in eLua 0.10

Hi Graham,

Could you provide the luaopen & map definitions from your file?  I suspect the issue might be there.  Also, are you running a script or just starting up the Lua prompt with no arguments?

If you can't provide that, see the other modules in src/modules for how these portions should be set up.

I was able to take the tutorial on the wiki and with a few minor edits plus what I recommended I had it working in the image.  I've saved a few quick changes to that to be more consistent with the current build system.

Best.

-jsnyder



On Tue, Mar 24, 2015 at 12:29 PM, grahams [via eLua Development] <[hidden email]> wrote:
I think I may be nearly there,

Adding "json = {}" made a difference but has not fixed it.  When I start lua from the terminal I now get "lua: attempt to index a function value" output and the lua interrupter fails to start.

Graham


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



--
James Snyder
ph: (847) 448-0386
grahams grahams
Reply | Threaded
Open this post in threaded view
|

Re: Adding C module to rom in eLua 0.10

It looks like I was registering the function incorrectly in the luaopen_json() function.  I was not using the LREGISTER macro.  Thank you for updating the wiki and your help.

Graham.