I'm using Flutter, lib:usb_serial 0.4.0, I was trying to connect with my chip by CDC prototype. In other iphone it still working but since I'm using Samsung, it not show any verify connection, and of course cannot open usbserial port or communicate with it. I had been used usb debug on Samsung develop options but still not working. Here is my code:
String _serialData = '';
int increase =0;
int increase2 =0;
bool accdown=true;
var checked;
bool trasmit= false;
String _jsResult = '';
var transaction;
UsbPort port = UsbPort('1');
late InAppWebViewController controlleroll;
var devices;
bool setUHF_on=false;
void startup() async {
List<UsbDevice> device = await UsbSerial.listDevices();
//checked=devices.toString();
UsbPort _port;
if (device.length == 0) {
accdown=false;
return;
}
else{
accdown=true;
}
devices = device;
_port = (await device[0].create(UsbSerial.CDC))!;// not working on samsung
bool openResult = await _port.open();
if ( !openResult ) {
print("Failed to open");
accdown=false;
return;
}
await _port.setDTR(true);
await _port.setRTS(true);
_port.setPortParameters(115200, UsbPort.DATABITS_8,
UsbPort.STOPBITS_1, UsbPort.PARITY_NONE);
Transaction<String> transactions = Transaction.stringTerminated(_port.inputStream!, Uint8List.fromList([13,10]));
port =_port;
transaction = transactions;
// While using transactions you can still listen to all
// incoming messages!
transactions.stream.listen( (String data) {
if(true){
_serialData=data;
if(_serialData.contains('EPC:')){
controlleroll.evaluateJavascript(source: "transactionUHF('"+_serialData+"')");
}
else{
controlleroll.evaluateJavascript(source: "transaction('"+_serialData+"')");
}
}
});
}
I Also request permission on android: enter image description hereenter image description here