Skip to content

Linux (Debian): Can write to Serial Port but cannot read #6972

Description

@no-sense

Checklist

  • I have searched the issue tracker and was unable to find an open or closed issue matching what I'm seeing.
  • I have verified that the issue is happening in the latest nightly build, or the latest commit, if building from source.

What happened?

This is the same problem as reported in issue #3224 which was closed after issue #3691 was fixed.

While fixing the serial flags made it work a lot better, one very important flag was not added. This is the flags CREAD in c_cflags which is the flag to enable the receiver.
In my system (Debian 12) the RS-232 receiver is not by default enabled and must be enabled manually to receive any bytes from the serial port. Note: I am using a real RS-232 port, not a USB to serial device.

The following almost-oneliner fixes the issue (patch made on latest master):

diff --git a/src/unix/unix_serial_passthrough.c b/src/unix/unix_serial_passthrough.c
index 0fcfbe5b1..6d61701e1 100644
--- a/src/unix/unix_serial_passthrough.c
+++ b/src/unix/unix_serial_passthrough.c
@@ -223,6 +223,10 @@ plat_serpt_set_params(void *priv)
#endif
}
term_attr.c_iflag &= ~(IXON | IXOFF);
+

  •    /* Enable receiver */
    
  •    term_attr.c_cflag |= CREAD;
    
  •    tcsetattr(dev->master_fd, TCSANOW, &term_attr);
    

#undef BAUDRATE_RANGE
}

It was not tested on other unix/linux flavors but the fix is in my opinion extremely low-risk

Configuration file

[ATI Mach64GX ISA]
memory = 4

[General]
host_cpu = AMD Ryzen 9 5900X 12-Core Processor
uuid = 5e6630e5-5982-5674-8faa-5082bd4e0c92
vid_renderer = qt_software

[Machine]
cpu_family = i486dx
cpu_multi = 1
cpu_speed = 33333333
cpu_use_dynarec = 0
fpu_type = internal
machine = 486sp3g
mem_size = 32768

[Video]
gfxcard = mach64gx_isa

[Input devices]
keyboard_type = keyboard_at
mouse_type = ps2

[Sound]
sndcard = sb16

[Storage controllers]
hdc_1 = ide_pci_2ch

[Hard disks]
hdd_01_fn = ../../486-freedos.vhd
hdd_01_ide_channel = 0:0
hdd_01_parameters = 63, 16, 4095, 0, ide
hdd_01_speed = ramdisk
hdd_01_vhd_blocksize = 4096

[Floppy and CD-ROM drives]
cdrom_01_ide_channel = 0:1
cdrom_01_image_history_01 = /home/eric/src/DOS/FreeDOS14/FD14LIVE.iso
cdrom_01_image_history_02 = /home/eric/src/DOS/simtel.iso
cdrom_01_image_history_03 = /home/eric/src/DOS/1-57176-081-4_Best_of_Walnut_Creek_1995-04.iso
cdrom_01_image_path = /home/eric/src/DOS/FreeDOS14/FD14BNS.iso
cdrom_01_parameters = 1, atapi
cdrom_01_type = nec_280
fdd_01_fn = /home/eric/src/DOS/Telix/telix.img
fdd_01_image_history_01 = /home/eric/src/DOS/tlx351fe.zip.img
fdd_01_image_history_02 = /home/eric/src/DOS/Borland Turbo C++ 3.0 (3.5)/Disk05.img
fdd_01_image_history_03 = /home/eric/src/DOS/Borland Turbo C++ 3.0 (3.5)/Disk04.img
fdd_01_image_history_04 = /home/eric/src/DOS/Borland Turbo C++ 3.0 (3.5)/Disk03.img
fdd_01_image_history_05 = /home/eric/src/DOS/Borland Turbo C++ 3.0 (3.5)/Disk02.img
fdd_01_image_history_06 = /home/eric/src/DOS/Borland Turbo C++ 3.0 (3.5)/Disk01.img
fdd_01_image_history_07 = /home/eric/src/DOS/iomega.img
fdd_01_image_history_08 = /home/eric/src/DOS/z2i35059.img
fdd_01_image_history_09 = /home/eric/src/DOS/aspi.img
fdd_01_image_history_10 = /home/eric/src/DOS/pwb.img
fdd_01_type = 35_2hd
fdd_02_image_history_01 = /home/eric/src/DOS/FreeDOS14/120m/x86BOOT.img
fdd_02_type = 525_2hd

[Other removable devices]
rdisk_01_image_path = /home/eric/src/DOS/iomega250.zdi
rdisk_01_parameters = 2, scsi
rdisk_01_scsi_location = 0:06

[PS/2 Mouse]
buttons = 2

[3Com EtherLink II #1]
base = 0300
irq = 3
dma = 3
mac = e7:92:4d
bios_addr = CC000

[Network]
net_01_card = 3c503
net_01_host_device = /tmp/vde.tap0
net_01_net_type = vde

[Serial Passthrough Device #1]
mode = 3
host_serial_path = /dev/ttyS5
data_bits = 8
stop_bits = 1
baudrate = 115200

[Ports (COM & LPT)]
serial1_passthrough_enabled = 1

Operating system

Debian 12

86Box version

"86Box v6.0 [x86_64, old dynarec]" git branch master

Build architecture

Linux - x64 (64-bit)

Build type

  • New recompiler
  • Debug build

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions