Android arduino communication via usb using adk mode -


i working on android , arduino application uses adk mode communication have implemented runnable in main activity , in run method of reading values , when reading finishes writing values arduino board , communication running infinite.i using handler updating gui application stops it's communication after sometime not able figure out problem? gui update in handler takes more time happening or else?

following code receiving , sending data:

 while (true) { // read data     try {     int ret_read = 0;     byte[] buffer_read = new byte[128];     ret_read = minputstream.read(buffer_read);      (int p = 0; p < 2 * (nooffsensors); p = p + 2) {     intlistvalues.add((int) composeint(buffer_read[p],                 buffer_read[p + 1]));      log.d("jankari", "pu value : "+string.valueof((int) composeint(buffer_read[p],                 buffer_read[p + 1])));      }         message mpu = message.obtain(mhandlerpusensors);       mpu.obj = new valuemsgpusensors("f", ret_read,intlistfvalues);         mhandlerpusensors.sendmessage(mpu);      (int = 0; < 2 * (noofansensors); = + 2) {     intlistanvalues.add((int) (composeint(buffer_read[2* (nooffsensors) + a],                  buffer_read[2* (nooffsensors) + + 1])));     log.d("jankari", "an value : "+string.valueof(          (int) (composeint(buffer_read[2* (nooffsensors) + a],      buffer_read[2* (nooffsensors) + + 1]))));      }     message man = message.obtain(mhandleransensors);     man.obj = new valuemsgansensors("f", ret_read,     intlistanvalues);     mhandleransensors.sendmessage(man);      (int l = 0; l < noofsw; l++) {     intlistswvalues.add((int) buffer_read[2* (nooffsensors) +         2 * (noofansensors) + l]);     log.d("jankari", "sw : "+string.valueof((int)           buffer_read[2* (nooffsensors) + 2 * (noofansensors) + l]) );     }     message msw = message.obtain(mhandlerswsensors);     msw.obj = new valuemsgswsensors("f", ret_read,intlistswvalues);     mhandlerswsensors.sendmessage(msw);          += 1;       minputstream.close();      // send output arduino     sendoutput();        } catch (ioexception e) {       break;     }  } 

and handlers using are,

handler mhandlerpusensors = new handler() {         @override     public void handlemessage(message msg) {         valuemsgpusensors msgpu = (valuemsgpusensors) msg.obj;         txtreceivedbytes.settext("received bytes: " + msgpu.getret());         (int = 0; < txtlistfsensors.size(); i++) {             txtlistfsensors.get(i).settext(string.valueof(msgpu.getfreadings().get(i)));         }         intlistfvalues.clear();              } }; 


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -