Esempio n. 1
0
 def write_multiple_coils(self, command):
     parser = argument_parser()
     command = 'write_multiple_coils ' + command
     spec = parser.parse_args(command.split())
     response = _ModbusClient.write_coils(
         self, spec.address, list(map(int, spec.values)), unit=spec.unit_id)
     return response
Esempio n. 2
0
 def write_single_coil(self, command):
     parser = argument_parser()
     command = 'write_single_coil ' + command
     spec = parser.parse_args(command.split())
     response = _ModbusClient.write_coil(
         self, spec.address, spec.value, unit=spec.unit_id)
     return response
Esempio n. 3
0
 def read_coils(self, command):
     parser = argument_parser()
     command = 'read_coils ' + command
     spec = parser.parse_args(command.split())
     response = _ModbusClient.read_coils(
         self, spec.address, spec.count, unit=spec.unit_id)
     return response
Esempio n. 4
0
 def read_discrete_inputs(self, command):
     parser = argument_parser()
     command = 'read_discrete_inputs ' + command
     spec = parser.parse_args(command.split())
     response = _ModbusClient.read_discrete_inputs(self, spec.address,
                                                   spec.count)
     return response
Esempio n. 5
0
 def read_holding_registers(self, command):
     parser = argument_parser()
     command = 'read_holding_register ' + command
     spec = parser.parse_args(command.split())
     response = _ModbusClient.read_holding_registers(
         self, spec.address, spec.count)
     return response
Esempio n. 6
0
    def write_multiple_registers(self, command):
        parser = argument_parser()
        command = 'write_multiple_registers ' + command
        spec = parser.parse_args(command.split())

        builder = BinaryPayloadBuilder(byteorder=Endian.Big,
                                       wordorder=Endian.Big)
        for func, value in spec.values:
            getattr(builder, func)(value)
        payload = builder.build()

        response = _ModbusClient.write_registers(
            self, spec.address, payload, skip_encode=True, unit=spec.unit_id)
        return response