本文整理汇总了Python中pymodbus.client.sync.ModbusTcpClient._send方法的典型用法代码示例。如果您正苦于以下问题:Python ModbusTcpClient._send方法的具体用法?Python ModbusTcpClient._send怎么用?Python ModbusTcpClient._send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymodbus.client.sync.ModbusTcpClient
的用法示例。
在下文中一共展示了ModbusTcpClient._send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testTcpClientSend
# 需要导入模块: from pymodbus.client.sync import ModbusTcpClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusTcpClient import _send [as 别名]
def testTcpClientSend(self):
''' Test the tcp client send method'''
client = ModbusTcpClient()
self.assertRaises(ConnectionException, lambda: client._send(None))
client.socket = mockSocket()
self.assertEqual(0, client._send(None))
self.assertEqual(4, client._send('1234'))
示例2: testBasicSyncTcpClient
# 需要导入模块: from pymodbus.client.sync import ModbusTcpClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusTcpClient import _send [as 别名]
def testBasicSyncTcpClient(self):
''' Test the basic methods for the tcp sync client'''
# receive/send
client = ModbusTcpClient()
client.socket = mockSocket()
self.assertEqual(0, client._send(None))
self.assertEqual(1, client._send('\x00'))
self.assertEqual('\x00', client._recv(1))
# connect/disconnect
self.assertTrue(client.connect())
client.close()
# already closed socket
client.socket = False
client.close()
self.assertEqual("127.0.0.1:502", str(client))