When fiddling around with old computers, you can occasionally find yourself in a sticky situation. What may be a simple task with today’s hardware and software can be nearly impossible given the limited resources available to machines with 20 or 30 years on the clock. That’s where [bison] recently found himself when he needed to configure a device over serial, but didn’t have any way of installing the appropriate terminal emulator on his Fujitsu Lifebook C34S.
His solution, since he had Python 2.6 installed on the Debian 6 machine, was to write his own minimal serial terminal emulator. He intended for the code to be as terse as possible so it could be quickly typed in, should anyone else ever find themselves in need of talking to a serial device on Linux but can’t get screen
or minicom
installed.
The code is very simple, and even if you never find yourself needing to fire up an impromptu terminal, it offers an interesting example of how straightforward serial communications really are. The code opens up the /dev/ttyS0
device for reading, and after appending the appropriate return character, pushes the user’s keyboard input into it. Keep looping around, and you’ve got yourself an interactive terminal.
With this program written, [bison] was able to connect the 266 MHz C34S to his Retro WiFi SI, a modem adapter that bridges the gap between a vintage computer and modern wireless network. Gadgets like these allow you to browse BBSes as the creator intended, and can be fashioned with nothing more exotic than an ESP8266 running some open source code.
so one can get debian 6 on a lifebook but had to type in a serial terminal
“””(((…))) but can’t get screen (((…))) installed.”””
Why?
Or…
IMPOSSIBLE!
There has to be a way!
–> http://archive.debian.org/debian/dists/
So, it’s:
“cat /dev/ttyS0 &; cat > /dev/ttyS0”
But then with a lot more code?
Dumb question, but should that work on android? not sure what the devices are for the dev mode USB link or the JTAG type serial header though.
Hah, I was trying to think up some solution using netcat.
And how do you configure baudrate, data bits, parity and a lot of small but sometimes critical settings that the tty driver has? It’s not that complicated, but it’s not as simple as this. A few more LoC are needed.
only one more line of code is needed:
“stty 9600 -parenb cread cs8 cstopb < /dev/tty???"
or whatever.
Doesn’t work, because parameters get reset on every new access. That’s why one needs ‘screen’ or some trivial application.
This is a very interesting and straightforward implementation compared to PySerial. A concern I would have that maybe isn’t really an issue because of the age of the devices he’s interacting with, but in Python 3 strings are treated differently and so you’ll potentially have to deal with byte conversion and Unicode if you wanted to do something similar there.
This program is fun for laughs but it will drop characters on your old slowpoke computer if you run it at high speeds, it’s only reading one character at a time from the remote system, even worse it’s converting each character to a string and then running the formatted output function on each character. This is actually a pretty good example of how NOT to do serial communications. Please don’t take lessons from poorly written code. Owen’s comment below is on the money.
I don’t get it. Is the alternate title of this article “Person discovers serial port on old computer”?
The follow up article will be “Person discovers parallel port on computer”?
Followed by archeological excavation of “laplink” :-)
I still have a “PLIP” (LapLink(?)) cable!
But forgot whether it was PLIP4 or PLIP8… :-(
…need to check that someday.
Maybe I should send it to a computer museum?
Nah!
I still have some oldtimers with parports!
Just for fun!
Ok… If I find a double (I’m camera shy!), the “guy rediscovers IP over parport” article can be made… :-P
Well if you plug it from an old XT to a PIII laptop or something and it blows out the XTs port, it was 8 bit.
Used PLIP for lot back in the day, still can be handy.
Oh and I can’t figure out if everybody kept getting ECP and EPP confused or it was just me, because every time I see it, it’s backwards to the last time I saw it.
As mentioned above, there are multiple possible solutions for Debian…
1. screen (screen /dev/)
2. Minicom (an open source terminal emulator similar to the old MS-DOS “Telix” program)
3. kermit and/or wermit
4. Good old ‘cu’
5. putty
6. Good old ‘tip’
To make matters worse, the code above appears to be line-oriented on the host->serial side while character oriented on the serial->host side and uses two processes to do what should be done with a simple use of select() in a loop.
Did you even attempt to read? He has no way of installing additional packages on the system.
TFA makes that claim but doesn’t back it up at all. It smells like BS. If Debian was installed, of course you can install new software; the disk is clearly writable so even if apt doesn’t work for some inexplicable reason, at least dpkg -x picocom*.deb would.
You forget Picocom which might be number 2 in terms of usage. Screen was a revolution coming from the nightmare of configuring minicom.
Kudos for making it into Hackadays news with two lines of code!
Retro Wifi SI ordering link: https://www.simulant.uk/shop/retro-vintage-computer-wifi-modem-rs232-serial-hayes-compatible