Просмотр исходного кода

fix: 增加不同版本的区别

梁健 9 месяцев назад
Родитель
Сommit
6957c406c6

+ 1 - 0
module/Air780EPM/demo/780EPM_1.3开发板出厂固件/demo/airlcd.lua

@@ -66,6 +66,7 @@ function airLCD.lcd_init(sn)
           end
       end)
   end
+
 end
 
 return airLCD

+ 0 - 3
module/Air8000/core/固件差异.txt

@@ -1,3 +0,0 @@
-LuatOS-SoC_V20xx_Air8000_LVGL  	固件支持LVGL,不支持VOLTE
-LuatOS-SoC_V20xx_Air8000_VOLTE 	固件支持VOLTE,不支持LVGL
-除此之外,两个固件支持的其他功能都一样。

+ 79 - 0
module/Air8000/core/版本功能列表.md

@@ -0,0 +1,79 @@
+
+# 不同版本的区别
+
+| 序号 | 核心库名称                      | 简介                                | 类别     | 8000_FS | 8000_VOLTE | 8000_LVGL |
+| ---- | ------------------------------- | ----------------------------------- | -------- | ------- | ---------- | --------- |
+| 1    | [adc](adc.md)                   | 模数转换                            | 外设驱动 | √       | √          | √         |
+| 2    | [arlink](arlink.md)             | 多网融合协议                        | 协议组件 | √       | √          | √         |
+| 3    | [audio](audio.md)               | 模数转换                            | 外设驱动 | ×       | √          | √         |
+| 4    | [bit64](bit64.md)               | 模数转换                            | 外设驱动 | √       | √          | √         |
+| 5    | [ble](ble.md)                   | 蓝牙功能                            | 通信组件 | √       | √          | √         |
+| 6    | [camera](camera.md)             | 模数转换                            | 外设驱动 | √       | √          | √         |
+| 7    | [can](can.md)                   | can操作库                           | 外设驱动 | √       | √          | √         |
+| 8    | [cc](cc.md)                     | VoLTE通话功能                       | 通信组件 | ×       | √          | ×         |
+| 9    | [codec](codec.md)               | 多媒体-编解码                       | 基础软件 | ×       | √          | √         |
+| 10   | [crypto](crypto.md)             | 加解密和hash函数                    | 加密解密 | √       | √          | √         |
+| 11   | [eink](eink.md)                 | 墨水屏操作库                        | 外设驱动 | √       | √          | √         |
+| 12   | [errDump](errDump.md)           | 错误上报                            | 基础软件 | √       | √          | √         |
+| 13   | [fastlz](fastlz.md)             | FastLZ压缩                          | 基础软件 | ×       | √          | √         |
+| 14   | [fatfs](fatfs.md)               | SD卡的接口                          | 基础软件 | ×       | √          | √         |
+| 15   | [fonts](fonts.md)               | 字体库                              | 基础软件 | √       | √          | √         |
+| 16   | [fota](fota.md)                 | 底层固件升级                        | 基础软件 | √       | √          | √         |
+| 17   | [fs](fs.md)                     | 文件系统额外操作                    | 基础软件 | √       | √          | √         |
+| 18   | [fskv](fskv.md)                 | kv数据库,掉电不丢数据               | 基础软件 | √       | √          | √         |
+| 19   | [ftp](ftp.md)                   | ftp 客户端                          | 协议组件 | √       | √          | √         |
+| 20   | [gmssl](gmssl.md)               | 国密算法(SM2/SM3/SM4)               | 加密解密 | √       | √          | √         |
+| 21   | [gpio](gpio.md)                 | GPIO操作                            | 外设驱动 | √       | √          | √         |
+| 22   | [gtfont](gtfont.md)             | 高通字库芯片                        | 外设驱动 | ×       | √          | √         |
+| 23   | [hmeta](hmeta.md)               | 硬件元数据                          | 通信组件 | √       | √          | √         |
+| 24   | [ht1621](ht1621.md)             | 断码屏                              | 外设驱动 | ×       | √          | √         |
+| 25   | [http](http.md)                 | http 客户端                         | 协议组件 | √       | √          | √         |
+| 26   | [httpsrv](httpsrv.md)           | http服务端                          | 协议组件 | √       | √          | √         |
+| 27   | [i2c](i2c.md)                   | I2C操作                             | 外设驱动 | √       | √          | √         |
+| 28   | [i2s](i2s.md)                   | 数字音频                            | 外设驱动 | ×       | √          | √         |
+| 29   | [iconv](iconv.md)               | iconv操作                           | 基础软件 | √       | √          | √         |
+| 30   | [io](io.md)                     | io操作(扩展)                        | 基础软件 | √       | √          | √         |
+| 31   | [ioqueue](ioqueue.md)           | io序列操作                          | 基础软件 | √       | √          | √         |
+| 32   | [iotauth](iotauth.md)           | IoT鉴权库, 用于生成各种云平台的参数 | 协议组件 | √       | √          | √         |
+| 33   | [iperf](iperf.md)               | 吞吐量测试                          | 通信组件 | √       | √          | √         |
+| 34   | [json](json.md)                 | json生成和解析库                    | 基础软件 | √       | √          | √         |
+| 35   | [lcd](lcd.md)                   | lcd驱动模块                         | 外设驱动 | √       | √          | √         |
+| 36   | [libgnss](libgnss.md)           | NMEA数据处理                        |          | √       | √          | √         |
+| 37   | [little_flash](little_flash.md) | NAMD flash操作                      | 协议组件 | ×       | √          | √         |
+| 38   | [log](log.md)                   | 日志库                              | 基础软件 | √       | √          | √         |
+| 39   | [lora2](lora2.md)               | lora2驱动模块(支持多挂)             | 外设驱动 | ×       | √          | √         |
+| 40   | [lvgl](lvgl.md)                 | LVGL图像库                          | 基础软件 | ×       | ×          | √         |
+| 41   | [mcu](mcu.md)                   | 封装mcu一些特殊操作                 | 基础软件 | √       | √          | √         |
+| 42   | [miniz](miniz.md)               | 简易zlib压缩                        | 基础软件 | √       | √          | √         |
+| 43   | [mobile](mobile.md)             | 蜂窝网络                            | 通信组件 | √       | √          | √         |
+| 44   | [mqtt](mqtt.md)                 | mqtt客户端                          | 协议组件 | √       | √          | √         |
+| 45   | [modbus](modbus.md)             | modbus RTU和TCP                     | 协议组件 | √       | √          | √         |
+| 46   | [netdrv](netdrv.md)             | 网络设备管理                        | 外设驱动 | √       | √          | √         |
+| 47   | [onewire](onewire.md)           | 单总线协议驱动                      | 外设驱动 | √       | √          | √         |
+| 48   | [os](os.md)                     | os操作                              | 基础软件 | √       | √          | √         |
+| 49   | [otp](otp.md)                   | OTP操作库                           | 基础软件 | ×       | √          | √         |
+| 50   | [pack](pack.md)                 | 打包和解包格式串                    | 基础软件 | √       | √          | √         |
+| 51   | [pins](pins.md)                 | 管脚复用                            | 外设驱动 | √       | √          | √         |
+| 52   | [pm](pm.md)                     | 电源管理                            | 基础软件 | √       | √          | √         |
+| 53   | [protobuf](protobuf.md)         | ProtoBuffs编解码                    | 基础软件 | √       | √          | √         |
+| 54   | [pwm](pwm.md)                   | PWM模块                             | 外设驱动 | √       | √          | √         |
+| 55   | [rsa](rsa.md)                   | RSA加密解密                         | 加密解密 | √       | √          | √         |
+| 56   | [rtc](rtc.md)                   | 实时时钟                            | 基础软件 | √       | √          | √         |
+| 57   | [rtos](rtos.md)                 | RTOS底层操作库                      | 基础软件 | √       | √          | √         |
+| 58   | [sfud](sfud.md)                 | 开源sfud软件包,复杂SPI操作          | 外设驱动 | ×       | √          | √         |
+| 59   | [sms](sms.md)                   | 短信                                | 通信组件 | √       | √          | √         |
+| 60   | [socket](socket.md)             | 网络接口                            | 协议组件 | √       | √          | √         |
+| 61   | [spi](spi.md)                   | spi操作库                           | 外设驱动 | √       | √          | √         |
+| 62   | [string](string.md)             | 字符串操作函数                      | 基础软件 | √       | √          | √         |
+| 63   | [sys](sys.md)                   | sys库                               | 基础软件 | √       | √          | √         |
+| 64   | [sysplus](sysplus.md)           | sys库的强力补充                     | 基础软件 | √       | √          | √         |
+| 65   | [tp](tp.md)                     | 触摸库                              | 外设驱动 | √       | √          | √         |
+| 66   | [u8g2](u8g2.md)                 | u8g2                                | 外设驱动 | √       | √          | √         |
+| 67   | [uart](uart.md)                 | 串口操作库                          | 外设驱动 | √       | √          | √         |
+| 68   | [wdt](wdt.md)                   | watchdog操作库                      |          | √       | √          | √         |
+| 69   | [websocket](websocket.md)       | websocket客户端                     | 基础软件 | √       | √          | √         |
+| 70   | [wlan](wlan.md)                 | 局域网操作                          | 协议组件 | √       | √          | √         |
+| 71   | [xxtea](xxtea.md)               | xxtea加密解密                       | 加密解密 | √       | √          | √         |
+| 72   | [yhm27xx](yhm27xx.md)           | yhm27xx充电芯片                     | 外设驱动 | ×       | √          | √         |
+| 73   | [ymodem](ymodem.md)             | ymodem协议                          | 基础软件 | ×       | √          | √         |
+| 74   | [zbuff](zbuff.md)               | c内存数据操作库                     | 基础软件 | √       | √          | √         |

+ 1 - 0
module/Air8000/project/整机开发板出厂工程/user/airlan.lua

@@ -50,6 +50,7 @@ local function start_lan()
     while netdrv.link(socket.LWIP_GP) ~= true do
         sys.wait(100)
     end
+
     sys.wait(2000)
     dhcpsrv.create({adapter=socket.LWIP_ETH})
     dnsproxy.setup(socket.LWIP_ETH, socket.LWIP_GP)

+ 8 - 1
module/Air8000/project/整机开发板出厂工程/user/airwan.lua

@@ -39,8 +39,15 @@ local function start_wan()
     -- SPI ID 1, 片选 GPIO12
     netdrv.setup(socket.LWIP_ETH, netdrv.CH390, {spi=1,cs=12})
     netdrv.dhcp(socket.LWIP_ETH, true)
-
+    while 1 do
+        local result, ip, adapter = sys.waitUntil("IP_READY", 3000)
+        log.info("ready?", result, ip, adapter)
+        if adapter and adapter ==  socket.LWIP_ETH then
+            break
+        end
+    end
     iperf.client(socket.LWIP_ETH, "192.168.4.1")
+    log.info("创建完成,iperf 客户端创建完成")
     wifi_net_state = "创建完成,iperf 客户端创建完成"
 end
 

