Эх сурвалжийг харах

add: 添加repl库的支持

Wendal Chen 2 жил өмнө
parent
commit
c9e8293d0d

+ 8 - 1
cloudbuild/esp32c2-idf5.meta.json

@@ -164,6 +164,13 @@
            "content":"工具库",
            "rsize":0,
            "children":[
+               {
+                   "name": "repl",
+                   "content": "REPL(读取-解析-执行)循环",
+                   "rsize": 10908,
+                   "fsize": 284260,
+                   "dft": false
+               },
               {
                  "name":"cjson",
                  "content":"JSON序列化与反序列化",
@@ -228,7 +235,7 @@
               },
               {
                  "name":"shell",
-                 "content":"控制台,搭配dbg功能才可以在LuatIDE使用",
+                 "content":"控制台,会跟repl冲突",
                  "rsize":6848,
                  "fsize":372224,
                  "dft":false,

+ 8 - 1
cloudbuild/esp32c3-idf5.meta.json

@@ -200,6 +200,13 @@
            "content":"工具库",
            "rsize":0,
            "children":[
+            {
+                "name": "repl",
+                "content": "REPL(读取-解析-执行)循环",
+                "rsize": 10908,
+                "fsize": 284260,
+                "dft": false
+            },
               {
                  "name":"cjson",
                  "content":"JSON序列化与反序列化",
@@ -257,7 +264,7 @@
               },
               {
                  "name":"shell",
-                 "content":"控制台,搭配dbg功能才可以在LuatIDE使用",
+                 "content":"控制台,会跟repl冲突",
                  "rsize":6848,
                  "fsize":372224,
                  "dft":false,

+ 8 - 1
cloudbuild/esp32s3-idf5.meta.json

@@ -178,6 +178,13 @@
            "content":"工具库",
            "rsize":0,
            "children":[
+            {
+                "name": "repl",
+                "content": "REPL(读取-解析-执行)循环",
+                "rsize": 10908,
+                "fsize": 284260,
+                "dft": false
+            },
               {
                  "name":"cjson",
                  "content":"JSON序列化与反序列化",
@@ -242,7 +249,7 @@
               },
               {
                  "name":"shell",
-                 "content":"控制台,搭配dbg功能才可以在LuatIDE使用",
+                 "content":"控制台,会跟repl冲突",
                  "rsize":6848,
                  "fsize":372224,
                  "dft":false,

+ 2 - 0
luatos/components/luat/CMakeLists.txt

@@ -85,6 +85,7 @@ idf_component_register(SRC_DIRS ${LUATOS_ROOT}/luat/modules
                                 ${LUATOS_ROOT}/components/iconv
                                 ${LUATOS_ROOT}/components/gmssl/src
                                 ${LUATOS_ROOT}/components/gmssl/bind
+                                ${LUATOS_ROOT}/components/repl
                                 INCLUDE_DIRS ../../include
                                 ${LUATOS_ROOT}/components/max30102
                                 ${LUATOS_ROOT}/lua/include
@@ -145,6 +146,7 @@ idf_component_register(SRC_DIRS ${LUATOS_ROOT}/luat/modules
                                 ${LUATOS_ROOT}/components/romfs
                                 ${LUATOS_ROOT}/components/iconv
                                 ${LUATOS_ROOT}/components/gmssl/include
+                                ${LUATOS_ROOT}/components/repl
                     REQUIRES esp-tls lwip esp_http_client mbedtls spiffs driver heap esp_netif esp_event
                              esp_wifi esp_rom http_parser mqtt esp_adc bt console spi_flash esp_psram 
                     )

+ 3 - 0
luatos/components/luat/port/luat_base_idf5.c

@@ -242,6 +242,9 @@ static const luaL_Reg loadedlibs[] = {
 #endif
 #ifdef LUAT_USE_GMSSL
   {"gmssl", luaopen_gmssl},
+#endif
+#ifdef LUAT_USE_REPL
+  {"repl", luaopen_repl},
 #endif
   {NULL, NULL}
 };

+ 4 - 4
luatos/components/luat/port/luat_uart_idf5.c

@@ -13,7 +13,7 @@
 #include "luat_log.h"
 #define LUAT_LOG_TAG "uart"
 
-#ifdef LUAT_USE_SHELL
+#if defined(LUAT_USE_SHELL) || defined(LUAT_USE_REPL)
 static uint8_t shell_state = 0;
 static char shell_buffer[1024] = {0};
 #endif
@@ -48,7 +48,7 @@ static void uart0_irq_task(void *arg){
                     msg.arg2 = event.size;
                     luat_msgbus_put(&msg, 0);
                 }
-#ifdef LUAT_USE_SHELL
+#if defined(LUAT_USE_SHELL) || defined(LUAT_USE_REPL)
             if (shell_state){
                 int len = luat_uart_read(0, shell_buffer, 1024);
                 if (len < 1)
@@ -144,7 +144,7 @@ int luat_uart_setup(luat_uart_t *uart){
     uart_set_rx_timeout(id, 3);
     switch (id){
     case 0:
-#ifdef LUAT_USE_SHELL
+#if defined(LUAT_USE_SHELL) || defined(LUAT_USE_REPL)
         if (shell_state){
             shell_state = 0;
             luat_uart_close(0);
@@ -221,7 +221,7 @@ int luat_setup_cb(int uartid, int received, int sent){
     return 0;
 }
 
-#ifdef LUAT_USE_SHELL
+#if defined(LUAT_USE_SHELL) || defined(LUAT_USE_REPL)
 void luat_shell_poweron(int _drv) {
     shell_state = 1;
     uart_driver_install(0, 2048, 2048, LUAT_UART_QUEUE_SIZE, &(uart_port[0].xQueue), 0);

+ 4 - 3
luatos/include/luat_conf_bsp.h

@@ -95,9 +95,10 @@
 // #define LUAT_USE_FATFS_CHINESE 3
 
 //----------------------------
-// 高级功能, 其中shell是推荐启用, 除非你打算uart0也读数据
-#define LUAT_USE_SHELL 1
-#define LUAT_USE_DBG
+// 高级功能, 推荐使用repl, shell已废弃
+// #define LUAT_USE_SHELL 1
+// #define LUAT_USE_DBG
+#define LUAT_USE_REPL 1
 // 多虚拟机支持,实验性,一般不启用
 // #define LUAT_USE_VMX 1
 // #define LUAT_USE_PROTOBUF 1

+ 1 - 1
luatos/main/idf5_main.c

@@ -45,7 +45,7 @@ void app_main(void){
     vTaskPrioritySet( NULL, 10);
     void luat_mcu_us_timer_init();
     luat_mcu_us_timer_init();
-#ifdef LUAT_USE_SHELL
+#if defined(LUAT_USE_SHELL) || defined(LUAT_USE_REPL)
     extern void luat_shell_poweron(int _drv);
 	luat_shell_poweron(0);
 #endif