Quantcast

STM32F4

classic Classic list List threaded Threaded
14 messages Options
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

STM32F4

I have got elua running on the 407 discovery board with the latest from Git. Really nice.  Is there a newer tutorial or instructions on adding a module to the build? The tutorial on the site references files I cannot find.

Bill


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Richard Möhn Richard Möhn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

On Thu, Nov 28, 2013 at 09:42:24AM -0600, Bill wrote:
> I have got elua running on the 407 discovery board with the latest from
> Git. Really nice.  Is there a newer tutorial or instructions on adding a
> module to the build? The tutorial on the site references files I cannot
> find.
>
> Bill


Hi Bill,

what do you mean by "adding a module to the build"? If you want to write
your own platform module in C and build it with eLua, I could give you
some advice since I've done that multiple times for a board similar to
the Discovery board.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

In reply to this post by tobor
I have a piece of hardware with a large communication protocol that exists in C that would be easier to just add a simple API for the user in elua. I would not want to have to support 2 versions of the protocol.

Bill



On Thu, Nov 28, 2013 at 1:53 PM, Richard Möhn <[hidden email]> wrote:
On Thu, Nov 28, 2013 at 09:42:24AM -0600, Bill wrote:
> I have got elua running on the 407 discovery board with the latest from
> Git. Really nice.  Is there a newer tutorial or instructions on adding a
> module to the build? The tutorial on the site references files I cannot
> find.
>
> Bill


Hi Bill,

what do you mean by "adding a module to the build"? If you want to write
your own platform module in C and build it with eLua, I could give you
some advice since I've done that multiple times for a board similar to
the Discovery board.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Richard Möhn Richard Möhn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

On Thu, Nov 28, 2013 at 03:33:22PM -0600, Bill wrote:
> I have a piece of hardware with a large communication protocol that exists
> in C that would be easier to just add a simple API for the user in elua. I
> would not want to have to support 2 versions of the protocol.


That sounds a lot like what I did. Unfortunately, I am not sure whether
I am allowed to share the code on github, but I'll try and explain.
However, I found those things out by looking on the code. Therefore, if
someone sees me doing something unidiomatic or wrong, please correct me.

Suppose you have your C sources lying in
src/platform/stm32f4/STM32F4DISCOVERY/ComProto/src with the headers in
src/platform/stm32f4/STM32F4DISCOVERY/ComProto/inc.

First thing you should do is add that code to the build. This is done in
src/platforms/stm32f4/build_config.lua and I introduced an if-block to
distinguish between the code needed for different boards:

--- conf.lua ---
local utils = require "utils.utils"
local sf = string.format

local src_with_platform = 'src/platform/' .. platform

local boardname = comp.board:upper()
local boardfiles = ''

if boardname  == "STM32F4DISCOVERY" then
  addi(src_with_platform .. '/STM32F4DISCOVERY/ComProto/inc')
  boardfiles = utils.get_files(src_with_platform ..  '/STM32F4DISCOVERY/ComProto/src', ".*%.c$")
else
  print( sf( "Invalid board for %s platform (%s)", platform, comp.board ) )
  os.exit( -1 )
end

addi( sf( 'src/platform/%s/FWLib/library/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/STM32_USB_OTG_Driver/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/STM32_USB_Device_Library/Class/cdc/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/STM32_USB_Device_Library/Core/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/VCP/inc', platform ) )

[...]

specific_files = boardfiles .. " "
                 .. fwlib_files .. " "
                 .. utils.prepend_path( specific_files, "src/platform/" .. platform )

[...]
----------------

Then you add your platform module for interfacing between C and eLua.
Suppose it's the file
src/platform/stm32f4/STM32F4DISCOVERY/ComProto/src/stm32f4discovery_comproto.c.
Documentation on C modules for Lua can be found in [1, section 3] and on
C modules for eLua with the Lua Tiny RAM patch in [2].

--- stm32f4discovery_comproto.c. ---
#include "<what you like>"

// for the Lua API
#include "lua.h"
#include "lauxlib.h"

