bdring / Grbl_Esp32

A port of Grbl CNC Firmware for ESP32
GNU General Public License v3.0
1.68k stars 529 forks source link

Support RFC2217 #60

Open Harvie opened 5 years ago

Harvie commented 5 years ago

rfc2217 is telnet extension for acessing remote serial line. Maybe it would be usefull to implement, because there are drivers (for most operating systems) to attach such terminal server as local serial port, so it can be used by any software which supports local serial ports.

https://tools.ietf.org/html/rfc2217

luc-github commented 5 years ago

Do you have example for such drivers ?

Harvie commented 5 years ago

I've done some more research today and i've found they are probably not really drivers. They are just userspace programs, that somehow manage to add new fake device. I've written all my observations here:

https://github.com/vlachoudis/bCNC/wiki/Remote-Machine

luc-github commented 5 years ago

FYI :

luc-github commented 5 years ago

Sorry to ask, I am not expert so what would be the benefit of rfc2217 for GRBL_ESP32 vs RawTCP ?

GRBL_ESP32 only read and write data, so RawTCP should be enough, but I may be wrong.

@bdring : Does GRBL_ESP32 could handle control lines, what would the benefit if yes ?

bdring commented 5 years ago

What control lines? Hardware flow control?

luc-github commented 5 years ago

control lines are RTS / CTS /DTR /DSR, so yes hardware flow control I think

bdring commented 5 years ago

Yes, but I don't think it is a good idea. The USB-serial on dev boards is not wired that way. It is probably not worth the extra I/O. RTS and DTR are used for bootloader

luc-github commented 5 years ago

Ok understood - thank you

Harvie commented 5 years ago

The USB-serial on dev boards is not wired that way.

I think that telnet "serial" interface of esp32 grbl is not wired at all, so settings of baudrate and flow control might be completely irrelevant. I've done some research and i think the virtual serial might work out of the box on current grbl esp32 (as long as it has grbl serial available over telnet). Maybe this would be worth of mentioning in documentation.

Is there somebody, who can try it? I don't have windows to try it.

On linux it should be easy:

socat pty,link=/dev/ttyS23 tcp:hostname:port

Harvie commented 5 years ago

BTW how am i supposed to hard reset ESP32 Controller over that TCP serial? Currently in bCNC we reset arduino by pulsing DTR pin. I need some alternative for this in order to add telnet support to bCNC.

bdring commented 5 years ago

The esptool.py program that is used to program ESP32 dev boards via bootloader uses DTR and RTS. See this piece of the schematic on how to do that. you just need to pull EN low.

image

There is also a [ESPxxx] command to do it. (WebUI branch)

[ESP444]RESTART pwd=<admin/password>

Harvie commented 5 years ago

See this piece of the schematic...

That applies when you connect to ESP32 using usb/serial. You need to differentiate between serial and telnet. There are no serial wires when running g-code over Wifi.

bdring commented 5 years ago

[ESP444]RESTART pwd=<admin/password>

bdring commented 5 years ago

What is the purpose of the reset? Do you just need to reset Grbl or the ESP32? You will lose your Telnet connection if you do that.

Would you like to join our Slack channel?

Harvie commented 5 years ago

Talking about arduino: In bCNC we have two buttons "soft reset" (ctrl+x) and "hard reset" (DTR pulse). When something gets screwed and i get to the "Alarm" state it needs soft reset. But sometimes stuff freezes even more and i need to do hard reset.

I suppose there will be similar issue with ESP32. I plan to implement serial over TCP support to bCNC relatively soon, but i don't know how to handle hard reset button in such case. In fact i don't even know if Ctrl+x will result in soft reset. I will need to experiment with combination of ESP32 GRBL telnet and bCNC.

Another thing that worries me is login to that telnet service. This wasn't really used on plain serial connection, so i will need to handle that. I wonder if there is some standart login protocol for telnet, so this will not require us to have separate code for ESP32 GRBL and eg. ESP32 smoothie or tiny-g (if they ever decide to implement their own telnet). Because bCNC supports more controllers than just GRBL. Maybe we should contact authors of other motion controllers (tiny-g, smoothie, marlin, etc...) to agree on some connection and auth mechanisms that will be compatible between controllers. Maybe it would even make sense to support some basic SSH connection which would handle auth stuff for us. AFAIK there are SSH implementations running on ESP32...

Would you like to join our Slack channel?

I don't have slack account. In fact i don't even really know what slack is :-) But surely i would like to be in contact with your team regarding bCNC and GRBL-ESP32 cooperation. I still have some major task to solve in bCNC before i start working on telnet support. I've just discovered that GRBL-ESP32 exists, so i wanted to start the discussion. There is surely some work to be done in the future.

luc-github commented 5 years ago

The issue I see with [ESP444]RESTART - it that will stop and restart wifi, and so telnet connection will be aborted, it means you need to reconnect after restart is done

bdring commented 5 years ago

Slack is designed for groups/teams to work in real time. It has some integration with GitHub. Try the link if you want. It is pretty easy to use. The link expires tomorrow,

terjeio commented 5 years ago

The telnet protocol as defined in RFC854 does not cover authentication. Authentication has to be implemented after the connection is established in some kind of dialog if it is needed. Telnet is a pretty basic protocol that might be used to connect to other higher level protocols, like smtp, and also to connect to "simple" socket streams - most, if not all, terminal programs supporting telnet will allow that.

I have implemented streaming over ethernet/wifi for two of my grbl-drivers, basically it is just about redirecting the serial stream to a TCP/IP stream instead. I can see the need for a hard reset as sometimes grbl does not responds to a soft reset in a menaingful way, this might be implemented by assigning a control character or escape sequence for the purpose. I would think most processors can be hard reset programmatically...

IMO it is perhaps a bit misleading to bring the telnet protocol into the discussion, it is just a side-effect that it can be used to connect to, and interact with, simple socket streams that transfers intelligble data such as the grbl data stream. A reason for this is perhaps because it is easy to just hijack the telnet port for streaming and connect to that with a terminal for testing...

The discussion could (should?) then boil down to which grbl protocol extensions that could be nice to have to support (more advanced) streaming over TCP/IP.

Harvie commented 5 years ago

Sorry for not responding, i am bit busy lately. However i have some good news.

I've just found that serial library used in bCNC already has abstraction layer with native IP support (Both RFC2217 and plain TCP). I've written some details here: https://github.com/vlachoudis/bCNC/issues/1072

So that's good starting point. You can try to connect bCNC to ESP32.

Harvie commented 5 years ago

I've proposed simple auth protocol for networked GRBL and i can add such support to bCNC. So i want to ask you for your opinions:

https://github.com/vlachoudis/bCNC/issues/1072#issuecomment-469010560

thawkins commented 4 years ago

Socat on linux is able to bind a virtual tty (/dev/ttyxxxxx) to a port on a remote system,

There is also another project that purport to be abke to do this

https://gitlab.com/lars-thrane-as/ttynvt