diff --git a/lib/connector/list-devices.js b/lib/connector/list-devices.js index f4e1f3a..07faa54 100755 --- a/lib/connector/list-devices.js +++ b/lib/connector/list-devices.js @@ -13,6 +13,9 @@ const knownVendorIDs = [ // FTDI232 adapter | Product ID 6001 '0403', + + // Espressif chips + "303A", ]; // show connected serial devices diff --git a/lib/lua/esp32-commands.js b/lib/lua/esp32-commands.js index fd2496c..4286f7d 100755 --- a/lib/lua/esp32-commands.js +++ b/lib/lua/esp32-commands.js @@ -34,10 +34,10 @@ const lua_commands = { reset: 'node.restart()', // list files on SPIFFS - listFiles: 'local l = file.list();for k,v in pairs(l) do uart.write(0,k..":"..v..";") end print("")', + listFiles: 'local l={}for k,v in pairs(file.list())do l[#l+1]=("%s:%d"):format(k,v)end;print(table.concat(l,";"))', // file open - fileOpen: '__f=io.open("?", "?") print(__f)', + fileOpen: 'local open=file.open or io.open;__f=open("?", "?") print(__f)', // close a opened file fileClose: '__f:close() __f=nil', @@ -49,13 +49,13 @@ const lua_commands = { fileCloseFlush: '__f:flush(f) __f:close() __f=nil', // read file content - fileRead: '__nmtread()', + fileRead: "local b=encoder and encoder.toBase64 __nmtread(b)", // helper function to write hex/base64 encoded content to file @see docs/TransferEncoding.md transferWriteHelper: "if encoder and encoder.fromBase64 then _G.__nmtwrite = function(s) __f:write(encoder.fromBase64(s)) end print('b') else _G.__nmtwrite = function(s) for c in s:gmatch('..') do __f:write(string.char(tonumber(c, 16))) end end print('h') end", // helper function to read hex/base64 encoded content from file @see docs/TransferEncoding.md - transferReadHelper: "function __nmtread()local b = encoder and encoder.toBase64 while true do c = __f:read(b and 240 or 1) if c==nil then print('')break end uart.write(0, b and encoder.toBase64(c) or string.format('%02X', string.byte(c)))end print('') end" + transferReadHelper: "function __nmtread(b)while true do c=__f:read(b and 240 or 1)if c==nil then print''break end;local d=b and encoder.toBase64(c)or string.format('%02X',string.byte(c))if console then console.write(d)else uart.write(0,d)end end print''end", }; module.exports = lua_commands;