// for the Lua Tiny RAM patch
#include "lrotable.h"
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"

// This is an example function that takes one parameter and returns an
// arbitrary number of packets. Never mind the contents.
/*
 * Receive to_receive_cnt packets with the transceiver and return them.
 *
 * Parameters:
 * 1   to_receive_cnt  number of packets to receive
 *
 * Returns:
 *      to_receive_cnt   p_{to_receive_cnt}
 *      ...
 *      2                p_2
 *      1                p_1
 * or
 *      nothing if there was an error
 */
static int stm32f4discovery_comproto_receive(lua_State *L)
{
    // Find out how many packets to receive
    int to_receive_cnt = luaL_checkint(L, 1);
    lua_pop(L, 1);

    // Make sure the stack is large enough to hold that number of packets
    if (!lua_checkstack(L, to_receive_cnt)) {
        return 0;
    }

    // For every packet to receive
    int r;
    for (r = 0; r < to_receive_cnt; ++r) {
        // Get one packet
        CC1100_Rx p = blocking_receive_Packet();

        // Put a new table onto the stack
        lua_createtable(L, 1, 4); // 1 data array, 4 metadata

        // Put the metadata in the table
        TABLESET_INT(L, PKG_SOURCE, p.source);
        TABLESET_INT(L, PKG_DEST,   p.dest);
        TABLESET_INT(L, PKG_RSSI,   p.RSSI);
        TABLESET_INT(L, PKG_LENGTH, p.length);

        // Put the data in the table
        lua_pushlstring(L, p.data + 2, p.length - 2);
            // First two chars are metadata
        lua_setfield(L, -2, PKG_DATA);
    }

    return to_receive_cnt;
}

// Here you list the functions and constants to be exported by the
// module.
const LUA_REG_TYPE stm32f4discovery_comproto_map[] = {
    { LSTRKEY("receive"),   LFUNCVAL(stm32f4discovery_comproto_receive) },
    // [...]
    { LNILKEY,              LNILVAL                         },
};

// Register module
LUALIB_API int stm32f4discovery_luaopen_comproto(lua_State *L)
{
    LREGISTER(L, "comproto", stm32f4discovery_comproto_map);
}
------------------------------------

Now you can add your module to the list of platform modules for the
STM32F4DISCOVERY in src/platform/stm32f4/build_config.lua by modifying
the function get_platform_modules. Again, I've introduced an if-block to
distinguish between platforms:

--- build_config.lua ---
[...]

-- Return an array of all the available platform modules for the given cpu
function get_platform_modules( board, cpu )
  local mods = {
    pio = {
      lib   = '"pio"',
      map   = "stm32_pio_map",
      open  = false
    },
    cpu = {
      lib   = '"cpu"',
      map   = "stm32_cpu_map",
      open  = "luaopen_stm32_cpu"
    },
  }

  -- Register MSB-IOT platform modules
  if board:upper() == 'STM32F4DISCOVERY' then
    mods.comproto = {
      lib       = '"comproto"',
      map       = "stm32f4discovery_comproto_map",
      open      = false
    }
  end

  return mods
end
------------------------

Last thing you have to do is to set the platform name in the board
configuration file:

--- boards/known/stm32f4discovery.lua ---
[...]

  modules = {
    generic = { 'all', "-i2c", "-net" },
    platform = 'all',
    platform_name = 'stm32f4discovery',
  },
}
-----------------------------------------

Then you can call our function as stm32f4discovery.comproto.receive().

Best,

Richard


[1] http://www.lua.org/manual/5.1/
[2] http://www.eluaproject.net/doc/master/en_arch_ltr.html
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

In reply to this post by tobor
How does it know to call this function:
// Register module
LUALIB_API int stm32f4discovery_luaopen_comproto(lua_State *L)
{
    LREGISTER(L, "comproto", stm32f4discovery_comproto_map);
}


On Fri, Nov 29, 2013 at 2:32 AM, Richard Möhn <[hidden email]> wrote:
On Thu, Nov 28, 2013 at 03:33:22PM -0600, Bill wrote:
> I have a piece of hardware with a large communication protocol that exists
> in C that would be easier to just add a simple API for the user in elua. I
> would not want to have to support 2 versions of the protocol.


