瀏覽代碼

提取有效数据

xuxinyi 4 月之前
父節點
當前提交
526f9303b4
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      testSpiFlash.lua

+ 6 - 2
testSpiFlash.lua

@@ -20,8 +20,12 @@ log.info("testSpiFlash.init",result)
 sys.taskInit(function ()
     sys.wait(5000)
     while true do
-        local command = string.fromHex("1D06bc000000")
-        log.info("testSpiFlash.readFlashID",spi.send_recv(spi.SPI_1,command):toHex())--收发读写
+        local command = string.fromHex("1D0740000000") 
+        local ret = spi.send_recv(spi.SPI_1,command):toHex()
+        log.info("testSpiFlash.readFlashID",ret)--收发读写  & string.fromHex("000000FFFFFF")
+        local lastFourChars = string.sub(ret, -4)  -- 从倒数第四个字符到末尾
+        log.info("提取结果", lastFourChars)  -- 输出: 1D0F
+        
         sys.wait(2000)
     end
     spi.close(spi.SPI_1)