재 프로그래밍 능력 : 내가 킷에는 UART 모듈을 사용하고 있기 때문에,ESP8266 Tcp를 - 투 - UART 내가 nodemcu의 REPO에서이 예를 사용하고
uart.setup(0,9600,8,0,1,0)
sv=net.createServer(net.TCP, 60)
global_c = nil
sv:listen(9999, function(c)
if global_c~=nil then
global_c:close()
end
global_c=c
c:on("receive",function(sck,pl) uart.write(0,pl) end)
end)
uart.on("data",4, function(data)
if global_c~=nil then
global_c:send(data)
end
end, 0)
을하지만, 나는 더 이상 내 칩과 통신 할 수 있어요 LuaLoader를 통해 업데이트 된 파일 init.lua
을 업로드 할 수 없습니다. 대신 칩을 플래시 업로드 모드로 설정 한 다음 초기 노드 카드 펌웨어를 플래시 한 다음 업데이트 된 init.lua
을 플래시해야합니다. 너무 많은 단계.
LuaLoader를 통해 통신하는 기능은 어떻게 유지할 수 있습니까?
이uart.on('data', '\n', handleUartResponse, 0)
...
...
function handleUartResponse(response)
if response == 'flash\n' then
g_flash = true
toggleOutput(true)
uart.write(0, 'flash mode')
elseif response == 'endflash\n' then
g_flash = false
uart.write(0, 'normal mode')
toggleOutput(false)
elseif g_flash then
node.input(response)
else
if g_conn ~= nil then
g_conn:send(response, function(sock)
closeConnection(sock)
g_conn = nil
end)
end
end
end
function toggleOutput(turnOn)
if turnOn then
node.output(nil, 1)
else
node.output(silent, 0)
end
end
그것은 또 다른 시리얼 터미널에서 flash mode
및 normal mode
를 인쇄하지만 LuaLoader에서 작동하지 않습니다 :이 같은 뭔가를 시도했습니다. 나는 문제가 uart 설치에 있다고 생각하지만 어쩌면 그것은 \n
이되어서는 안된다. 그러나 다른 조건은 무엇인지 모른다.