Created
July 11, 2016 14:02
-
-
Save cristi-badila/463a9b0fac7402d32f04c8acab764d7b to your computer and use it in GitHub Desktop.
Sample RtsModbusSerialClient from https://github.com/bashwork/pymodbus/issues/33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RtsModbusSerialClient(ModbusSerialClient): | |
def _send(self, request): | |
''' Sends data on the underlying socket | |
:param request: The encoded request to send | |
:return: The number of bytes written | |
''' | |
if not self.socket: | |
raise ConnectionException(self.__str__()) | |
if request: | |
self.socket.setRTS(True) | |
result = self.socket.write(request) | |
self.socket.setRTS(False) | |
return result | |
return 0 | |
def _recv(self, size): | |
''' Reads data from the underlying descriptor | |
:param size: The number of bytes to read | |
:return: The bytes read | |
''' | |
if not self.socket: | |
raise ConnectionException(self.__str__()) | |
self.socket.setRTS(False) | |
result = self.socket.read(size) | |
self.socket.setRTS(True) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment