UsbSerial icon indicating copy to clipboard operation
UsbSerial copied to clipboard

Problem in receiving data

Open saury001 opened this issue 9 years ago • 4 comments

Whenever I am receiving data in UsbReadCallback and displaying it in setText() method of textview its showing incorrect values i.e. a part of value eg. Sometimes it display 00 for 100 and 2 for 42 etc. But its working fine in append() method of textview.What to do?

saury001 avatar Dec 31 '16 17:12 saury001

I have Same Problem. that's issue so important. please patch it

danialrajabi avatar Jul 23 '18 19:07 danialrajabi

same problem here.

JudeBautista avatar Oct 01 '18 14:10 JudeBautista

hey @saury001 , i have a problem in the receiving data, how did you manage it? because mine I cant receive any , can you help me?

here is my code:

 public void openDevice()
    {
        connection = usbManager.openDevice(printer);
        debug.append("printer:  "+printer +"\n");
        debug.append("connection:  "+connection+"\n");
        serialDevice = UsbSerialDevice.createUsbSerialDevice(printer, connection);
        debug.append("serialDevice:  "+serialDevice.toString()+"\n");
        if (serialDevice != null) {
            if (serialDevice.open()) {
                serialDevice.setBaudRate(9600);
                serialDevice.setStopBits(UsbSerialInterface.STOP_BITS_1);
                serialDevice.setParity(UsbSerialInterface.PARITY_NONE);
                serialDevice.setFlowControl(UsbSerialInterface.FLOW_CONTROL_OFF);
                serialDevice.setRTS(true);
             //   serialDevice.read(mCallback);
            } else {
                debug.append("Printer port not open \n");
            }
        } else {
            debug.append("Serial is null \n");
        }
    }

    public void sendData(String data)
    {
        debug.append("\n sendData  \n"+data.getBytes());
        serialDevice.write(data.getBytes());
        serialDevice.read(mCallback);

    }

    String respond;
    private UsbSerialInterface.UsbReadCallback mCallback = new UsbSerialInterface.UsbReadCallback() {
        @Override
        public void onReceivedData(byte[] arg0)
        {
            Toast.makeText(getApplication(),"RESPONSE TERMINAL: "+arg0,Toast.LENGTH_LONG ).show();
            debug.append("RESPOND TERMINAL ONLY"+respond+"\n");

        }
    };
 

is there any i missed ? can you help me on this please?

JudeBautista avatar Oct 01 '18 14:10 JudeBautista

Whenever I am receiving data in UsbReadCallback and displaying it in setText() method of textview its showing incorrect values i.e. a part of value eg. Sometimes it display 00 for 100 and 2 for 42 etc. But its working fine in append() method of textview.What to do?

same I am facing the same issue when I use SetText() but it works fine when I use append() I really need to solve this issue

niranjan-tech avatar Oct 06 '21 17:10 niranjan-tech