babca / python-gsmmodem

Maintained fork of a Python module to control GSM modems attached to the system: send/receive SMS messages in your scripts, handle calls, and more.
GNU Lesser General Public License v3.0
174 stars 106 forks source link

Support for RFC2217 (serial port over network) #113

Open xdanik opened 1 year ago

xdanik commented 1 year ago

Hello! In my specific use case I want to decouple the computer with GSM modem and the computer running python-gsmmodem. Thus I am using ser2net to share the serial line device over telnet protocol with RFC2217.

But python-gsmmodem uses simple serial.Serial(dsrdtr=True, rtscts=True, port=self.port, ... way to open the serial port and that does not allows usage of RFC2217. Thus I made a hack and replaced the line with self.serial = serial.Serial( in serial_comms.py with serial.serial_for_url(self.port) and used rfc2217://192.168... as a port.

Everything seems to work still the same as with local serial port.

Would be please possible to add native support for RFC2217?

The serial.serial_for_url( can be used as direct replacement for the serial.Serial( construct as long as it's not necessary to pass any special arguments. Or at lease move the serial port creation to separate method so it can be easily overridden.