VOGONS


First post, by pengo

User metadata
Rank Newbie
Rank
Newbie

Hi I'm new here but often found the information around here amazingly well researched.

There are a lot of Morse code related DOS programs that ignore what serial ports are usually used for and just use a couple of serial port pins to receive or send Morse code signals, e.g. just shorting and breaking a connection to produce Morse code. These pins have names like Clear-to-Send (CTS) and Data Set Ready (DSR) and are meant for flow control, but they're used by amateur radio software for sending morse code signals or to wire up a morse code key or paddles to a PC without ever setting a baud rate or agreeing on parity bits. [They're still used this way in modern Windows software too] Here's one random example of such a program that sends Morse on a serial port without touching the data pins: mpp-110a https://archive.org/details/mpp-110a

I made a simple sidetone generator (https://github.com/pengowray/upsidetone/) that DOS programs can connect to via a pair of virtual com0com serial ports on windows, but while it works for me, I'm not happy with the mess of extra virtual serial ports that my imaginary users would have to install and configure to get going. [In the distant future I'd like to find a way to create a virtual interface for dosbox serial ports for when it's embedded on a web page]

Trying to work out if I could connect more directly using the ENET UDP protocol that dosbox supports. I _can_ find docs and libraries for ENet, but not anything on how Dosbox uses it. Please save me from having to reverse engineer the dosbox code or snoop the connections myself. Does/can dosbox send events when non-data pins are toggled (CTS DSR DTR RTS) or is it only for higher level data transmission? Thanks

Reply 1 of 3, by superfury

User metadata
Rank l33t++
Rank
l33t++

Dosbox (UniPCemu as well) supports the nullmodem feature (a simple nullmodem cable over TCP). UniPCemu can even be configured to either honor or ignore the lowering of DTR (lowering DTR for disconnecting being optional). Raising DTR can automatically connect to the other side in UniPCemu (using the first phonebook entry to connect to some other location or client). UniPCemu can also connect to the other side manually (through the settings menu) or automatically(using DTR raising detection combined with the first phonebook entry). UniPCemu can also manually disconnect using the settings menu as well.
Both will use the Dosbox's method of relaying DTR and RTS to the other side's DSR and CTS using the FFh escape bytes.
Although UniPCemu only updates the speed of the outgoing and incoming transfers at a speed of the baudrate divided by the byte transfer timing.

Edit: Just adjusted the timing for the passthrough lines in UniPCemu to send the status to the other side ASAP (not taking any timing for the hardware into account). Although this isn't a released feature yet.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 2 of 3, by jmarsh

User metadata
Rank Oldbie
Rank
Oldbie
pengo wrote on 2022-10-26, 21:20:

Does/can dosbox send events when non-data pins are toggled (CTS DSR DTR RTS) or is it only for higher level data transmission? Thanks

It does because those signals are necessary for proper serial port communication. The actual implementation depends which type of serial port emulation is being used. For example for null-modem emulation:
- "transparent" mode simply disables the extra signals and passes characters straight through the UDP socket
- non-transparent mode uses 0xff as an escape character; two consecutive received 0xff translates to one 0xff, while 0xff followed by any other byte treats the second byte as a control byte:
- control bit 0 = sets the status of CTS on the host
- control bit 1 = sets the status of DSR on the host
- control bit 2 = signals break on the host (I think)

You can see this code in CNullModem::readChar() (and also the sending equivalent CNullModem::setRTSDTR) in the file nullmodem.cpp.
There's also telnet emulation which is a more "standard" protocol but might be less suitable for your situation.

Reply 3 of 3, by pengo

User metadata
Rank Newbie
Rank
Newbie

Thanks for the replies. I've now successfully made a "nullmodem server" which DosBOX can connect to and send CTS or DSR signals, which are received and decoded as expected (I ignore everything else), and I can play as Morse code.

This proof-of-concept is a success.

I had assumed I'd need to use ENet (UDP) to help with latency, but TCP is working just fine. (And anyway I haven't found a C# ENet library that I can get to work as yet).

I will have to try testing it with UniPCemu at some point too.

Anyway, I made a 30 second demo so you could see what the hell I'm talking about: https://www.youtube.com/watch?v=uFsMdE6Vtis

Cheers.