Sharing physical COM port with two servers

kankamuso

Active Member
Oct 19, 2011
76
0
26
Hi,

I was wondering if it would be possible to share the same physical COM device with two virtual servers at the same time. This is just an INPUT COM key, so servers will not be writing on it.

At this point I am able to use it for a single server by adding this to the server config file:

serial1: /dev/ttyS0

But adding the same line to another server draws the COM unaccessible...

Thanks in advance,

Jose.
 
I would suggest to use an multiplexer, some quick searching lead me to this: https://github.com/danielinux/ttybus
This example the provide in the README sounds good to me:
Use case 1: Multiplexing serial input only or output only device attached to /dev/ttyS0, for use with multiple applications.
- step 1: create a new tty bus called /tmp/ttyS0mux:

tty_bus -s /tmp/ttyS0mux

- step 2: connect the real device to the bus using tty_attach:

tty_attach -s /tmp/ttyS0mux /dev/ttyS0

- step 3: create 2 fake ttyS0 devices, attached to the bus:

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

- step 4: start your application and force it to use the new serial device for input or output

/bin/foo /dev/ttyS0fake0 &
/bin/bar /dev/ttyS0fake1 &

Both application will read (or write) from the same serial device. CAUTION: all data written on each of the two fake devices
will be echoed on the other one too.
Haven't tested it, use at your own risk and maybe there is also a simpler solution which I forgot, but multiplexing it will be needed.

If you know some basic programming you could do it also yourself.

Edit:
But adding the same line to another server draws the COM unaccessible...
this is only the natural behavior for serial ports, they connect two devices and aren't meant to be shared.
 
Last edited:
Out of curiosity, what is an an "INPUT COM key" ? I couldn't find about that.
 
Hi manu,

It is just nothing "per se", just my expression meaning that no output is written to the external device.

Hope this clarifies ;),

Jose


Enviado desde mi iPhone utilizando Tapatalk
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!