That sounds a lot like what I did. Unfortunately, I am not sure whether
I am allowed to share the code on github, but I'll try and explain.
However, I found those things out by looking on the code. Therefore, if
someone sees me doing something unidiomatic or wrong, please correct me.

Suppose you have your C sources lying in
src/platform/stm32f4/STM32F4DISCOVERY/ComProto/src with the headers in
src/platform/stm32f4/STM32F4DISCOVERY/ComProto/inc.

First thing you should do is add that code to the build. This is done in
src/platforms/stm32f4/build_config.lua and I introduced an if-block to
distinguish between the code needed for different boards:

--- conf.lua ---
local utils = require "utils.utils"
local sf = string.format

local src_with_platform = 'src/platform/' .. platform

local boardname = comp.board:upper()
local boardfiles = ''

if boardname  == "STM32F4DISCOVERY" then
  addi(src_with_platform .. '/STM32F4DISCOVERY/ComProto/inc')
  boardfiles = utils.get_files(src_with_platform ..  '/STM32F4DISCOVERY/ComProto/src', ".*%.c$")
else
  print( sf( "Invalid board for %s platform (%s)", platform, comp.board ) )
  os.exit( -1 )
end

addi( sf( 'src/platform/%s/FWLib/library/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/STM32_USB_OTG_Driver/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/STM32_USB_Device_Library/Class/cdc/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/STM32_USB_Device_Library/Core/inc', platform ) )
addi( sf( 'src/platform/%s/FWLib/USB/VCP/inc', platform ) )

[...]

specific_files = boardfiles .. " "
                 .. fwlib_files .. " "
                 .. utils.prepend_path( specific_files, "src/platform/" .. platform )

[...]
----------------

Then you add your platform module for interfacing between C and eLua.
Suppose it's the file
src/platform/stm32f4/STM32F4DISCOVERY/ComProto/src/stm32f4discovery_comproto.c.
Documentation on C modules for Lua can be found in [1, section 3] and on
C modules for eLua with the Lua Tiny RAM patch in [2].

--- stm32f4discovery_comproto.c. ---
#include "<what you like>"

// for the Lua API
#include "lua.h"
#include "lauxlib.h"

// for the Lua Tiny RAM patch
#include "lrotable.h"
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"

// This is an example function that takes one parameter and returns an
// arbitrary number of packets. Never mind the contents.
/*
 * Receive to_receive_cnt packets with the transceiver and return them.
 *
 * Parameters:
 * 1   to_receive_cnt  number of packets to receive
 *
 * Returns:
 *      to_receive_cnt   p_{to_receive_cnt}
 *      ...
 *      2                p_2
 *      1                p_1
 * or
 *      nothing if there was an error
 */
static int stm32f4discovery_comproto_receive(lua_State *L)
{
    // Find out how many packets to receive
    int to_receive_cnt = luaL_checkint(L, 1);
    lua_pop(L, 1);

    // Make sure the stack is large enough to hold that number of packets
    if (!lua_checkstack(L, to_receive_cnt)) {
        return 0;
    }

    // For every packet to receive
    int r;
    for (r = 0; r < to_receive_cnt; ++r) {
        // Get one packet
        CC1100_Rx p = blocking_receive_Packet();

        // Put a new table onto the stack
        lua_createtable(L, 1, 4); // 1 data array, 4 metadata

        // Put the metadata in the table
        TABLESET_INT(L, PKG_SOURCE, p.source);
        TABLESET_INT(L, PKG_DEST,   p.dest);
        TABLESET_INT(L, PKG_RSSI,   p.RSSI);
        TABLESET_INT(L, PKG_LENGTH, p.length);

        // Put the data in the table
        lua_pushlstring(L, p.data + 2, p.length - 2);
            // First two chars are metadata
        lua_setfield(L, -2, PKG_DATA);
    }

    return to_receive_cnt;
}

// Here you list the functions and constants to be exported by the
// module.
const LUA_REG_TYPE stm32f4discovery_comproto_map[] = {
    { LSTRKEY("receive"),   LFUNCVAL(stm32f4discovery_comproto_receive) },
    // [...]
    { LNILKEY,              LNILVAL                         },
};

// Register module
LUALIB_API int stm32f4discovery_luaopen_comproto(lua_State *L)
{
    LREGISTER(L, "comproto", stm32f4discovery_comproto_map);
}
------------------------------------

Now you can add your module to the list of platform modules for the
STM32F4DISCOVERY in src/platform/stm32f4/build_config.lua by modifying
the function get_platform_modules. Again, I've introduced an if-block to
distinguish between platforms:

--- build_config.lua ---
[...]

-- Return an array of all the available platform modules for the given cpu
function get_platform_modules( board, cpu )
  local mods = {
    pio = {
      lib   = '"pio"',
      map   = "stm32_pio_map",
      open  = false
    },
    cpu = {
      lib   = '"cpu"',
      map   = "stm32_cpu_map",
      open  = "luaopen_stm32_cpu"
    },
  }

  -- Register MSB-IOT platform modules
  if board:upper() == 'STM32F4DISCOVERY' then
    mods.comproto = {
      lib       = '"comproto"',
      map       = "stm32f4discovery_comproto_map",
      open      = false
    }
  end

  return mods
end
------------------------

Last thing you have to do is to set the platform name in the board
configuration file:

--- boards/known/stm32f4discovery.lua ---
[...]

  modules = {
    generic = { 'all', "-i2c", "-net" },
    platform = 'all',
    platform_name = 'stm32f4discovery',
  },
}
-----------------------------------------

Then you can call our function as stm32f4discovery.comproto.receive().

Best,

Richard


[1] http://www.lua.org/manual/5.1/
[2] http://www.eluaproject.net/doc/master/en_arch_ltr.html
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Richard Möhn Richard Möhn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

On Fri, Nov 29, 2013 at 08:55:04AM -0600, Bill wrote:
> How does it know to call this function:
> // Register module
> LUALIB_API int stm32f4discovery_luaopen_comproto(lua_State *L)
> {
>     LREGISTER(L, "comproto", stm32f4discovery_comproto_map);
> }


That's a good question. In normal Lua it is because of the name, as
described here: http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders
However, in one of my modules I had misspelled that name so that it
matched neither the filename nor the module's name and it still worked.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

In reply to this post by tobor
I seem to be missing a step, I was getting a fail at comproto, but now it is only at receive.
I get:
> stm32f4discovery.comproto.receive()
stdin:1: attempt to call field 'receive' (a nil value)
stack traceback:
        stdin:1: in main chunk
        [C]: ?
>

#include "lua.h"

#include "lualib.h"

#include "lauxlib.h"

#include "platform.h"

#include "auxmods.h"

#include "lrotable.h"

#include "lrodefs.h"

 

static int stm32f4discovery_comproto_receive(lua_State *L)

{

return((int) 42);

}

// Module function map

const LUA_REG_TYPE stm32f4discovery_comproto_map[] =

{

{ LSTRKEY( "receive" ), LFUNCVAL( stm32f4discovery_comproto_receive ) },

{ LNILKEY, LNILVAL },

};

LUALIB_API int stm32f4discovery_comproto( lua_State* L )

{

LREGISTER( L, "comproto", stm32f4discovery_comproto_map );

}




On Fri, Nov 29, 2013 at 9:40 AM, Richard Möhn <[hidden email]> wrote:
On Fri, Nov 29, 2013 at 08:55:04AM -0600, Bill wrote:
> How does it know to call this function:
> // Register module
> LUALIB_API int stm32f4discovery_luaopen_comproto(lua_State *L)
> {
>     LREGISTER(L, "comproto", stm32f4discovery_comproto_map);
> }


That's a good question. In normal Lua it is because of the name, as
described here: http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders
However, in one of my modules I had misspelled that name so that it
matched neither the filename nor the module's name and it still worked.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Richard Möhn Richard Möhn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

On Fri, Nov 29, 2013 at 10:24:11AM -0600, Bill wrote:
> I seem to be missing a step, I was getting a fail at comproto, but now it
> is only at receive.
> I get:
> > stm32f4discovery.comproto.receive()
> stdin:1: attempt to call field 'receive' (a nil value)
> stack traceback:
>         stdin:1: in main chunk
>         [C]: ?

You might open the eLua shell, start the Lua shell and type the
following:

    > = stm32f4discovery
    > = stm32f4discovery.comproto
    > = stm32f4discovery.comproto.receive

If the first one fails, it might be because platform_name was not
properly set in boards/known/stm32f4discovery.lua. If the second one
fails, something with the registration of the module went wrong. If the
third one fails, something with the registration of the function went
wrong.

And there is an issue with you stripped-down version of receive(): One
can't use the normal "return" from C to return a value to Lua. Instead,
it must be pushed onto the stack and then you return the number of
things you have pushed on the stack. Therefore, the function should look
like this:

    static int stm32f4discovery_comproto_receive(lua_State *L)
    {
        lua_pushinteger(L, 42);
        return 1;
    }

You can read about this here:
http://www.lua.org/manual/5.1/manual.html#3 The book Programming in Lua
probably is an easier introduction, though.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

In reply to this post by tobor
got it working. Is there a way to get the functions only 2 deep i.e.
gw.receive() instead of stm32f4discovery.gw.receive()

thanks for all the help.


On Fri, Nov 29, 2013 at 10:47 AM, Richard Möhn <[hidden email]> wrote:
On Fri, Nov 29, 2013 at 10:24:11AM -0600, Bill wrote:
> I seem to be missing a step, I was getting a fail at comproto, but now it
> is only at receive.
> I get:
> > stm32f4discovery.comproto.receive()
> stdin:1: attempt to call field 'receive' (a nil value)
> stack traceback:
>         stdin:1: in main chunk
>         [C]: ?

You might open the eLua shell, start the Lua shell and type the
following:

    > = stm32f4discovery
    > = stm32f4discovery.comproto
    > = stm32f4discovery.comproto.receive

If the first one fails, it might be because platform_name was not
properly set in boards/known/stm32f4discovery.lua. If the second one
fails, something with the registration of the module went wrong. If the
third one fails, something with the registration of the function went
wrong.

And there is an issue with you stripped-down version of receive(): One
can't use the normal "return" from C to return a value to Lua. Instead,
it must be pushed onto the stack and then you return the number of
things you have pushed on the stack. Therefore, the function should look
like this:

    static int stm32f4discovery_comproto_receive(lua_State *L)
    {
        lua_pushinteger(L, 42);
        return 1;
    }

You can read about this here:
http://www.lua.org/manual/5.1/manual.html#3 The book Programming in Lua
probably is an easier introduction, though.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
sweetlilmre sweetlilmre
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

I am probably talking out of turn here, but can't you assign a variable to stm32f4discovery.gw e.g mygw and then use that?

-(e)

On 1 Dec 2013 15:56, "Bill" <[hidden email]> wrote:
got it working. Is there a way to get the functions only 2 deep i.e.
gw.receive() instead of stm32f4discovery.gw.receive()

thanks for all the help.


On Fri, Nov 29, 2013 at 10:47 AM, Richard Möhn <[hidden email]> wrote:
On Fri, Nov 29, 2013 at 10:24:11AM -0600, Bill wrote:
> I seem to be missing a step, I was getting a fail at comproto, but now it
> is only at receive.
> I get:
> > stm32f4discovery.comproto.receive()
> stdin:1: attempt to call field 'receive' (a nil value)
> stack traceback:
>         stdin:1: in main chunk
>         [C]: ?

You might open the eLua shell, start the Lua shell and type the
following:

    > = stm32f4discovery
    > = stm32f4discovery.comproto
    > = stm32f4discovery.comproto.receive

If the first one fails, it might be because platform_name was not
properly set in boards/known/stm32f4discovery.lua. If the second one
fails, something with the registration of the module went wrong. If the
third one fails, something with the registration of the function went
wrong.

