Telnet Server
Re: Telnet Server
As far as I could tell, importing & starting the telnet server reduced the free memory by 1616 bytes, and it's not frozen bytecode. As frozen bytecode, it's 640 bytes.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Telnet Server
Oops, sorry. Brain fade yesterday. Some figures based on frozen bytecode on the reference board.
Accessing via USB:
After import, usage 480 bytes
After starting server 608 bytes.
I then edited main.py to run it at boot, power cycled the board and accessed it over WiFi via Telnet. Usage (relative to the free RAM reported in the first test) was 1408 bytes.
Accessing via USB:
After import, usage 480 bytes
After starting server 608 bytes.
I then edited main.py to run it at boot, power cycled the board and accessed it over WiFi via Telnet. Usage (relative to the free RAM reported in the first test) was 1408 bytes.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Telnet Server
This is very useful. but I have a strange problem when typing.
I am connecting to the ESP8266 module over my LAN. I am using Putty for telnet. It connects immediately and in the Putty window I see the same flow of stuff on REPL as I am seeing through the serial connection.
When I type I cannot see what I am typing!
But what I type is definitely received and acted upon by REPL...its just that I cant see it when i am typing. And this applies to BOTGH the Putty console and on the serial view - when I am typing, nothing shows.
Also, CTRL-C does not work
Any hints?
Thanks
I am connecting to the ESP8266 module over my LAN. I am using Putty for telnet. It connects immediately and in the Putty window I see the same flow of stuff on REPL as I am seeing through the serial connection.
When I type I cannot see what I am typing!
But what I type is definitely received and acted upon by REPL...its just that I cant see it when i am typing. And this applies to BOTGH the Putty console and on the serial view - when I am typing, nothing shows.
Also, CTRL-C does not work
Any hints?
Thanks
Re: Telnet Server
That seems to be a putty configuration problem. It seems to be in line edit mode. In the terminal setting of putty's configuration, set local line editing to force off. Then it works.
Re: Telnet Server
Doh!Roberthh wrote:That seems to be a putty configuration problem. It seems to be in line edit mode. In the terminal setting of putty's configuration, set local line editing to force off. Then it works.
Thanks so much - works perfectly.
Re: Telnet Server
Very useful! Thank you for writing and sharing it.
Re: Telnet Server
Will this telnet server (or any other telnet) work with the standard (official) ESP32 microphython port?
[ I've been using the Pycom and the Loboris ports for this feature; both are (more or less) subtly different from standard microphython. ]
Bernhard
[ I've been using the Pycom and the Loboris ports for this feature; both are (more or less) subtly different from standard microphython. ]
Bernhard
Bernhard Boser
Re: Telnet Server
I've tried this now on an ESP32 and it doesn't work, getting this error:
Code: Select all
Traceback (most recent call last):
File "utelnetserver.py", line 81, in accept_telnet_connect
OSError: stream operation not supported
Anyway I've come to a conclusion that I want telnet on my ESP32 because it would work much more smooth compared with the webrepl, so I'll keep you updated once I get this working
Re: Telnet Server
The change is simple. According to the hint here viewtopic.php?f=8&t=5868&p=33586&hilit=dupterm#p33586 add
to the import section and change
into
as shown below in the code snippet:
Code: Select all
from uio import IOBase
Code: Select all
class Telnetserver()
Code: Select all
class Telnetserver(IOBase)
Code: Select all
import socket
import network
import uos
import errno
from uio import IOBase
last_client_socket = None
server_socket = None
# Provide necessary functions for dupterm and replace telnet control characters that come in.
class TelnetWrapper(IOBase):
def __init__(self, socket):
self.socket = socket
self.discard_count = 0
Re: Telnet Server
Roberthh wrote: ↑Thu Feb 21, 2019 8:30 pmThe change is simple. According to the hint here viewtopic.php?f=8&t=5868&p=33586&hilit=dupterm#p33586 addto the import section and changeCode: Select all
from uio import IOBase
intoCode: Select all
class Telnetserver()
as shown below in the code snippet:Code: Select all
class Telnetserver(IOBase)
Code: Select all
import socket import network import uos import errno from uio import IOBase last_client_socket = None server_socket = None # Provide necessary functions for dupterm and replace telnet control characters that come in. class TelnetWrapper(IOBase): def __init__(self, socket): self.socket = socket self.discard_count = 0
Thanks! That really fixed it.
I was puzzled by this as I didn't realize which magic connects my object with its `write`, `readinto` methods to what `mp_uos_dupterm` accepts. `iobase_read` and `iobase_write` were what I missed...
The `uos.dupterm` should definitely be updated so people won't have to look in the code next time..