Telnet example issues: packages lost during frequent sends
Posted: Sat Dec 19, 2015 9:41 am
It seem that for the telnet example posted on the nodeMCU.com official site does not work if I have several consecutive prints. Only the first line is sent, and it is actually sent without the end-of-line character.
I am using a custom build from http://nodemcu-build.com/ , and is running on ESP-01
When I used it with an older 0.9.6 firmware I did not encounter this problem.
I inserted a UART write in the s_output(str) function for debugging and noticed that this function receives the contest string and the end-of-line character in two separate calls. This might be fine with default UART, but I think is quite unreasonable for redirected TCP communications??
Is this a problem with the nodeMCU net library or should I implement some sort of buffer and waiting mechanism for the telnet server myself??
Help appreciated!!
My telnet code:
And on my laptop I wrote a node.js script to show what is received (only the first line):
The same issue is there for Win7 telnet and also an android telnet app.
I am using a custom build from http://nodemcu-build.com/ , and is running on ESP-01
NodeMCU custom build by frightanic.com
branch: master
commit: 432f698fd80e0ff90ea4f209b66c77d5105ea55a
SSL: false
modules: node,file,gpio,wifi,net,tmr,uart,ow,dht,rtctime,sntp
build built on: 2015-12-18 03:59
powered by Lua 5.1.4 on SDK 1.4.0
When I used it with an older 0.9.6 firmware I did not encounter this problem.
I inserted a UART write in the s_output(str) function for debugging and noticed that this function receives the contest string and the end-of-line character in two separate calls. This might be fine with default UART, but I think is quite unreasonable for redirected TCP communications??
Is this a problem with the nodeMCU net library or should I implement some sort of buffer and waiting mechanism for the telnet server myself??
Help appreciated!!
My telnet code:
Code: Select all
s=net.createServer(net.TCP,180)
s:listen(23,function(c)
function s_output(str)
if(c~=nil) then
c:send(str, function() uart.write(0,"*sent\n") end)
end
uart.write(0,"\n*rec:\n"..str)
end
node.output(s_output, 0)
-- re-direct output to function s_ouput.
c:on("receive",function(c,l)
node.input(l)
end)
c:on("disconnection",function(c)
node.output(nil)
--unregist redirect output function, output goes to serial
end)
print("Welcome to NodeMCU world.")
print("Hello world 1")
print("Hello world 2")
print("Hello world 3")
end)
And on my laptop I wrote a node.js script to show what is received (only the first line):
Connected
From Socket:192.168.0.105 : 23
Welcome to NodeMCU world.
The same issue is there for Win7 telnet and also an android telnet app.