Toggle navigation
首页
(current)
问答
文章
话题
商城
登录
注册
在core中添加自己的lua模块
Lua
二次开发
固件
# 下载core 打开[http://www.openluat.com/Product/gprs/Air202.html](http://www.openluat.com/Product/gprs/Air202.html)--> 资料下载 --> 下载源码 --> 资料下载 --> 下载源码  把压缩包里的文件解压到一个位置 # 添加模块 假设新增的模块叫`test`,调用`test.get(a)`返回`a+1`后的值 在`core\cust_src\elua\modules\src`新建一个文件`test.c`:  放入如下示例代码: ```c #include "lua.h" #include "lualib.h" #include "lauxlib.h" #include "platform.h" #include "auxmods.h" #include "lrotable.h" #include
#include
#include
static int test_get( lua_State *L ) { int number = luaL_checkinteger( L, 1 ); lua_pushinteger( L, number + 1); return 1; } // Module function map #include "lrodefs.h" const LUA_REG_TYPE test_map[] = { { LSTRKEY( "get" ), LFUNCVAL( test_get ) }, { LNILKEY, LNILVAL } }; LUALIB_API int luaopen_test( lua_State *L ) { luaL_register( L, AUXLIB_TEST, test_map ); return 1; } ``` 接着,打开文件`core\cust_src\elua\modules\include\auxmods.h`  在合适位置加上: ```c #define AUXLIB_TEST "test" LUALIB_API int ( luaopen_test )( lua_State *L ); ```  打开`core\cust_src\elua\platform\coolsand\include\platform_conf.h` 在合适位置加上`_ROM( AUXLIB_TEST, luaopen_test, test_map ) \`  # 编译 下载csdtk4,解压到c盘根目录: [https://1dv.papapoi.com/%E8%BD%AF%E4%BB%B6/csdk%E7%9B%B8%E5%85%B3/CSDTK4.7z](https://1dv.papapoi.com/%E8%BD%AF%E4%BB%B6/csdk%E7%9B%B8%E5%85%B3/CSDTK4.7z) 运行`core\project\你需要的lua运行版本\build\ cust_build.bat`编译即可 运行`core\project\你需要的lua运行版本\build\ cust_clean.bat`可完全重新编译 Lod文件可在`core\hex\你需要的lua运行版本\`目录找到  # 测试   
发表于 2019-01-28 11:57
阅读 ( 3844 )
分类:
默认分类
1 推荐
打赏
收藏
你可能感兴趣的文章
13、RDA8910CSDK二次开发:将你的代码藏起来----编译静态库
5614 浏览
3、RDA8910CSDK二次开发:GPIO输入详解
2204 浏览
11、合宙Air模块Luat开发:通过http协议获取天气信息
2609 浏览
10、合宙Air模块Luat开发:JSON字符串的生成与解析
2488 浏览
9、合宙Air模块Luat开发:认识NVS数据管理模块
2154 浏览
8、合宙Air模块Luat开发:基于官方库的二次封装,使串口更加易用
2749 浏览
相关问题
关于二次开发功能上的咨询
1 回答
air202,用mqtt协议连接onenet平台(lua)。
1 回答
请问lua中number类型的浮点数有没有快速的函数将其转换成按字节存储的table变量
1 回答
关于字符串中按位写入数值的问题
1 回答
Lua数据处理问题
2 回答
1 条评论
请先
登录
后评论
晨旭
菜鸟
20 篇文章
作家榜
»
技术销售Delectate
43 文章
陈夏
26 文章
国梁
24 文章
miuser
21 文章
晨旭
20 文章
朱天华
19 文章
金艺
19 文章
杨奉武
18 文章
×
发送私信
发给:
内容:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!