def call_function(self, command, response_length=0, params=[], timeout_sec=1):
        data = bytearray(2+len(params))
        data[0]  = PN532_HOSTTOPN532
        data[1]  = command & 0xFF
        data[2:] = params
        self._write_frame(data)
        if not self._wait_ready(timeout_sec):
            return None
        response = self._read_data(len(PN532_ACK))
        if response != PN532_ACK:
            raise RuntimeError('Did not receive expected ACK from PN532!')
        if not self._wait_ready(timeout_sec):
            return None
        response = self._read_frame(response_length+2)
        if not (response[0] == PN532_PN532TOHOST and response[1] == (command+1)):
            raise RuntimeError('Received unexpected command response!')
        return response[2:]