felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.8k stars 585 forks source link

on app, I wrote with Serial.write("rrr".getBytes()), but arduino doesn't received. #263

Open kotran88 opened 5 years ago

kotran88 commented 5 years ago

android code is as below I checked Serialport is opened, then I write string data to arduino

     ` serialPort = UsbSerialDevice.createUsbSerialDevice(UsbSerialDevice.CP210x, device, connection,0);
                if (serialPort != null) {
                    Toast.makeText(getApplicationContext(),"opened!!!",Toast.LENGTH_SHORT).show();
                    Log.e("dialog","serialport : "+serialPort.toString());

                    serialPort.setBaudRate(9600);
                    serialPort.setDataBits(UsbSerialInterface.DATA_BITS_8);
                    serialPort.setStopBits(UsbSerialInterface.STOP_BITS_1);
                    serialPort.setParity(UsbSerialInterface.PARITY_NONE);
                    serialPort.setFlowControl(UsbSerialInterface.FLOW_CONTROL_OFF);

                    serialPort.write("rrr".getBytes());

                    serialPort.read(mCallback); //

                } else {
                    Log.e("dialog", "PORT IS NULL");
                }`

on arduino, loop(){ }

I added blink to recognize arduino is received string data well. but not blinking at all... what did I do wrong.

kotran88 commented 5 years ago

my git address to refer is...

https://github.com/kotran88/SerialPrinting

feder240516 commented 4 years ago

could you solve this? having same problem here

helaquiz commented 4 years ago

You need to write in other function see the example https://github.com/felHR85/UsbSerial/tree/master/example

And in Arduino you need to begin the serial port