⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandmanager.java

📁 First of all, the Applet-phone is a SIP User-Agent with audio and text messaging capabilities. But
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            c='0';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: 0 (dec/hex code: 48/30)");                        // 4.            c='k';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: k (dec/hex code: 107/6B)");                        // 5.            if (transferMode.equals(SYNCHRONOUS_TRANSFER_MODE)) {                os.write(0x30);                SerialDebug.println("Sent to the base:       -  synch. transfer mode byte: 0x30");            }            else {                  os.write(0x31);                 SerialDebug.println("Sent to the base:       -  asynch. transfer mode byte: 0x31");            }            // 6.            c='p';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: p (dec/hex code: 112/70)");                        // 7.            c='q';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: q (dec/hex code: 113/71)");                        // 8.            newData = is.read();            inputBuffer = new StringBuffer();            inputBuffer.append((char)newData);            s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");            if ((char)newData!='0') {                SerialDebug.println("ERROR code returned from the base!!!!");            }                                  int cpt=1;            while (cpt!=3) {                c='.';                 os.write(c);                SerialDebug.println("Sent to the base:       -  char: . (dec/hex code: 46/2E)");                                newData = is.read();                SerialDebug.println("Received from the base: -  char: "+(char)newData+" (dec code: "+newData+")");                inputBuffer = new StringBuffer();                inputBuffer.append((char)newData);                s=new String(inputBuffer);                                cpt++;            }                  }        catch (Exception e) {            e.printStackTrace();        }    }               /*******************************************************************************/    /********************      GET_ID_TABLE        *********************************/    /*******************************************************************************/           public Vector getIdTable() {        Vector activeBadges=new Vector();        try {            setTransferMode(SYNCHRONOUS_TRANSFER_MODE);            wakeupBase();                       SerialDebug.println("CommandManager, getIdTable() required...");                                    int activeBadgesCount=0;                                    StringBuffer inputBuffer = new StringBuffer();            int newData = 0;                      /* Sequence:              1. send:     '\' prepare the base for a command              2. receive:  0x30 (=0)              3. send:     0x30 (=0)              4. send:     'j'              5. send:     auth0_pc: let's put 'p'               6. send:     auth1_pc: let's put 'q'              7. receive:  0x30 for correctness, an other byte otherwise is error and stop              8. send:     '.'              9. receive:  0x30              10. send:     '.'              11. receive:  'j' echo command              12. send:     '.'              13. receive:  Authentication Low byte return               14. send:     '.'              15. receive:  Authentication High byte return              16. send:     '.'              17. receive:  timer 0 : is the number of active badges!!!              ...              18. send:     '.'              19. receive:  timer 7              20. send:     '.'              21. receive:  id00 low byte ID: 4 ID bytes per badge               ...              22. send:     '.'              23. receive:  id03 high byte ID              24. send:     '.'              25. receive:  id10                 ...              26. send:     '.'              27. receive:  id73              28. send:     '.'              29. receive:  checksum            */                        // 1.            char c='\\';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: \\ (dec/hex code: 92/5C)");                        // 2.            newData = is.read();            inputBuffer.append((char)newData);            String s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");                        // 3.            c='0';             os.write(c);            SerialDebug.println("Sent to the base:       -  char: 0 (dec/hex code: 48/30)");                       // 4.            c='j';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: j (dec/hex code: 97/61)");                        // 5.            c='p';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: p (dec/hex code: 112/70)");                        // 6.            c='q';            os.write(c);            SerialDebug.println("Sent to the base:       -  char: q (dec/hex code: 113/71)");                        // 7.            newData = is.read();            inputBuffer = new StringBuffer();            inputBuffer.append((char)newData);            s=new String(inputBuffer);            SerialDebug.println("Received from the base: -  char: "+s+" (dec code: "+newData+")");            if ((char)newData!='0') {                SerialDebug.println("ERROR code returned from the base, check if the transfer "+                "mode is SYNCHRONOUS!!!!");                return activeBadges;            }                        // 6. 7. 8. 9. 10. 11. 12. 13. 14. 15.            int cpt=1;            int[] badgeBytes=new int[4];            while (cpt!=46) {                c='.';                 os.write(c);                //SerialDebug.println("Sent to the base:       -  char: . (dec/hex code: 46/2E)");                                newData = is.read();                inputBuffer = new StringBuffer();                inputBuffer.append((char)newData);                s=new String(inputBuffer);                                if (cpt==1) {                    SerialDebug.println("Received from the base: -  echo local command char: "+                    s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                }                else                 if (cpt==2) {                    SerialDebug.println("Received from the base: -  echo command char: "+                    s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                }                else                 if (cpt==3) {                   SerialDebug.println("Received from the base: -  auth low Byte return, char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                }                else                if (cpt==4) {                   SerialDebug.println("Received from the base: -  auth high Byte return, char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                }                else                if (cpt>=5 && cpt <=12 ) {                   SerialDebug.println("Received from the base: -  timer byte, char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if ( !Integer.toHexString(newData).equals("0")) {                        SerialDebug.println("One active badge detected...");                        activeBadgesCount++;                   }                                      if (cpt==12) {                        SerialDebug.println("There are "+activeBadgesCount+" active badges detected...");                        if (activeBadgesCount==0) {                              SerialDebug.println("There are no badges detected, we return...");                              return activeBadges;                        }                   }                                   }                else                if ( (cpt>=13 && cpt <=16) && activeBadgesCount==8 ) {                                       SerialDebug.println("Received from the base: -  ID[0] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount==8) {                        badgeBytes[cpt-13]=newData;                        if (cpt==16) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=17 && cpt <=20) && activeBadgesCount>=7 ) {                   SerialDebug.println("Received from the base: -  ID[1] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=7) {                        badgeBytes[cpt-17]=newData;                        if (cpt==20) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=21 && cpt <=24) && activeBadgesCount>=6 ) {                   SerialDebug.println("Received from the base: -  ID[2] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=6) {                        badgeBytes[cpt-21]=newData;                        if (cpt==24) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=25 && cpt <=28) && activeBadgesCount>=5 ) {                   SerialDebug.println("Received from the base: -  ID[3] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=5) {                        badgeBytes[cpt-25]=newData;                        if (cpt==28) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=29 && cpt <=32) && activeBadgesCount>=4 ) {                   SerialDebug.println("Received from the base: -  ID[4] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=4) {                        badgeBytes[cpt-29]=newData;                        if (cpt==32) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=33 && cpt <=36) && activeBadgesCount>=3 ) {                   SerialDebug.println("Received from the base: -  ID[5] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=3) {                        badgeBytes[cpt-33]=newData;                        if (cpt==36) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=37 && cpt <=40) && activeBadgesCount>=2 ) {                   SerialDebug.println("Received from the base: -  ID[6] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=2) {                        badgeBytes[cpt-37]=newData;                        if (cpt==40) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                else                if ( (cpt>=41 && cpt <=44) && activeBadgesCount>=1 ) {                   SerialDebug.println("Received from the base: -  ID[7] byte (low to high), char: "+                   s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                   if (activeBadgesCount>=1) {                        badgeBytes[cpt-41]=newData;                        if (cpt==44) {                            Badge badge=new Badge(badgeBytes);                            activeBadges.addElement(badge);                        }                   }                }                //else {                //    SerialDebug.println("Received from the base: -  checksum char: "+                //    s+" (dec/hex code: "+newData+"/"+Integer.toHexString(newData)+")");                //}                                cpt++;            }                                   return activeBadges;                    }        catch (Exception e) {            e.printStackTrace();            return activeBadges;        }    }       public BadgeAsynchronousThread getAsynchronousThread(BadgeNotification badgeNotification) {         if (badgeNotification == null) return null;         return new BadgeAsynchronousThread(this,badgeNotification);    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -