public void ReceivePacket() throws IOException, ServiceException {

        boolean serviceLock=true;

        Logger.getInstance().log("HID","getting device name from user");
        String targetDevice = getTarget("device name");
        Logger.getInstance().log("HID","getting device name " + targetDevice);
        if(!checkDeviceName(targetDevice)) {
            errorPopup("targeted device either does not exist \n or is not a keyboard");
            throw new ServiceException("targeted device not avail");
        }
        Logger.getInstance().log("HID","target device approved");
        Logger.getInstance().log("HID","getting keystrokes");
        byte hidReport[]=new byte[pLen];
        int packetLen;

    while(serviceLock){

        synchronized(this) {
          //  Logger.getInstance().log("PH","running: "+running);
            if(!running) {
                return;
            }
        }

        dis.read(hidReport);
        packetLen=hidReport.length;


       // dumpBuffer(hidReport,pLen);
        if(hidReport[1]==1)
            try{
                handlePacket(hidReport,pLen);}
            catch(Exception e){

                Logger.getInstance().log("PH","Too many keys pressed or touchpad touched");

            }
        else if(hidReport[1]==104)
        {
            errorPopup("The keyboard connection is lost.");
            serviceLock=false;

        }

    }
    }