def write_single_coil(slave_id, address, value): """ Return ADU for Modbus function code 05: Write Single Coil. :param slave_id: Number of slave. :return: Byte array with ADU. """ function = WriteSingleCoil() function.address = address function.value = value return _create_request_adu(slave_id, function.request_pdu)
def write_single_coil(): function_code = 5 address = 100 value = 0xFF00 pdu = struct.pack('>BHH', function_code, address, value) return WriteSingleCoil.create_from_request_pdu(pdu)
def write_single_coil(): instance = WriteSingleCoil() instance.address = 100 instance.value = 1 return instance
def test_write_single_coil_response_pdu(write_single_coil): response_pdu = write_single_coil.create_response_pdu() instance = WriteSingleCoil.create_from_response_pdu(response_pdu) assert instance.address == 100 assert instance.data == 1
def test_write_single_coil_request_pdu(write_single_coil): instance = WriteSingleCoil.create_from_request_pdu( write_single_coil.request_pdu) # NOQA assert instance.address == 100 assert instance.value == 1
def test_write_single_coil_request_pdu(write_single_coil): instance = WriteSingleCoil.create_from_request_pdu(write_single_coil.request_pdu) # NOQA assert instance.address == 100 assert instance.value == 1