+ 51 - 47
script/corelib/sys.lua

@@ -69,13 +69,13 @@ local function wrapper(co,...)
     end
     return ...
 end
-sys.coresume = function(...)
+sys.coresume = function(...)   
     local arg = {...}
-    return wrapper(arg[1], coroutine.resume(...))
+    return wrapper(arg[1], coroutine.resume(...)) -- 恢复协程,并且检查协程执行结果
 end
 
 function sys.check_task()
-    local co, ismain = coroutine.running()
+    local co, ismain = coroutine.running()   -- 获取当前协程号,如果是主协程,则ismain为 true,主协程不允许等待,因为一旦等待则无法接受消息,其他的任务也无法继续执行
     if ismain then
         error(debug.traceback("attempt to yield from outside a coroutine"))
     end
@@ -90,9 +90,9 @@ function sys.wait(ms)
     -- 参数检测,参数不能为负值
     --assert(ms > 0, "The wait time cannot be negative!")
     -- 选一个未使用的定时器ID给该任务线程
-    local co = sys.check_task()
-    while true do
-        if taskTimerId >= TASK_TIMER_ID_MAX - 1 then
+    local co = sys.check_task()       --  获取当前的task,并检测,如果是在main task ,则报异常,如果不是,返回当前协程号
+    while true do                     -- 如果定时器的id 大于最大值,则返回重新找空的timerPool 仓位
+        if taskTimerId >= TASK_TIMER_ID_MAX - 1 then  
             taskTimerId = 0
         else
             taskTimerId = taskTimerId + 1
