This implementation adds pseudo terminal (PTY) support to tcpser, allowing you to use Hayes-compatible modem functionality through a PTY device instead of requiring a physical serial port.
The -P option has been added to create or use a pseudo terminal:
-P pseudo terminal (PTY) - auto-create or specify device (e.g. /dev/pts/15)
# Create a PTY modem listening on default port 6400
./tcpser -P mymodem -s 38400
# Create a PTY modem with specific TCP port
./tcpser -P mymodem -s 38400 -p 2323# Use a specific PTY device
./tcpser -P /dev/pts/15 -s 38400
# Use a specific PTY device with custom TCP port
./tcpser -P /dev/pts/20 -s 38400 -p 2323# First modem on PTY, second on serial port
./tcpser -P modem1 -s 38400 -d /dev/ttyS0 -s 9600- Auto-Create Mode: When using
-Pwith a name hint (e.g.,-P mymodem), tcpser creates a pseudo terminal pair automatically - Specify Mode: When using
-Pwith a device path (e.g.,-P /dev/pts/15), tcpser opens the specified PTY device - Device Output: The PTY device name is displayed (e.g.,
Pseudo terminal device: /dev/pts/13) - Hayes Commands: Connect to the PTY device to send AT commands
- Network Bridge: Commands like
ATDT hostname:portestablish TCP connections
# Connect to the PTY device (replace /dev/pts/13 with your device)
minicom -D /dev/pts/13 -b 38400screen /dev/pts/13 38400# For auto-created PTY, use the device shown in tcpser output
# For specified PTY, use the device you specified
# In one terminal, read responses
cat /dev/pts/15 &
# In another terminal, send commands
echo -e "AT\r" > /dev/pts/15
echo -e "ATDT example.com:23\r" > /dev/pts/15# Create a PTY pair with socat for testing
socat -d -d pty,raw,echo=0 pty,raw,echo=0
# Use one of the PTY devices with tcpser
./tcpser -P /dev/pts/16 -s 38400AT- Basic attention command (should respond "OK")ATZ- Reset modem to default settingsATDT hostname:port- Dial/connect to a TCP host and portATDT hostname- Connect to host on default port 23 (telnet)ATH- Hang up connectionATA- Answer incoming call+++- Escape sequence to return to command mode
AT
OK
ATDT towel.blinkenlights.nl:23
CONNECT 38400
[Star Wars ASCII animation plays]
+++
OK
ATH
NO CARRIER
-
New Files:
src/pty.h- PTY interface definitionssrc/pty.c- PTY implementation
-
Modified Files:
src/dce.h- Added PTY support to DCE configurationsrc/dce.c- Integrated PTY functions into DCE layersrc/init.c- Added-Pcommand line optionMakefile- Added PTY source files and -lutil library
- Automatic PTY Creation: Uses
openpty()to create master/slave pair - Control Line Simulation: Simulates DTR/DCD for compatibility
- Hayes Protocol: Full compatibility with existing Hayes command set
- Flow Control: Supports software flow control (XON/XOFF)
- Multi-modem: Can be combined with serial and IP232 modems
- No Hardware Required: Works without physical serial ports
- Container Friendly: Perfect for Docker/containerized environments
- Testing: Ideal for development and testing scenarios
- Retro Computing: Enables vintage systems to connect via modern networks
- BBS Systems: Allows old BBS software to accept network connections
- Ensure you have permissions to create PTY devices
- Check that
/dev/ptsis mounted and accessible
- Verify the PTY device name in the tcpser output
- Ensure line endings are correct (use
\rnot\n) - Check that the terminal application supports the baud rate
- Verify the target host and port are accessible
- Check firewall settings
- Ensure tcpser is listening on the correct port
The PTY support requires the util library:
make clean
makeOn some systems, you may need to install development packages:
# Ubuntu/Debian
sudo apt-get install libutil-dev
# CentOS/RHEL
sudo yum install libutempter-devel