def format_response(self, response_data):
        """Format an RPC response."""

        _addr, length = self.response_info()
        if len(response_data) != length:
            raise HardwareError("Invalid response read length, should be the same as what response_info() returns", expected=length, actual=len(response_data))

        resp, flags, received_length, payload = struct.unpack("<HxBL4x20s", response_data)
        resp = resp & 0xFF
        if flags & (1 << 3):
            raise HardwareError("Could not grab external gate")

        if received_length > 20:
            raise HardwareError("Invalid received payload length > 20 bytes", received_length=received_length)

        payload = payload[:received_length]

        return {
            'status': resp,
            'payload': payload
        }
Format an RPC response.