@@ -102,15 +102,15 @@ function sys.wait(ms)
         end
     end
     local timerid = taskTimerId
-    timerPool[timerid] = co
+    timerPool[timerid] = co           -- timerPool 仓位赋值
     -- 调用core的rtos定时器
-    if 1 ~= rtos.timer_start(timerid, ms) then log.debug("rtos.timer_start error") return end
+    if 1 ~= rtos.timer_start(timerid, ms) then log.debug("rtos.timer_start error") return end   -- 通过core 开始启动定时器,如果超过64 则报错
     -- 挂起调用的任务线程
-    local message = {coroutine.yield()}
-    if #message ~= 0 then
-        rtos.timer_stop(timerid)
-        timerPool[timerid] = nil
-        return unpack(message)
+    local message = {coroutine.yield()}         -- 挂起当前的task
+    if #message ~= 0 then                       -- 判断挂起协程结束后返回值,如果有返回值,说明恢复协程的时候,有带参数
+        rtos.timer_stop(timerid)                -- 有参数,一定是消息返回了,定时器需要提前停止
+        timerPool[timerid] = nil                -- 释放core定时器和timerPool定时器列表
+        return unpack(message)                  -- 返回消息的带的参数
     end
 end
 
@@ -121,15 +121,16 @@ end
 -- @return data 接收到消息返回消息参数
 -- @usage result, data = sys.waitUntil("SIM_IND", 120000)
 function sys.waitUntil(id, ms)
-    local co = sys.check_task()
-    sys.subscribe(id, co)
-    local message = ms and {sys.wait(ms)} or {coroutine.yield()}
+    local co = sys.check_task()         -- 获取并检查当前的task
+    sys.subscribe(id, co)               -- 订阅当前ID 消息,订阅的回调是task 号,如果消息过来,则可以解除下一行的挂起状态
+    local message = ms and {sys.wait(ms)} or {coroutine.yield()}  -- 如果有写入时间,则进入sys.wait,定时间到就直接进入下行的取消订阅,如果时间未到,却等来了订阅的消息,则在sys.wait 里面 会解除挂起,然后解除订阅
     sys.unsubscribe(id, co)
-    return message[1] ~= nil, unpack(message, 2, #message)
+    return message[1] ~= nil, unpack(message, 2, #message)  -- 返回订阅消息带的参数
 end
 
+
 --- 同上,但不返回等待结果
-function sys.waitUntilMsg(id)
+function sys.waitUntilMsg(id)           -- 同上,不需要sys.wait 挂起
     local co = sys.check_task()
     sys.subscribe(id, co)
     local message = {coroutine.yield()}
@@ -143,7 +144,7 @@ end
 -- @return message 接收到消息返回message,超时返回false
 -- @return data 接收到消息返回消息参数
 -- @usage result, data = sys.waitUntilExt("SIM_IND", 120000)
-function sys.waitUntilExt(id, ms)
+function sys.waitUntilExt(id, ms)           --  好像没用
     local co = sys.check_task()
     sys.subscribe(id, co)
     local message = ms and {sys.wait(ms)} or {coroutine.yield()}
@@ -192,15 +193,15 @@ end
 -- @usage timerStop(1)
 function sys.timerStop(val, ...)
     -- val 为定时器ID
-    if type(val) == 'number' then
+    if type(val) == 'number' then                          -- 停止单个定时器
         timerPool[val], para[val] = nil, nil
         rtos.timer_stop(val)
-    else
+    else                                                   -- 停止多个定时器 
         for k, v in pairs(timerPool) do
             -- 回调函数相同
             if type(v) == 'table' and v.cb == val or v == val then
                 -- 可变参数相同
-                if cmpTable({...}, para[k]) then
+                if cmpTable({...}, para[k]) then           -- 带来的定时器列表的参数和sys.lua 内之前创建的参数是否一致,如果一致,则取消定时器,释放timerPool
                     rtos.timer_stop(k)
                     timerPool[k], para[k] = nil, nil
                     break
@@ -214,9 +215,9 @@ end
 -- @param fnc 定时器回调函数
 -- @return 无
 -- @usage timerStopAll(cbFnc)
-function sys.timerStopAll(fnc)
+function sys.timerStopAll(fnc)              --  停止同一回调函数所有的定时器
     for k, v in pairs(timerPool) do
-        if type(v) == "table" and v.cb == fnc or v == fnc then
+        if type(v) == "table" and v.cb == fnc or v == fnc then  -- 只判断函数名,不判断参数
             rtos.timer_stop(k)
             timerPool[k], para[k] = nil, nil
         end
@@ -229,14 +230,13 @@ function sys.timerAdvStart(fnc, ms, _repeat, ...)
     --assert(ms > 0, "sys.timerStart(Second parameter) is <= zero !")
     -- 关闭完全相同的定时器
     local arg = {...}
-    if #arg == 0 then
+    if #arg == 0 then                           -- 如果没有参数,直接停止无参的定时器
         sys.timerStop(fnc)
     else
-        sys.timerStop(fnc, ...)
+        sys.timerStop(fnc, ...)                 -- 如果有参数,停止对应的有参定时器
     end
-    -- 为定时器申请ID,ID值 1-20 留给任务,20-30留给消息专用定时器
     while true do
-        if msgId >= MSG_TIMER_ID_MAX then msgId = TASK_TIMER_ID_MAX end
+        if msgId >= MSG_TIMER_ID_MAX then msgId = TASK_TIMER_ID_MAX end  -- 这里的区别是,sys.wait 是taskTimerId,这里msgid,为什么要区分
         msgId = msgId + 1
         if timerPool[msgId] == nil then
             timerPool[msgId] = fnc
@@ -244,10 +244,10 @@ function sys.timerAdvStart(fnc, ms, _repeat, ...)
         end
     end
     --调用底层接口启动定时器
-    if rtos.timer_start(msgId, ms, _repeat) ~= 1 then return end
+    if rtos.timer_start(msgId, ms, _repeat) ~= 1 then return end    -- 如果_repeat为-1.则core,会启用一个循环定时器
     --如果存在可变参数,在定时器参数表中保存参数
     if #arg ~= 0 then
-        para[msgId] = arg
+        para[msgId] = arg       -- 存定时器参数表,为了后面判断停止定时器,或者定时器事件到时,寻找符合参数的定时器,作为判断标准
     end
     --返回定时器id
     return msgId
@@ -277,7 +277,7 @@ end
 --另一种是开启定时器时的回调函数,此形式时必须再传入可变参数...才能唯一标记一个定时器
 -- @param ... 可变参数
 -- @return number 开启状态返回true,否则nil
-function sys.timerIsActive(val, ...)
+function sys.timerIsActive(val, ...)          -- 判断定时器释放存在,其实很简单就是看timerPool 对应的id 释放为空
     if type(val) == "number" then
         return timerPool[val]
     else
@@ -311,8 +311,8 @@ function sys.subscribe(id, callback)
         for _, v in pairs(id) do sys.subscribe(v, callback) end
         return
     end
-    if not subscribers[id] then subscribers[id] = {} end
-    subscribers[id][callback] = true
+    if not subscribers[id] then subscribers[id] = {} end  
+    subscribers[id][callback] = true              -- 创建一般的订阅消息的数据结构,即每个元素里面保存的是一个回调函数
 end
 --- 取消订阅消息
 -- @param id 消息id
@@ -341,7 +341,7 @@ end
 -- @param ... 可变参数,用户自定义
 -- @return 无
 -- @usage publish("NET_STATUS_IND")
-function sys.publish(...)
+function sys.publish(...)                  -- 消息插入消息队列,在定时器任务处理完毕后,执行消息发布
     table.insert(messageQueue, {...})
 end
 
@@ -351,16 +351,16 @@ local function dispatch()
         if #messageQueue == 0 then
             break
         end
-        local message = table.remove(messageQueue, 1)
-        if subscribers[message[1]] then
+        local message = table.remove(messageQueue, 1)       -- 移除消息,并且将消息赋值给message 变量
+        if subscribers[message[1]] then                     -- 消息队列的第一个值就是订阅的id号,如果该ID 号依然存在订阅的列表内,则进行信息筛选
             local tmpt = {}
-            for callback, _ in pairs(subscribers[message[1]]) do
+            for callback, _ in pairs(subscribers[message[1]]) do   -- 遍历某个消息对应的回调函数,将回调函数,和返回的参数一一提取出到tmpt里面
                 table.insert(tmpt, callback)
             end
-            for _, callback in ipairs(tmpt) do
+            for _, callback in ipairs(tmpt) do                      -- 遍历回调列表,先判断回调属性,如果是function ,则回调回调函数
                 if type(callback) == "function" then
                     callback(unpack(message, 2, #message))
-                elseif type(callback) == "thread" then
+                elseif type(callback) == "thread" then              -- 如果是thread(即协程),则恢复挂起的协程,一般是waituntil函数,这里有个问题,为何不是sys.wait?
                     sys.coresume(callback, unpack(message))
                 end
             end
@@ -368,6 +368,10 @@ local function dispatch()
     end
 end
 
+local function sss()
+    print()
+end
+
 -- rtos消息回调
 --local handlers = {}
 --setmetatable(handlers, {__index = function() return function() end end, })
@@ -384,28 +388,28 @@ end
 ------------------------------------------ Luat 主调度框架  ------------------------------------------
 function sys.safeRun()
     -- 分发内部消息
-    dispatch()
+    dispatch()                              -- 内部消息的分发和定时器消息交替进行
     -- 阻塞读取外部消息
-    local msg, param, exparam = rtos.receive(rtos.INF_TIMEOUT)
+    local msg, param, exparam = rtos.receive(rtos.INF_TIMEOUT)     -- 第一个是消息类型(目前只有定时器消息),param,是定时器消息的ID 号,exparam,判断是是否是循环定时器
     --log.info("sys", msg, param, exparam, tableNSize(timerPool), tableNSize(para), tableNSize(taskTimerPool), tableNSize(subscribers))
     -- 空消息?
     if not msg or msg == 0 then
         -- 无任何操作
     -- 判断是否为定时器消息,并且消息是否注册
     elseif msg == rtos.MSG_TIMER and timerPool[param] then
-        if param < TASK_TIMER_ID_MAX then
+        if param < TASK_TIMER_ID_MAX then           -- 这里都是task 的内部等待
             local taskId = timerPool[param]
             timerPool[param] = nil
             sys.coresume(taskId)
-        else
-            local cb = timerPool[param]
+        else                                        -- 这里收到的是定时器消息
+            local cb = timerPool[param]             -- 获取回调函数
             --如果不是循环定时器,从定时器id表中删除此定时器
             if exparam == 0 then timerPool[param] = nil end
             if para[param] ~= nil then
-                cb(unpack(para[param]))
+                cb(unpack(para[param]))            -- 回调含参数的定时器函数
                 if exparam == 0 then para[param] = nil end
             else
-                cb()
+                cb()                                -- 直接回调定时器函数
             end
             --如果是循环定时器,继续启动此定时器
             --if loop[param] then rtos.timer_start(param, loop[param]) end
@@ -488,7 +492,7 @@ local taskList = {}
 -- @return co  返回该任务的线程号
 -- @usage sys.taskInitEx(task1,'a',callback)
 function sys.taskInitEx(fun, taskName, cbFun, ...)
-    taskList[taskName]={msgQueue={}, To=false, cb=cbFun}
+    taskList[taskName]={msgQueue={}, To=false, cb=cbFun}      --  相对于taskinit ,增加了一个taskname
     return sys.taskInit(fun, ...)
 end