1 Reply Latest reply on Jun 16, 2016 7:35 AM by Robin West

    kr403 sdk java sendAndWaitForResponse

    Plagnes Didier

      Hello,

       

      usb.sendAndWaitForResponse("~HQES".getBytes(), 1000, 1000,null);

       

      When I run this command line, sometimes answer is empty or length is double (message is double but right).

       

      Do you know why ? do I need reset buffer before run ?

       

      thanks

       

      Didier

       

       

        • Re: kr403 sdk java sendAndWaitForResponse
          Robin West

          Hi Didier,

          I'm moving this question to the printer pages. 

           

          The ~HQES may take the printer a little time to process.   If the printer doesn't respond within the timeout you have given, it may still respond and sit in the USB buffer on the Android until you request it again.  That's why sometimes it's empty and other times you get double.  It may have the previous response in the buffer.  Also the printers, when powering off, sometimes flush the last USB response again, so you may get an extra then. 

          Some ideas:

          1. Try upping the initialResponseTimeout to maybe 2000, and cutting the timeToWaitForMoreData to 500.  Once the printer starts responding, it doesn't take long for it to finish on this command.

          2. You could also just try again if you get an empty response the first time and discard the extra data you get back.

          3. Try using the string terminator to just pull a single response: usb.sendAndWaitForResponse("~HQES".getBytes(), 2000, 1000,new String(new byte[] { 0x03 }));

          1 of 1 people found this helpful