I am developing small app that will send SMS using remote device as gateway.
These devices are connected with VPN, but it doesn't matter.
SMS gateway has physically serial port /dev/AMA0
.
I'm using ser2net
on SMS Gateway to share serial port over Internet,
and I'm using socat
to create virtual serial port on VPS and "receive" shared port.
Here are my confings:
SMS Gw:
cat /etc/ser2net.conf
3333:raw:0:/dev/ttyAMA0:9600,8DATABITS,NONE,1STOPBIT
VPS:
socat pty,link=/dev/tty_remote_serial,waitslave tcp:10.8.0.2:3333
I'm using gammu
to control the SMS device. When I log on VPS and execute this command I see:
gammu identify
Device : /dev/tty_remote_rpi_serial
Manufacturer : SIMCOM_Ltd
Model : unknown (SIMCOM_SIM800L)
Firmware : Revision:1308B08SIM800L16
IMEI : 867XXXXXXXXXXX23
SIM IMSI : XXXXXXXXXX491925
And it's perfect. I can use remote serial port and everything works perfect. The problem is when I run gammu identify
one more time. Device /dev/tty_remote_rpi_serial
does not exist because socat
terminated. When I restart socat
service everything works fine ONCE. I must restart socat
every closed connection (from mincom) or executed command (gammu identify
).
Is there a way to prevent socat
from terminating?
2016/01/06 04:50:04 socat[4233] N read(5, 0x16ea680, 8192): Input/output error (probably PTY closed)
2016/01/06 04:50:04 socat[4233] N socket 1 (fd 5) is at EOF
2016/01/06 04:50:04 socat[4233] I shutdown(6, 1)
2016/01/06 04:50:04 socat[4233] D shutdown() -> 0
2016/01/06 04:50:04 socat[4233] D data loop: sock1->eof=2, sock2->eof=0, closing=1, wasaction=1, total_to={0.000000}
2016/01/06 04:50:04 socat[4233] D select(7, &0x40, &0x0, &0x0, &999.000000)
2016/01/06 04:50:04 socat[4233] D select -> (, 0x40, 0x0, 0x0, &998.974365), 1
2016/01/06 04:50:04 socat[4233] D read(6, 0x16ea680, 8192)
2016/01/06 04:50:04 socat[4233] D read -> 0
2016/01/06 04:50:04 socat[4233] N socket 1 (fd 5) is at EOF
2016/01/06 04:50:04 socat[4233] I shutdown(6, 1)
2016/01/06 04:50:04 socat[4233] D shutdown() -> -1
2016/01/06 04:50:04 socat[4233] I shutdown(6, 1): Transport endpoint is not connected
2016/01/06 04:50:04 socat[4233] N socket 2 (fd 6) is at EOF
2016/01/06 04:50:04 socat[4233] I close(5)
2016/01/06 04:50:04 socat[4233] D close() -> 0
2016/01/06 04:50:04 socat[4233] D unlink("/dev/tty_remote_rpi_serial")
2016/01/06 04:50:04 socat[4233] D unlink() -> 0
2016/01/06 04:50:04 socat[4233] I shutdown(6, 2)
2016/01/06 04:50:04 socat[4233] D shutdown() -> -1
2016/01/06 04:50:04 socat[4233] I shutdown(6, 2): Transport endpoint is not connected
2016/01/06 04:50:04 socat[4233] N exiting with status 0
2016/01/06 04:50:04 socat[4233] D exit(0)
2016/01/06 04:50:04 socat[4233] D starting xioexit()
2016/01/06 04:50:04 socat[4233] D finished xioexit()