I felt that it was important that my Sol-20 reproduction work with a real HW Serial port. It is the Sol Terminal Computer after all. I thought that adding an RS-232 Serial hat like I did for my VT100 reproduction would complicate things since I was already using a Voltage-Level Shifter Module hat for the keyboard. So I purchased a USB to Serial Converter from Amazon.
I found that the version of Raspberry PI OS that I was using recognized this device without having lo load any drivers. I did have to figure out what the device name was. I did this by listing all of the USB devices.
pi@raspberrypi:~ $ ls /dev/*USB* /dev/ttyUSB0 pi@raspberrypi:~ $
Then it was a pretty simple process to integrate /dev/ttyUSB0 into my emulator using the Python serial library.
pip install pyserial
I won't go into too many details here, but on a Sol-20 the serial port works just like keyboard. When the Sol-20 monitor program is waiting for a character from the serial port, it will make repeated IN requests to port 0xF8 to fetch the Serial Status Port. If there is a character in the port's input buffer I return the 8-bit status result with the Serial Data Ready (SDR) bit (0x40) "set" otherwise that bit will be "cleared". When it "sees" that there is a character ready, the monitor program will make a subsequent IN request on port 0xF9 to fetch the character which I then returned from the serial port's buffer. Similarly if the monitor wants to send a character to the serial port, it checks port 0xF8 with an IN to see if the Serial Transmit Buffer is Empty (STBE) bit (0x80) is "set" and if so an OUT to port 0xF9 is issued with the character to send which I write to the serial ports output buffer.
I wired the TX, RX, and GND from the USB Serial Converter to the DB9 connector.