And there is an issue with you stripped-down version of receive(): One
can't use the normal "return" from C to return a value to Lua. Instead,
it must be pushed onto the stack and then you return the number of
things you have pushed on the stack. Therefore, the function should look
like this:

    static int stm32f4discovery_comproto_receive(lua_State *L)
    {
        lua_pushinteger(L, 42);
        return 1;
    }

You can read about this here:
http://www.lua.org/manual/5.1/manual.html#3 The book Programming in Lua
probably is an easier introduction, though.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Richard Möhn Richard Möhn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

On Sun, Dec 01, 2013 at 04:45:56PM +0200, Peter Edwards wrote:
> I am probably talking out of turn here, but can't you assign a variable to
> stm32f4discovery.gw e.g mygw and then use that?

Of course that's kind of a workaround, but I don't have a better idea,
either. What Peter means is this, I think:

    local gw = stm32discovery.gw
    gw.receive()

This works because modules are nothing else than tables in Lua. If you
don't like the name of the module/table, simply create a new variable
referencing that table.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

In reply to this post by sweetlilmre
thanks


On Sun, Dec 1, 2013 at 9:08 AM, Richard Möhn <[hidden email]> wrote:
On Sun, Dec 01, 2013 at 04:45:56PM +0200, Peter Edwards wrote:
> I am probably talking out of turn here, but can't you assign a variable to
> stm32f4discovery.gw e.g mygw and then use that?

Of course that's kind of a workaround, but I don't have a better idea,
either. What Peter means is this, I think:

    local gw = stm32discovery.gw
    gw.receive()

This works because modules are nothing else than tables in Lua. If you
don't like the name of the module/table, simply create a new variable
referencing that table.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
tobor tobor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

Am I limited to adding 1 module? I tried adding a second and it seemed to take only the last in the list. When I tried to create a group, it gave an error "string expected, got table"




On Sun, Dec 1, 2013 at 9:18 AM, Bill <[hidden email]> wrote:
thanks


On Sun, Dec 1, 2013 at 9:08 AM, Richard Möhn <[hidden email]> wrote:
On Sun, Dec 01, 2013 at 04:45:56PM +0200, Peter Edwards wrote:
> I am probably talking out of turn here, but can't you assign a variable to
> stm32f4discovery.gw e.g mygw and then use that?

Of course that's kind of a workaround, but I don't have a better idea,
either. What Peter means is this, I think:

    local gw = stm32discovery.gw
    gw.receive()

This works because modules are nothing else than tables in Lua. If you
don't like the name of the module/table, simply create a new variable
referencing that table.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev



_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Richard Möhn Richard Möhn
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: STM32F4

On Mon, Dec 02, 2013 at 10:58:57AM -0600, Bill wrote:
> Am I limited to adding 1 module? I tried adding a second and it seemed to
> take only the last in the list. When I tried to create a group, it gave an
> error "string expected, got table"


I do not quite know what you mean with creating a group, but my
build_config.lua looks like this:

------------------------------------------------------------------------
-- Return an array of all the available platform modules for the given cpu
function get_platform_modules( board, cpu )
  local mods = {
    pio = {
      lib   = '"pio"',
      map   = "stm32_pio_map",
      open  = false
    },
    cpu = {
      lib   = '"cpu"',
      map   = "stm32_cpu_map",
      open  = "luaopen_stm32_cpu"
    },
  }

  -- Register MSB-IOT platform modules
  if board == 'msb-iot' then
    mods.cc1101 = {
      lib       = '"cc1101"',
      map       = "msbiot_cc1101_map",
      open      = false
    }
    mods.scratch = {
      lib       = '"scratch"',
      map       = "msbiot_scratch_map",
      open      = false
    }
    mods.cc3000 = {
      lib       = '"cc3000"',
      map       = "msbiot_cc3000_map",
      open      = false
    }
  end

  return mods
end
------------------------------------------------------------------------

I hope you can make something out of this.

Best,

Richard
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Loading...