Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for esp32 'console' module #101

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/connector/list-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const knownVendorIDs = [

// FTDI232 adapter | Product ID 6001
'0403',

// Espressif chips
"303A",
];

// show connected serial devices
Expand Down
8 changes: 4 additions & 4 deletions lib/lua/esp32-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;