I'm no Linux expert so please go easy ;).
Ok, the situation is that I have a single board computer running Debian Wheezy. I know its old/risky etc etc but its not actually "my" equipment and therefore I have no control over this.
There is some software running on it, written in c# and ran through mono. Again, this is not my software and I have zero control over it or the ability to alter the code.
The software sends AT commands down a physical serial port (
/dev/ttyS1) to a modem which returns the appropriate responses to the commands.
The modems are no longer available and therefore I need to develop some alternative. Therefore I thought I could run a simple python script on the SBC that would "intercept" the AT commands, send back the appropriate responses to the c# software and then I can use the python script to talk to another device however I need to.
Having had a good "google",
socat seemed to be the best option for doing this. However, I have tried I dont know how many combinations and cannot get it to work the way I need it to.
The physical setup is that I currently have the serial port plugged into my laptop so I can see the AT commands coming up the pipe (on ttyS1) I then ssh into the SBC and fire up minicom to view the new "virtual ports" created by
C# <-> ttyS1 <-> Old Modem
C# <-> socat <-> python -> New Modem
Below is just two of the variations I've tried:
socat -x /dev/ttyS1,raw,echo=0,crnl PTY,link=/dev/ttyV1,raw,echo=0,crnl
... also tried the other way around in case I misunderstood ...
socat -x PTY,link=/dev/ttyV1,raw,echo=0,crnl /dev/ttyS1,raw,echo=0,crnl
I've also tried many different variations, pushing to files, "teeing" off to files, different command switches, configuring the ports using stty etc etc
Every time I have the same issue that I cannot actually see the AT commands being sent from the c# software?!
I can type into minicom on the SBC and see the output turning up on the serial port reader on my laptop, likewise I can type into the serial port reader on my laptop and see the input in minicom on the SBC, however what I cannot seem to intercept is the actual AT commands being sent from the c# software even though the software is configured to use ttyS1.
The one bit of control I do have over the software is which port it uses to talk to the modem on. Therefore I have also tried changing this to a virtual port e.g.
/dev/ttyV1 and running
socat to create the virtual port during startup and before the c# program starts so that the virtual port is actually available. Again I have exactly the same issue where I still cannot see the AT commands being sent by c# software.
Hope someone can help as I've been at this two full days now and cannot get it to work. I'm pretty sure socat is the tool to use and hopefully I've just fundamentally misunderstood how it works.