rcvr.close();
    public void run() {	// The magical ID-Request Message        byte[] idData = {	    (byte) 0xf0, (byte) 0x7e, (byte) 0,	    (byte) 0x06, (byte) 0x01, (byte) 0xf7	};	anyUnknown = false;        report = new String();	SysexMessage inqMsg = new SysexMessage();	int maxin = MidiUtil.getInputMidiDeviceInfo().length;	int maxout = MidiUtil.getOutputMidiDeviceInfo().length;        if (pb != null) {	    // Preparation for a progress bar	    pb.setMaximum(maxout * (MAX_DEVICE_ID + 1));	    pb.setNote("Scanning MIDI Devices");	}	for (int j = 0; j < maxout; j++)  {   // For all Outputs	    ErrorMsg.reportStatus("Out port : " + j);	    Receiver rcvr;	    try {		rcvr = MidiUtil.getReceiver(j);	    } catch (MidiUnavailableException e) {		ErrorMsg.reportStatus(e + ": Ignored.");		continue;	    }	    for (int devID = 0; devID <= MAX_DEVICE_ID; devID++) { // every devID		if (pb != null)		    pb.setProgress(j * (MAX_DEVICE_ID + 1) + devID);		//ErrorMsg.reportStatus("  device ID : " + devID);		idData[2] = (byte) devID; // Set the transmit devID		try {		    inqMsg.setMessage(idData, idData.length);		} catch (InvalidMidiDataException e) {		    ErrorMsg.reportStatus(e);		    continue;		}		// clear all input queue		for (int i = 0; i < maxin; i++)		    MidiUtil.clearSysexInputQueue(i);		// send Inquiry ID Sysex Message 		try {		    MidiUtil.send(rcvr, inqMsg);		} catch (MidiUnavailableException e) {		    ErrorMsg.reportStatus(e);		    continue;		} catch (InvalidMidiDataException e) {		    ErrorMsg.reportStatus(e);		    continue;		} 		try {		    sleep(WAITFORRESPONSE);		} catch (InterruptedException e) {		    ErrorMsg.reportStatus(e);		    // what should we do?		}		for (int i = 0; i < maxin; i++) { // For all Inputs		    //ErrorMsg.reportStatus("    in port : " + i);		    if (MidiUtil.isSysexInputQueueEmpty(i))			continue;		    //ErrorMsg.reportStatus("    Message Received");		    SysexMessage msg;		    try {			msg = (SysexMessage) MidiUtil.getMessage(i, 1);		    } catch (InvalidMidiDataException e) {			ErrorMsg.reportStatus(e);			continue;		    } catch (MidiUtil.TimeoutException e) {			ErrorMsg.reportStatus(e);			continue;		    }		    int sysexSize = msg.getLength();		    if (sysexSize <= 0)			continue;		    byte[] answerData = msg.getMessage();		    // check, whether it is really an inquiry response		    if (((answerData[0] & 0xff) == 0xf0)			&& (answerData[1] == 0x7e)			&& (answerData[3] == 0x06)			&& (answerData[4] == 0x02)) {			// Look in all loaded modules			checkResponseData(answerData, sysexSize, j, i, devID);		    } else if (! Arrays.equals(idData, answerData)) {			// don't show debug messge for the inquiry request			ErrorMsg.reportStatus("MidiScan : received non inquiry response data. Ingored.");		    }		} // i : input	    } // devID	    rcvr.close();	} //  j : output	if (pb != null)	    // clear progress bar	    pb.setProgress(maxout * (MAX_DEVICE_ID + 1));	if (anyUnknown && (parent != null)) {	    ScanUnkownReportDialog surd = new ScanUnkownReportDialog(parent, true);	    surd.addToReport(report);	    surd.show();	}    }