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 to connect to a module via TCP & telnet server #35

Merged
merged 4 commits into from Nov 5, 2015
Merged

Add support to connect to a module via TCP & telnet server #35

merged 4 commits into from Nov 5, 2015

Conversation

ghost
Copy link

@ghost ghost commented Nov 5, 2015

Add a lua telnet server that can be run on the nodemcu device. The luatool.py was extended to offer exchangeable transports (serial and tcp) to support all features also via remote telnet sessions.

Joachim Lusiardi and others added 4 commits November 1, 2015 22:08
Merge pull request #34 from shing19m/master
The first implementation of a transport is the already known
serial port.
This adds support to use a telnet server on the nodemcu based
module. The same commands as with serial transport work but
beware, do NOT break the telnet server.
Update the README.md to explain the use of the option to connect
to the module based on TCP.
@4refr0nt
Copy link
Owner

4refr0nt commented Nov 5, 2015

Thanks for you work!
Please, increment version number and add change log

4refr0nt added a commit that referenced this pull request Nov 5, 2015
Add support to connect to a module via TCP & telnet server
@4refr0nt 4refr0nt merged commit 1efbb0c into 4refr0nt:master Nov 5, 2015
@ghost
Copy link
Author

ghost commented Nov 5, 2015

Hi Eku,

can you provide your telnet server code? Or try using the telnet server from this project and try again.

Regard
J

@eku
Copy link

eku commented Nov 6, 2015

I'm using the telnet server code from the luatool project.

@ghost
Copy link
Author

ghost commented Nov 6, 2015

Ok, I am puzzled.

  1. Does the direct telnet list all files you got on the device like directly talking to it via serial port? Or does it also just stop after name:init.lua, size:468?

  2. I may not matter, but Welcome to esp1 running NodeMCU! is not the default welcome message of the supplied telnet server code. Any other modifications?

  3. you run the which nodemcu version? I tested with nodemcu_integer_0.9.6-dev_20150704.bin

@eku
Copy link

eku commented Nov 6, 2015

  1. yes, it returns only one line. But the telnet session still responds to further Lua commands.
  2. I changed the banner. That's all.
  3. I'm using the dev branch of nodemcu, i.e. SDK 1.4, self compiled

@ghost
Copy link
Author

ghost commented Nov 6, 2015

can you publish the output of

  • ./luatool/luatool.py --port /dev/your tty -l | hexdump -C
  • ./luatool/luatool.py --ip 192.168.33.131 -l | hexdump -C
  • echo "local l = file.list();for k,v in pairs(l) do print('name:'..k..', size:'..v)end" | nc -w 1 192.168.33.131 23 | hexdump -C

this might help me a little

@ghost ghost mentioned this pull request Nov 7, 2015
@eku
Copy link

eku commented Nov 8, 2015

@shing19m : Please find the output at https://gist.github.com/eku/1b018e2f49e98a7b8ada

The udpatesrv.lua and sendfile.py from https://github.com/tjclement/esp-common work for me.

@ghost
Copy link
Author

ghost commented Nov 9, 2015

Hi,

esp-common's updatesrv.lua fails with line srv:on("receive", onReceive) because of method not supported. So i cannot verify this.

The only clue I got from your files, is that (as in the original code) my code waits for some '>' appear as prompt (either via serial port or socket). The serial port code just continues but the socket code hangs.

Sadly i cannot reproduce this with my setting here.

can you try the attached diff?

diff --git a/luatool/luatool.py b/luatool/luatool.py
index 41a01d3..2ce8ec6 100755
--- a/luatool/luatool.py
+++ b/luatool/luatool.py
@@ -144,7 +144,10 @@ class TcpSocketTransport(AbstractTransport):
             sys.stdout.write(" -> send without check")

     def read(self, length):
-        return self.socket.recv(length)
+        data = self.socket.recv(length)
+        if not data:
+            return ''
+        return data

     def close(self):
         self.socket.close()

And, sorry to say, I am a little clue less...

@eku
Copy link

eku commented Nov 10, 2015

esp-common's updatesrv.lua fails with line srv:on("receive", onReceive) because of method not supported. So i cannot verify this.

updatesrv.lua uses UDP which has a slighlty different NodeMCU API than TCP.

The latest SDK and NodeMCU dev branch requires a strict event driven programming as discussed in this NodeMCU issue. This would explain why I see only the first line of the output from the fsinfo test program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants