fix CP2102N initialization

do not send SET_BAUDDIV command. It fails on CP2102N and CP2102/5 work without
This commit is contained in:
kai-morich 2020-03-01 13:49:51 +01:00
parent 17c3d40605
commit 2cad1fd5a2
2 changed files with 4 additions and 5 deletions

View File

@ -5,7 +5,7 @@ publishing {
maven(MavenPublication) { maven(MavenPublication) {
groupId 'com.github.mik3y' groupId 'com.github.mik3y'
artifactId 'usb-serial-for-android' artifactId 'usb-serial-for-android'
version '2.2.0a' version '2.2.2a'
afterEvaluate { afterEvaluate {
artifact androidSourcesJar artifact androidSourcesJar
artifact bundleReleaseAar artifact bundleReleaseAar

View File

@ -128,13 +128,12 @@ public class Cp21xxSerialDriver implements UsbSerialDriver {
return Cp21xxSerialDriver.this; return Cp21xxSerialDriver.this;
} }
private int setConfigSingle(int request, int value) throws IOException { private void setConfigSingle(int request, int value) throws IOException {
int result = mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, request, value, int result = mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, request, value,
mPortNumber, null, 0, USB_WRITE_TIMEOUT_MILLIS); mPortNumber, null, 0, USB_WRITE_TIMEOUT_MILLIS);
if (result != 0) { if (result != 0) {
throw new IOException("Setting baudrate failed: result=" + result); throw new IOException("Control transfer failed: " + request + " / " + value + " -> " + result);
} }
return result;
} }
@Override @Override
@ -160,7 +159,7 @@ public class Cp21xxSerialDriver implements UsbSerialDriver {
setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE); setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS); setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE); // setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
// setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY); // setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
} }