当前位置: 首页>>代码示例>>Python>>正文


Python ModbusSerialClient._send方法代码示例

本文整理汇总了Python中pymodbus.client.sync.ModbusSerialClient._send方法的典型用法代码示例。如果您正苦于以下问题:Python ModbusSerialClient._send方法的具体用法?Python ModbusSerialClient._send怎么用?Python ModbusSerialClient._send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymodbus.client.sync.ModbusSerialClient的用法示例。


在下文中一共展示了ModbusSerialClient._send方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testBasicSyncSerialClient

# 需要导入模块: from pymodbus.client.sync import ModbusSerialClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusSerialClient import _send [as 别名]
    def testBasicSyncSerialClient(self, mock_serial):
        ''' Test the basic methods for the serial sync client'''

        # receive/send
        mock_serial.in_waiting = 0
        mock_serial.write = lambda x: len(x)

        mock_serial.read = lambda size: b'\x00' * size
        client = ModbusSerialClient()
        client.socket = mock_serial
        client.state = 0
        self.assertEqual(0, client._send(None))
        client.state = 0
        self.assertEqual(1, client._send(b'\x00'))
        self.assertEqual(b'\x00', client._recv(1))

        # connect/disconnect
        self.assertTrue(client.connect())
        client.close()

        # already closed socket
        client.socket = False
        client.close()

        self.assertEqual('ModbusSerialClient(ascii baud[19200])', str(client))
开发者ID:ccatterina,项目名称:pymodbus,代码行数:27,代码来源:test_client_sync.py

示例2: testSerialClientSend

# 需要导入模块: from pymodbus.client.sync import ModbusSerialClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusSerialClient import _send [as 别名]
    def testSerialClientSend(self):
        ''' Test the serial client send method'''
        client = ModbusSerialClient()
        self.assertRaises(ConnectionException, lambda: client._send(None))

        client.socket = mockSocket()
        self.assertEqual(0, client._send(None))
        self.assertEqual(4, client._send('1234'))
开发者ID:Agilefreaks,项目名称:pymodbus,代码行数:10,代码来源:test_client_sync.py

示例3: testSerialClientSend

# 需要导入模块: from pymodbus.client.sync import ModbusSerialClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusSerialClient import _send [as 别名]
 def testSerialClientSend(self, mock_serial):
     ''' Test the serial client send method'''
     mock_serial.in_waiting = None
     mock_serial.write = lambda x: len(x)
     client = ModbusSerialClient()
     self.assertRaises(ConnectionException, lambda: client._send(None))
     # client.connect()
     client.socket = mock_serial
     self.assertEqual(0, client._send(None))
     self.assertEqual(4, client._send('1234'))
开发者ID:zhanglongqi,项目名称:pymodbus,代码行数:12,代码来源:test_client_sync.py

示例4: testSerialClientCleanupBufferBeforeSend

# 需要导入模块: from pymodbus.client.sync import ModbusSerialClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusSerialClient import _send [as 别名]
 def testSerialClientCleanupBufferBeforeSend(self, mock_serial):
     ''' Test the serial client send method'''
     mock_serial.in_waiting = 4
     mock_serial.read = lambda x: b'1' * x
     mock_serial.write = lambda x: len(x)
     client = ModbusSerialClient()
     self.assertRaises(ConnectionException, lambda: client._send(None))
     # client.connect()
     client.socket = mock_serial
     client.state = 0
     self.assertEqual(0, client._send(None))
     client.state = 0
     self.assertEqual(4, client._send('1234'))
开发者ID:ccatterina,项目名称:pymodbus,代码行数:15,代码来源:test_client_sync.py

示例5: testBasicSyncSerialClient

# 需要导入模块: from pymodbus.client.sync import ModbusSerialClient [as 别名]
# 或者: from pymodbus.client.sync.ModbusSerialClient import _send [as 别名]
    def testBasicSyncSerialClient(self):
        ''' Test the basic methods for the serial sync client'''

        # receive/send
        client = ModbusSerialClient()
        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('ascii baud[19200]', str(client))
开发者ID:thom-nic,项目名称:pymodbus,代码行数:21,代码来源:test_client_sync.py


注:本文中的pymodbus.client.sync.ModbusSerialClient._send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。