Open heroin-moose opened 1 year ago
I'm a bit undecided on the feature of letting tio be able to connect to sockets. I mean, if you want to connect to a UNIX socket you could easily do so with nc -U <socket>
. Of course, that will give you a raw connection and you won't have any of tio's features available (line time stamping, hex mode, local echo, mappings, auto connect, etc.).
That being said, tio already supports redirecting serial I/O to a socket using e.g. tio --socket unix:test-socket-0
. Likewise tio could be used to connect to the same socket via a similar syntax tio unix:test-socket-0
, tio inet:192.168.0.42:3333
, etc. This way tio can be used end to end for sharing serial ports.
On the other hand, there is the principle of letting one tool do one thing well, namely connecting to serial ports.
Sadly nc -U <socket>
can't handle complex TTY features, can't handle escapes, echoes back passwords and so on. It is possible to run minicom -D unix#test.sock
or socat
with right flags, but I was thinking about replacing minicom with tio so this feature kinda felt natural. But of course I understand that this is not the primary focus of tio.
After some more consideration I think it makes sense to support connecting to a socket as that will make tio be able to both serve a serial port via a socket and connect to it - it will be an end to end solution. In short we will be able to do the following:
Host serial port on socket:
tio --socket unix:/tmp/tio-socket-0 /dev/ttyUSB0
Connect to same socket:
tio unix:/tmp/tio-socket-0
However, getting there is a bit more involved. I'm making a TODO list here, mostly for my own reference.
Besides a bit of refactoring the following changes spring to mind:
tio unix:<filename>
tio inet:<ip>:<port>
tio inet6:<ip>:<port>
It would be really great to have unix socket support. nc -U ...
is barely functional and minicom is a bit dated and limited. Key use case is of course QEMU.
Wonderful! Given your list of changes, can you update the issue title to also mention TCP? I came here to request that only to see you already considered it part of this request :)
I'm not sure if this should be a separate issue, but if TCP support is planned, could RFC 2217 be a feature alongside TCP? TLDR on RFC2217: it's an extension to telnet that allows a client to specify COM port parameters to a server. Example being the client wanting to change the baud rate on a console server in real time. And I don't know of a real world use, but maybe UDP too, instead of just TCP.
@Zorbatron That is possible but first things first. It can be added if there is a demand for it.
RFC 2217 would definitely be the way to go for TCP connections, would allow connecting to ser2net, proprietary TCP serial gateways, etc.. I would certainly love it!
Connecting to UNIX sockets comes in be handy with QEMU, for example. Like when you have a bunch of VMs and want to connect to a serial console:
Quick POC shows that everything works, I'm able to read/write to a serial console with a simple diff:
However it's necessary not call all TTY-related or else everything goes boom. I suspect that it's best to factor out two functions , one for each method. Anyway, if you are okay with the idea, I'll make a proper merge request.