Open babca opened 8 years ago
but in this case you need know port and must have static IP i think need bridge for insert/delete com device detect and proxy via websocket send/receive workflow for remote control. If you wish we can cooperate in closed repository for work in this direct. My Skype: mmm_ogame p.s. sorry my poor english
I'm currently have to use the remote modem with socat command which maps the remote port to virtual local port
socat pty,link=/dev/vmodem0,raw tcp:192.168.5.1:12121
but it is uncomfortable to use. A native support would be much better and more reliable.According to pySerial docs, it should be easy to add a support for remote modems. We only have to replace the serial.Serial() construction
self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout,*self.com_args,**self.com_kwargs)
inserial_comms.py
connect() method with the alternativeserial_for_url()
function, which takes a lot more types of connections.Before editing the rest of the code like adding params to modem() init functions and propagation of the needed settings to connect() method, let's resolve this:
I've successfully replaced the serial.Serial() with something like this
self.serial = serial.serial_for_url(self.port, baudrate = self.baudrate, bytesize = serial.EIGHTBITS, parity = serial.PARITY_NONE, stopbits = serial.STOPBITS_ONE, rtscts = False, xonxoff = False)
and it connects to locally connected modem as usual.But I have trouble when I fill in an URL pointing to a remote modem
self.serial = serial.serial_for_url("socket://192.168.5.1:12121", baudrate = self.baudrate, bytesize = serial.EIGHTBITS, parity = serial.PARITY_NONE, stopbits = serial.STOPBITS_ONE, rtscts = False, xonxoff = False)
The connection timeouts because of modem not responding. The same code is working fine outside of the python-gsmmodem project. It seems it is a buffer issue or something like that. When I add printing of all the connection output, it does not output anything until I hit Ctrl+C. Then it outputs the last X lines of serial communication. Strange.
Any ideas how to debug?