EmbeddedRelated.com
Forums

Linux Readile library through telnet

Started by Alexander Baranov August 13, 2004
Grant Edwards wrote:

> We don't know if he _has_ a shell on his SBC, if he's running any > sort of init or getty, or ...
He started the question off with "In my Linux program..." so I sort of assumed he was, well, running Linux. My apologies if my assumption was unwarranted. Kelly
Aleksandr Baranov wrote:

[...]

> > Well. I would better explain from the beginning. I will have a single board > computer with Linux, which will receive data from serial port, process it > and transfer through Ethernet. It will not have keyboard and monitor. > Somehow from time to time will I have to issue commands to it. I decided to > do it using Ethernet connection. I'm going to create a simple TCP server > and bind it with a stream. I decided to use port 123. Then I will connect > notebook to the network and run "telnet <IP address> <port> on it. Now my > notebook's telnet is ready to send characters and my SBC computer starts > receiving these characters from the stream associated with TCP server. My > program has to handle incoming characters from remote telnet console > characters, handle left and right arrows, DELs, BS etc. On getting CR the > obtained string has to be processed by parser.
Ah, much better. I think I see where there is some confusion, or maybe the wrong (or harder) approach. Using readline is fairly easy, although it seems a little crufty. And it is GPL, not LGPL, so when you link with it you are under the GPL (if you care). Readline and curses go together somewhat (I can't remember if curses is required). And curses is way crufty. I recommend the approach of composing and editing the lines in the terminal window, and sending only the completed line to the server. If you want to capture and send individual keys to the server, then readline becomes less useful or even precluded. Readline is line oriented. If you want to process and send individual keys, then you probably have much work to do, and I would not recommend doing that without a very good reason.
> While I was in the middle of this work I was told that the readline library > does all this routine work and all, that I have to do is to install it and > make it work with stream rather than with standard input and output.
I think you want it to work with the standard in and terminal disciplines, the way you describe. human|keyboard|readline+curses|term prog|write|TCP-----------TCP|read|server ||| display human|display|curses|term prog|read|TCP----------------------TCP|write|server
> I installed the library, it works fine with standard console, but I cannot > make it receive characters from stream. Instead it outputs warning: > "rl_prep_terminal: cannot get terminal settings." > > Thats the whole story. > >
-- ------------------------------------------------------------ Creepy, Soulless Gigolo for President ? NOT ! --------------------------------------------- THK is one weird, weird something.