From 62b07985e0df7b544446fbbfcd09ab17fe0b28cb Mon Sep 17 00:00:00 2001 From: TMDevel89 <39184377+TMDevel89@users.noreply.github.com> Date: Mon, 12 Aug 2024 00:05:16 +0200 Subject: [PATCH] fix(luacode): disable echo on upload and download According to the technical details for upload points 2 and 8 without function According to the technical details for download points 2 and 9 without function fixes #99 closes #99 --- nodemcu_uploader/luacode.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nodemcu_uploader/luacode.py b/nodemcu_uploader/luacode.py index 0acdbc3..852e6a6 100644 --- a/nodemcu_uploader/luacode.py +++ b/nodemcu_uploader/luacode.py @@ -22,11 +22,13 @@ function recv() local on,w,ack,nack=uart.on,uart.write,'\6','\21' local fd + local _print = print; print = function() end + local function enablePrint() print,_print=_print,nil end local function recv_block(d) local t,l = d:byte(1,2) - if t ~= 1 then w(0, nack); fd:close(); return on('data') end + if t ~= 1 then w(0, nack); fd:close(); enablePrint(); return on('data') end if l >= 0 then fd:write(d:sub(3, l+2)); end - if l == 0 then fd:close(); w(0, ack); return on('data') else w(0, ack) end + if l == 0 then fd:close(); enablePrint(); w(0, ack); return on('data') else w(0, ack) end end local function recv_name(d) d = d:gsub('%z.*', '') d:sub(1,-2) file.remove(d) fd=file.open(d, 'w') on('data', 130, recv_block, 0) w(0, ack) end on('data', '\0', recv_name, 0) @@ -40,6 +42,8 @@ function send(f) uart.on('data', 1, function (data) local on,w=uart.on,uart.write local fd + local _print = print; print = function() end + local function enablePrint() print,_print=_print,nil end local function send_block(d) l = string.len(d) w(0, '\001' .. string.char(l) .. d .. string.rep('\0', 128 - l)) return l end local function send_file(f) local s, p @@ -48,12 +52,12 @@ if data == '\006' and p