0

HDP 샘플을 사용하고 있으며 혈압 센서가 있습니다 (http://www.andonline.com/medical/products/details.php?catname= & product_num = UA-767PBT-C). 나는 그것으로부터 데이터를 얻었지만 그것을 사람이 읽을 수있는 것으로 파싱하는 방법을 모른다.android (API 15)의 hdp 장치에서 데이터 구문 분석

이 내가 좋아하는 뭔가 지금까지 뭘하려 :

while(fis.read(data) > -1) { 
    String value = null; 
    BigInteger bi = new BigInteger(data); 
// for(byte b:data){ 
// value+=b; 
// } 

Log.d("read data binary", "the data "+bi.toString(2)); 

Log.d("read data decimal", "the data "+bi.toString()); 

Log.d("read data hexa", "the data "+bi.toString(16)); 

Log.d("read data pure", "the data "+data); 

// Log.d("read data in for", "the data "+value); 

과 나는 같은 것을 얻을 :

05-01 20시 17분 56초합니다.208 : D/판독 데이터 헥사 (4760) : 데이터 -1dffffcd7ffffffffffeffd5af86ffd97fffffff7fff7fffffffffffffffff7ffffffff7fff6e000017fe6c9fd43ff7eff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 05-01 20 : 17 : 56.208 : D/순수 판독 데이터 (4760) : 05-01 40d67e70 20시 18분 4초 @ 데이터 [B.626 : 데이터 -1100111111111111111111111110111111111111111011111111111111111111111111111111011111111110101011010111110000110111111111101100101111111111111111111111111111111011111111111111101111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111101111111111111110110111000000000000000000001011111111110011011001001111111010100001111111111011111101111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 : D는/ 바이너리 데이터 (4760)를 읽어 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 05-01 20:18:06.828 : D는/는 데이터 (4760)를 판독 진수 : 데이터 -781118974198215554193785785859382435002755250153009251411946038850315108576684984106702193657963347897709677566091677495576556681656068507314031372074156531214767021895212919495909358260588291818568553609578646758938365326563499166628415041706131521582622947791012917744251071555344476280175567553030365868879087958701356749275597544555441192209535828193783528540378443653793007478915664994969246893177676787034473169357958664807853394146528881072611495728346161885141354339050534315795112871110590890270640490572109200167490678091854953195502952814139817930997734428369811037792170901222000605941722889749 0663632127921884739590333205421495578736984062088071032839154640177381027612938354851032338713201676865091998435236402442816189068252388704413636282358447484621331032763011748386630715517268803987946565620349685791872315647315974663120852929314016264250312193673728801056695240217037954879300746602696068528503485619431744810596830479390072102256014904786379885200942541768018547285509315725810721925773238012551233765684211428599316991837817953275466249315099369637182036791450816547726156761439504911564577098798332137708614741665500028938950045393781414044845143215012544251865843063173228201190800735212465830239288556807716748344594855471404581795834110005529467215574659415846075926847599736673285344205312003601250493931652499391254622736559430124527961987196078914467096385259391360413766722244649547657680034992096702577430954894595554850121644988549721985474054339838378401514140718491721345155113453203729983438697193186989951240978305861633125655220991083790883839070297950011795570337329 25854106484925992046251994418246510444641426185467437327268959477603463411587255087111960727666751094267733565670470254329185066819049347190875320805571892878980923324446702125088753

사람은, 제발 구문 분석하는 방법을 어떤 ideea의있다?

추신 : 로그 캣에서 최선을 다하는 죄송합니다,하지만 어쩌면 누군가가 나는 해결책을 발견 모든 연결

+0

당신은 우리에게 적어도 혈액 센서의 제조사와 모델을 말할 수 있습니까? –

+0

방금 ​​질문에 추가했습니다. 죄송합니다 그게 필요하다는 것을 깨닫지 못해서 :) –

+0

이것이 당신에게 좋은지보십시오 : http://wiki.eclipse.org/OHF_SODA_Stepstone –

답변

0

를 찾습니다. 내 센서가 보내고있는 정확한 바이트 수 + 센서가 정보를 보내는 방식이 필요했습니다.

나는 혈압계의 데이터를 분석하는 클래스의 부분을 넣을 것이다.

public String byte2hex(byte[] b) 
    { 
    // String Buffer can be used instead 
     String hs = ""; 
     String stmp = ""; 

     for (int n = 0; n < b.length; n++) 
     { 
      stmp = (java.lang.Integer.toHexString(b[n] & 0XFF)); 

      if (stmp.length() == 1) 
      { 
      hs = hs + "0" + stmp; 
      } 
      else 
      { 
      hs = hs + stmp; 
      } 

      if (n < b.length - 1) 
      { 
      hs = hs + ""; 
      } 
     } 

     return hs; 
    } 

    public static int byteToUnsignedInt(byte b) { 
     return 0x00 << 24 | b & 0xff; 
     } 

    // Thread to read incoming data received from the HDP device. This sample application merely 
    // reads the raw byte from the incoming file descriptor. The data should be interpreted using 
    // a health manager which implements the IEEE 11073-xxxxx specifications. 
    private class ReadThread extends Thread { 
     private ParcelFileDescriptor mFd; 

     public ReadThread(ParcelFileDescriptor fd) { 
      super(); 
      mFd = fd; 
     } 


     @Override 
     public void run() { 
      FileInputStream fis = new FileInputStream(mFd.getFileDescriptor()); 
      byte data[] = new byte[300]; 
      try { 
       while(fis.read(data) > -1) { 
        // At this point, the application can pass the raw data to a parser that 
        // has implemented the IEEE 11073-xxxxx specifications. Instead, this sample 
        // simply indicates that some data has been received.     
        if (data[0] != (byte) 0x00) 
        { 
         String test = byte2hex(data); 
         Log.i(TAG, test); 
         if(data[0] == (byte) 0xE2){ 
          Log.i(TAG, "E2"); 
          count = 1; 
          (new WriteThread(mFd)).start(); 
          try { 
           sleep(100); 
          } catch (InterruptedException e) { 
           e.printStackTrace(); 
          } 
          count = 2; 
          (new WriteThread(mFd)).start(); 
         } 
         else if (data[0] == (byte)0xE7){ 
          Log.i(TAG, "E7"); 

          //work for legacy device... 
          if (data[18] == (byte) 0x0d && data[19] == (byte) 0x1d) //fixed report 
          { 
           count = 3; 
           //set invoke id so get correct response 
           invoke = new byte[] { data[6], data[7] }; 
           //write back response 
           (new WriteThread(mFd)).start();  
           //parse data!! 
           int length = data[21]; 
           Log.i(TAG, "length is " + length); 
           // check data-req-id 
           int report_no = data[22+3]; 
           int number_of_data_packets = data[22+5]; 
           //packet_start starts from handle 0 byte 
           int packet_start = 30; 
           final int SYS_DIA_MAP_DATA = 1; 
           final int PULSE_DATA = 2; 
           final int ERROR_CODE_DATA = 3; 
           for (int i = 0; i < number_of_data_packets; i++) 
           { 
            int obj_handle = data[packet_start+1]; 
            switch (obj_handle) 
            { 
            case SYS_DIA_MAP_DATA: 
             int sys = byteToUnsignedInt(data[packet_start+9]); 
             int dia = byteToUnsignedInt(data[packet_start+11]); 
             int map = byteToUnsignedInt(data[packet_start+13]); 
             //create team string... 9+13~9+20 
             Log.i(TAG, "sys is "+ sys); 
             sendMessage(RECEIVED_SYS, sys); 
             Log.i(TAG, "dia is "+ dia); 
             sendMessage(RECEIVED_DIA, dia); 
             Log.i(TAG, "map is "+ map); 
             //test 
//          sendMessage(RECEIVED_MAP, map); 
             break; 
            case PULSE_DATA: 
             //parse 
             int pulse = byteToUnsignedInt(data[packet_start+5]); 
             Log.i(TAG, "pulse is " + pulse); 
             sendMessage(RECEIVED_PUL, pulse); 
             break; 
            case ERROR_CODE_DATA: 
             //need more signal 
             break; 
            } 
            packet_start += 4 + data[packet_start+3]; //4 = ignore beginning four bytes 
           }        
          } 
          else 
          { 
           count = 2; 
          } 
         } 
         else if (data[0] == (byte) 0xE4) 
         { 
          count = 4; 
          (new WriteThread(mFd)).start(); 
//       sendMessage(); 
         } 
         //zero out the data 
         for (int i = 0; i < data.length; i++){ 
          data[i] = (byte) 0x00; 
         } 
        } 
        sendMessage(STATUS_READ_DATA, 0); 
       } 
      } catch(IOException ioe) {} 
      if (mFd != null) { 
       try { 
        mFd.close(); 
       } catch (IOException e) { /* Do nothing. */ } 
      } 
      sendMessage(STATUS_READ_DATA_DONE, 0); 
     } 
    } 


    private class WriteThread extends Thread { 
     private ParcelFileDescriptor mFd; 

     public WriteThread(ParcelFileDescriptor fd) { 
      super(); 
      mFd = fd; 
     } 

     @Override 
     public void run() { 
      FileOutputStream fos = new FileOutputStream(mFd.getFileDescriptor()); 
//   FileInputStream fis = new FileInputStream(mFd.getFileDescriptor()); 
      final byte data_AR[] = new byte[] {   (byte) 0xE3, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x2C, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x50, (byte) 0x79, 
                 (byte) 0x00, (byte) 0x26, 
                 (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, 
                 (byte) 0x80, (byte) 0x00, 
                 (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, 
                 (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x08, //bt add for phone, can be automate in the future 
                 (byte) 0x3C, (byte) 0x5A, (byte) 0x37, (byte) 0xFF, 
                 (byte) 0xFE, (byte) 0x95, (byte) 0xEE, (byte) 0xE3, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00}; 
      final byte data_DR[] = new byte[] {   (byte) 0xE7, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x12, 
                 (byte) 0x00, (byte) 0x10, 
                 (byte) invoke[0], (byte) invoke[1], 
                 (byte) 0x02, (byte) 0x01, 
                 (byte) 0x00, (byte) 0x0A, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, 
                 (byte) 0x0D, (byte) 0x1D, 
                 (byte) 0x00, (byte) 0x00 }; 

      final byte get_MDS[] = new byte[] {   (byte) 0xE7, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x0E, 
                 (byte) 0x00, (byte) 0x0C, 
                 (byte) 0x00, (byte) 0x24, 
                 (byte) 0x01, (byte) 0x03, 
                 (byte) 0x00, (byte) 0x06, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x00 }; 

      final byte data_RR[] = new byte[] {   (byte) 0xE5, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x02, 
                 (byte) 0x00, (byte) 0x00 }; 

      final byte data_RRQ[] = new byte[] {  (byte) 0xE4, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x02, 
                 (byte) 0x00, (byte) 0x00 }; 

      final byte data_ABORT[] = new byte[] {  (byte) 0xE6, (byte) 0x00, 
                 (byte) 0x00, (byte) 0x02, 
                 (byte) 0x00, (byte) 0x00 }; 
      try { 
       Log.i(TAG, String.valueOf(count)); 
       if (count == 1) 
       { 
        fos.write(data_AR); 
        Log.i(TAG, "Association Responsed!"); 
       } 
       else if (count == 2) 
       { 
        fos.write(get_MDS); 
        Log.i(TAG, "Get MDS object attributes!"); 
//     fos.write(data_ABORT); 
       } 
       else if (count == 3) 
       { 
        fos.write(data_DR); 
        Log.i(TAG, "Data Responsed!"); 
       } 
       else if (count == 4) 
       { 
        fos.write(data_RR); 
        Log.i(TAG, "Data Released!"); 
       } 
      } catch(IOException ioe) {} 
     } 
    } 

이 코드를 이해하려면 IEEE 11073 사양도 읽어야합니다. 모든 종류의 센서에는 그 자신의 바이트 수가 있습니다.

나는이 코드를 작성하지 않았다. 누군가 나에게 그것을 주었다. 그가 나를 제거 할 것을 요구하면, 나는 할 것이다 :

+0

구문 분석을 고수했기 때문에 자세한 내용을 설명해 주시겠습니까? hdp 장치에서 오는 데이터의 당신이 어떻게 해결했는지 도와주세요. –

+0

@SajidShaikh : 답변을 업데이트했습니다. –

+0

덕분에 ... 내 장치를 확인하고 .. 알려 드리겠습니다. –