I want to implement a modbus slave simulator that creates it's own serial device.
Something like in this example, where socat creates a "tunnel" between /dev/pts/6 and /dev/pts/7 and then diagslave will open one of them. The modbus client can then connect to the other one.
I've modified some code in https://github.com/simonvetter/modbus/tree/simon/refactor-rtu-transport, to be able to create a modbus server that can take RTU messages and it also works with socat.
But I want to overcome this step and create the /dev/pts/x directly.
So can it be done? Something like socat is doing? Ideally in go or c.
Can you try if the following command could work?
socat -d -d pty,raw,echo=0 pty,raw,echo=0If so, Ctrl+C to terminate socat or exit the terminal. Use this template to do what you want: