Matthew G.
Matthew G.

Reputation: 131

Mirror the incoming data from one COM port to a virtual COM port on Linux

Is there a way that two drivers are connected to the same COM device with one being able to send data to the device and both receiving the incoming data?

In more detail: Both drivers also want to send data to the device, which causes problems if both have write access to the device. Therefore a symlink to a virtual COM port doesn't help at all.

So I guess the best option would be to mirror all the incoming data from the device to a virtual COM port. One driver is connected to the real device (therefore also being able to send data to the device). The other one is only connected to the virtual COM port and therefore all data sent by this program should end up in /dev/null.

Is there a way of doing this or are there even better solutions?

EDIT: Some approaches by now:

  1. Using socat

    sudo socat pty,link=/dev/modem0,raw,waitslave file:/dev/ttyACM0,nonblock
    

    Doesn't work since it's a symlink.

  2. Using tee

    sudo cat /dev/ttyACM0 | tee 1.txt 2.txt /dev/modem0
    

    Isn't able to write to (virtual) COM ports (/dev/modem0 fails) AND I don't get a direct connection in order to also send data to ttyACM0

  3. Using slsnif (isn't compatible to current kernels)

  4. Using interceptty

    sudo interceptty /dev/ttyACM0 -o "1.txt"
    

    Is only able to sniff ASCII-Characters, all binary data is lost in the logfile.

Upvotes: 1

Views: 2515

Answers (1)

stdcall
stdcall

Reputation: 28880

You can create an application that opens this port and distributes the data to several file descriptor, something like tee.

Upvotes: 0

Related Questions