danielinux / ttybus

A simple TTY multiplexer.
GNU General Public License v2.0
114 stars 41 forks source link

tty_fake not working after disconnecting and reconnecting to fake serial port #9

Closed AccessArctic closed 3 years ago

AccessArctic commented 3 years ago

After setting correctly a bus with a real serial port and 2 fake port (can see the data in two independent terminal via miniterm/screen/a specific software), if the connection ttyS0fake0 (same with fake1) is closed, it cannot be reopen. It is necessary to kill the tty_fake process and restart it:

tty_bus -s /tmp/ttyS0mux

on a different terminal:

tty_attach -s /tmp/ttyS0mux /dev/ttyUSB0

on a different terminal:

tty_fake -s /tmp/ttyS0mux /tmp/ttyS0fake0 $
tty_fake -s /tmp/ttyS0mux /tmp/ttyS0fake1

on a different terminal:

miniterm /tmp/ttyS0fake1 19200

then if closing the miniterm and trying to reopen it with the same command, it won't work

nicolaje commented 3 years ago

Hello,

I have the same issue here, tty_fake will exit/close after a process stops reading from it. I don’t know yet if this is intended or if this is an issue that requires fixing.

nicolaje commented 3 years ago

Reproductible example:

In terminal 1:

./tty_bus -s /tmp/ttyS0mux
Creating bus: /tmp/ttyS0mux

In terminal 2:

./tty_fake -s /tmp/ttyS0mux /tmp/ttyS0fake0
Connecting to bus: /tmp/ttyS0mux
Device: /dev/pts/8 is now /tmp/ttyS0fake0

In terminal 3:

cat /tmp/ttyS0fake0 

When closing cat in terminal 3, tty_fake in terminal 2 will exit.

@danielinux is this intended and is there a workaround to keep tty_fake running, or should I fix this?

AccessArctic commented 3 years ago

@nicolaje If you can fix it, I would love to have your updated version as for me this is definitely an unwanted behaviour

danielinux commented 3 years ago

Is the PULLHUP fix in the pending PR #6 solving this for you? I never had the time to review those. I'm open to merge that PR (and/or more fixups) if it makes sense.

AccessArctic commented 3 years ago

Looks promising indeed. I will have a check, but don't have my RPi at hand right now. Thanks

nicolaje commented 3 years ago

Hello, indeed the changes made in this pull request prevent tty_fake from exiting when a process that was reading from it closes.

So it solves this issue for my use case, although I didn't review the whole PR extensively.

nicolaje commented 3 years ago

@danielinux can I help you further to merge this PR into master ?

danielinux commented 3 years ago

Merged #6 . Thanks everyone, apologies for not being very reactive on this project.

nicolaje commented 3 years ago

Thank you for your time.