mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.9k stars 1.59k forks source link

how can i change stopbit and PARITY #438

Closed zxy243153431 closed 2 years ago

zxy243153431 commented 2 years ago

my project neet to change these two attribute when in data communication. For example : port.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_EVEN); ...write some data port.setParameters(9600, 8, UsbSerialPort.STOPBITS_2, UsbSerialPort.PARITY_NONE); ...write some data ...read bytes port.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_EVEN); .....write some data ....read bytes

i wrote code like this ,but the result not working as expected. i want to ask how can i do that stopbit and PARITY can be changed in data communication.

kai-morich commented 2 years ago

parameters can be changed with setParameters repeatedly when the connection is open, e.g. tested here. maybe you have to wait until old data is fully read/written

zxy243153431 commented 2 years ago

parameters can be changed with setParameters repeatedly when the connection is open, e.g. tested here. maybe you have to wait until old data is fully read/written

i tried and it runs success! thank you very much.