@Override
    public void run() {    
        startTimer("onStartPhotoTimer");
        
        char mcuMessage[] = new char[10];
        mcuMessage[0]=0;
        int mcuI=0;
        
        while (process && conn!=null) {
            int znak=conn.read();
            if (znak!=-1) {
                if (jpegReading) {
                    //jpegData+=(char)znak;
                    
                    if (znak==0x76 && !(mcuI==1 && mcuMessage[0]==0x76 && mcuMessage[1]==0x75)) {
                        mcuMessage[0]=(char)znak;
                        mcuMessage[1]=0;
                        mcuI=0;
                    }
                    else if (mcuI==0 && mcuMessage[0]==0x76 && mcuMessage[1]==0) {
                        mcuMessage[++mcuI]=(char)znak;
                        if (mcuMessage[1]!=0x75) {
                            if (makeImgFile!=null) {
                                makeImgFile.write(mcuMessage[0]);
                                makeImgFile.write((char)znak);
                            }
                            mcuMessage[0]=0;
                        }
                        mcuMessage[2]=0;
                    }
                    else if (mcuI==1 && mcuMessage[0]==0x76 && mcuMessage[1]==0x75 && mcuMessage[2]==0) {
                        mcuMessage[++mcuI]=(char)znak;
                        if (mcuMessage[2]!=0x76) {
                            if (makeImgFile!=null) {
                                makeImgFile.write(mcuMessage[0]);
                                makeImgFile.write(mcuMessage[1]);
                                makeImgFile.write((char)znak);
                            }
                            mcuMessage[0]=0;
                        }
                    }
                    else if (mcuMessage[0]==0x76 && mcuMessage[1]==0x75 && mcuMessage[2]==0x76) {
                        mcuMessage[++mcuI]=(char)znak;
                        if (mcuI==5) {
                            System.out.println("MCU comand in Photo!");
                            //command from MCU
                            mcuMessage[0]=0;
                            messageToMcu(new String(new char[] {mcuMessage[3], mcuMessage[4], mcuMessage[5]}));
                        }
                    }
                    else {
                        if (makeImgFile!=null) {
                            makeImgFile.write((char)znak);
                        }
                    }
                }
                if (znak==(int)0x76 && !(message.length()==2 && message.charAt(0)==(char)0x76 && message.charAt(1)==(char)0x75)) {
                    message="";
                }
                message+=Character.toString((char)znak);
                checkRecievedData(message);
            }
            else {
                try {
                    Thread.yield();
                    Thread.sleep(delay);
                } catch (InterruptedException ex) {
                    //nevypisování chyby při odpojení
                    if (process) Logger.getLogger(TcpIp.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }