mirror of
https://github.com/mik3y/usb-serial-for-android
synced 2025-07-07 22:56:27 +00:00
Compare commits
15 Commits
896b242be0
...
5bb8db02d5
Author | SHA1 | Date | |
---|---|---|---|
|
5bb8db02d5 | ||
|
963ae1d243 | ||
|
ab27c19dc3 | ||
|
1091b4d88b | ||
|
b0e956c5b3 | ||
|
82aeccbf1c | ||
|
f8e76c9b3b | ||
|
1d4e0128c0 | ||
|
f997a8b68a | ||
|
cf9bada887 | ||
|
b853ac773c | ||
|
1f35587739 | ||
|
dea836d8ce | ||
|
a2fa5f010a | ||
|
49ee2d3c8e |
@ -29,7 +29,7 @@ allprojects {
|
||||
Add library to dependencies
|
||||
```gradle
|
||||
dependencies {
|
||||
implementation 'com.github.mik3y:usb-serial-for-android:3.4.3'
|
||||
implementation 'com.github.mik3y:usb-serial-for-android:3.4.6'
|
||||
}
|
||||
```
|
||||
|
||||
@ -140,7 +140,7 @@ This library supports USB to serial converter chips:
|
||||
* FTDI FT232R, FT232H, FT2232H, FT4232H, FT230X, FT231X, FT234XD
|
||||
* Prolific PL2303
|
||||
* Silabs CP2102 and all other CP210x
|
||||
* Qinheng CH340, CH341A
|
||||
* Qinheng CH340, CH341A, CH9102
|
||||
|
||||
and devices implementing the CDC/ACM protocol like
|
||||
* Arduino using ATmega32U4
|
||||
|
@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.2'
|
||||
classpath 'com.android.tools.build:gradle:7.0.4'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
#android.enableJetifier=true
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
|
@ -3,8 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion '30.0.3'
|
||||
compileSdkVersion 32
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
@ -13,10 +12,9 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 32
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
testInstrumentationRunner "android.test.InstrumentationTestRunner"
|
||||
missingDimensionStrategy 'device', 'anyDevice'
|
||||
}
|
||||
|
||||
@ -29,6 +27,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation project(':usbSerialForAndroid')
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
}
|
||||
|
@ -17,7 +17,8 @@
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize">
|
||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -8,6 +8,7 @@ import android.content.IntentFilter;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbDeviceConnection;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -211,7 +212,8 @@ public class TerminalFragment extends Fragment implements SerialInputOutputManag
|
||||
UsbDeviceConnection usbConnection = usbManager.openDevice(driver.getDevice());
|
||||
if(usbConnection == null && usbPermission == UsbPermission.Unknown && !usbManager.hasPermission(driver.getDevice())) {
|
||||
usbPermission = UsbPermission.Requested;
|
||||
PendingIntent usbPermissionIntent = PendingIntent.getBroadcast(getActivity(), 0, new Intent(INTENT_ACTION_GRANT_USB), 0);
|
||||
int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0;
|
||||
PendingIntent usbPermissionIntent = PendingIntent.getBroadcast(getActivity(), 0, new Intent(INTENT_ACTION_GRANT_USB), flags);
|
||||
usbManager.requestPermission(driver.getDevice(), usbPermissionIntent);
|
||||
return;
|
||||
}
|
||||
|
@ -32,4 +32,7 @@
|
||||
<usb-device vendor-id="7855" product-id="4" /> <!-- 0x1eaf / 0x0004: Leaflabs Maple -->
|
||||
<usb-device vendor-id="3368" product-id="516" /> <!-- 0x0d28 / 0x0204: ARM mbed -->
|
||||
<usb-device vendor-id="1155" product-id="22336" /><!-- 0x0483 / 0x5740: ST CDC -->
|
||||
<usb-device vendor-id="11914" product-id="5" /> <!-- 0x2E8A / 0x0005: Raspberry Pi Pico Micropython -->
|
||||
<usb-device vendor-id="11914" product-id="10" /> <!-- 0x2E8A / 0x000A: Raspberry Pi Pico SDK -->
|
||||
<usb-device vendor-id="6790" product-id="21972" /><!-- 0x1A86 / 0x55D4: Qinheng CH9102F -->
|
||||
</resources>
|
||||
|
@ -4,17 +4,16 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion '30.0.3'
|
||||
compileSdkVersion 32
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 32
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunnerArguments = [ // Raspi Windows LinuxVM ...
|
||||
'rfc2217_server_host': '192.168.0.100',
|
||||
'rfc2217_server_host': '192.168.0.186',
|
||||
'rfc2217_server_nonstandard_baudrates': 'true', // true false false
|
||||
]
|
||||
}
|
||||
@ -25,10 +24,11 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "androidx.annotation:annotation:1.2.0"
|
||||
implementation "androidx.annotation:annotation:1.3.0"
|
||||
implementation 'androidx.test:core:1.4.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.mockito:mockito-core:1.10.19'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||
androidTestImplementation 'commons-net:commons-net:3.8.0'
|
||||
androidTestImplementation 'org.apache.commons:commons-lang3:3.11'
|
||||
}
|
||||
@ -38,7 +38,7 @@ project.afterEvaluate {
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
from components.release
|
||||
from components.release // change to anyDeviceRelease if coverage is enabled
|
||||
artifact androidSourcesJar
|
||||
|
||||
// values used for local maven repo, jitpack uses github release:
|
||||
|
@ -7,13 +7,15 @@ package com.hoho.android.usbserial;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialPort;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber;
|
||||
import com.hoho.android.usbserial.util.TestBuffer;
|
||||
import com.hoho.android.usbserial.util.UsbWrapper;
|
||||
|
||||
import org.junit.Before;
|
||||
@ -24,12 +26,14 @@ import org.junit.rules.TestWatcher;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
@ -55,7 +59,7 @@ public class CrossoverTest {
|
||||
assumeTrue("ignore test for device specific coverage report",
|
||||
InstrumentationRegistry.getArguments().getString("test_device_driver") == null);
|
||||
|
||||
context = InstrumentationRegistry.getContext();
|
||||
context = ApplicationProvider.getApplicationContext();
|
||||
usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
|
||||
List<UsbSerialDriver> availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager);
|
||||
assertNotEquals("no USB device found", 0, availableDrivers.size());
|
||||
@ -160,4 +164,53 @@ public class CrossoverTest {
|
||||
usb2.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void concurrent() throws Exception {
|
||||
// 115200 baud ~= 11kB/sec => ~1.5 second test duration with 16kB tbuf
|
||||
// concurrent (+ blocking) write calls as tbuf larger than any buffer size returned by UsbWrapper.getWriteSizes()
|
||||
// concurrent read calls in IoManager threads
|
||||
TestBuffer tbuf1 = new TestBuffer(16*1024);
|
||||
TestBuffer tbuf2 = new TestBuffer(16*1024);
|
||||
|
||||
class WriteRunnable implements Runnable {
|
||||
public WriteRunnable(int port) { this.port = port; }
|
||||
private final int port;
|
||||
Exception exc;
|
||||
@Override
|
||||
public void run() {
|
||||
byte[] buf = new byte[1024];
|
||||
try {
|
||||
for(int i=0; i<tbuf1.buf.length / 1024; i++) {
|
||||
System.arraycopy(tbuf1.buf, i*1024, buf, 0, 1024);
|
||||
if (port == 1)
|
||||
usb1.write(buf);
|
||||
else
|
||||
usb2.write(buf);
|
||||
}
|
||||
} catch (IOException exc) {
|
||||
this.exc = exc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usb1.open();
|
||||
usb2.open();
|
||||
usb1.setParameters(115200, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
usb2.setParameters(115200, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
WriteRunnable wr1 = new WriteRunnable(1), wr2 = new WriteRunnable(2);
|
||||
Thread wt1 = new Thread(wr1), wt2 = new Thread(wr2);
|
||||
boolean done1 = false, done2 = false;
|
||||
wt1.start();
|
||||
Thread.sleep(50);
|
||||
wt2.start();
|
||||
while(!done1 && !done2) {
|
||||
if(!done1)
|
||||
done1 = tbuf1.testRead(usb1.read(-1));
|
||||
if(!done2)
|
||||
done2 = tbuf2.testRead(usb2.read(-1));
|
||||
}
|
||||
wt1.join(); wt2.join();
|
||||
assertNull(wr1.exc);
|
||||
assertNull(wr2.exc);
|
||||
}
|
||||
}
|
||||
|
@ -15,26 +15,30 @@ import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbDeviceConnection;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Process;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hoho.android.usbserial.driver.CdcAcmSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.Ch34xSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.CommonUsbSerialPort;
|
||||
import com.hoho.android.usbserial.driver.CommonUsbSerialPortWrapper;
|
||||
import com.hoho.android.usbserial.driver.Cp21xxSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.FtdiSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.ProbeTable;
|
||||
import com.hoho.android.usbserial.driver.ProlificSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.ProlificWrapper;
|
||||
import com.hoho.android.usbserial.driver.ProlificSerialPortWrapper;
|
||||
import com.hoho.android.usbserial.driver.SerialTimeoutException;
|
||||
import com.hoho.android.usbserial.driver.UsbId;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialPort;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialProber;
|
||||
import com.hoho.android.usbserial.util.SerialInputOutputManager;
|
||||
import com.hoho.android.usbserial.util.TelnetWrapper;
|
||||
import com.hoho.android.usbserial.util.TestBuffer;
|
||||
import com.hoho.android.usbserial.util.UsbWrapper;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialPort.ControlLine;
|
||||
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
@ -85,7 +89,6 @@ public class DeviceTest {
|
||||
private UsbManager usbManager;
|
||||
UsbWrapper usb;
|
||||
static TelnetWrapper telnet;
|
||||
private boolean isCp21xxRestrictedPort = false; // second port of Cp2105 has limited dataBits, stopBits, parity
|
||||
|
||||
@Rule
|
||||
public TestRule watcher = new TestWatcher() {
|
||||
@ -110,7 +113,7 @@ public class DeviceTest {
|
||||
public void setUp() throws Exception {
|
||||
telnet.setUp();
|
||||
|
||||
context = InstrumentationRegistry.getContext();
|
||||
context = ApplicationProvider.getApplicationContext();
|
||||
usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
|
||||
List<UsbSerialDriver> availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager);
|
||||
if(availableDrivers.isEmpty()) {
|
||||
@ -129,7 +132,6 @@ public class DeviceTest {
|
||||
usb.setUp();
|
||||
|
||||
Log.i(TAG, "Using USB device "+ usb.serialPort.toString()+" driver="+usb.serialDriver.getClass().getSimpleName());
|
||||
isCp21xxRestrictedPort = usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size()==2 && test_device_port == 1;
|
||||
telnet.read(-1); // doesn't look related here, but very often after usb permission dialog the first test failed with telnet garbage
|
||||
}
|
||||
|
||||
@ -145,34 +147,6 @@ public class DeviceTest {
|
||||
telnet.tearDownFixture();
|
||||
}
|
||||
|
||||
private static class TestBuffer {
|
||||
private final byte[] buf;
|
||||
private int len;
|
||||
|
||||
private TestBuffer(int length) {
|
||||
len = 0;
|
||||
buf = new byte[length];
|
||||
int i=0;
|
||||
int j=0;
|
||||
for(j=0; j<length/16; j++)
|
||||
for(int k=0; k<16; k++)
|
||||
buf[i++]=(byte)j;
|
||||
while(i<length)
|
||||
buf[i++]=(byte)j;
|
||||
}
|
||||
|
||||
private boolean testRead(byte[] data) {
|
||||
assertNotEquals(0, data.length);
|
||||
assertTrue("got " + (len+data.length) +" bytes", (len+data.length) <= buf.length);
|
||||
for(int j=0; j<data.length; j++)
|
||||
assertEquals("at pos "+(len+j), (byte)((len+j)/16), data[j]);
|
||||
len += data.length;
|
||||
//Log.d(TAG, "read " + len);
|
||||
return len == buf.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// clone of org.apache.commons.lang3.StringUtils.indexOfDifference + optional startpos
|
||||
private static int indexOfDifference(final CharSequence cs1, final CharSequence cs2) {
|
||||
return indexOfDifference(cs1, cs2, 0, 0);
|
||||
@ -229,7 +203,7 @@ public class DeviceTest {
|
||||
doReadWrite(reason, -1);
|
||||
}
|
||||
private void doReadWrite(String reason, int readWait) throws Exception {
|
||||
byte[] buf1 = new byte[]{ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x55, 0x55};
|
||||
byte[] buf1 = new byte[]{ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x55, 0x55};
|
||||
byte[] buf2 = new byte[]{ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x55, 0x55};
|
||||
byte[] data;
|
||||
|
||||
@ -323,9 +297,9 @@ public class DeviceTest {
|
||||
403200, 460800, 614400, 806400, 921600, 1228800, 2457600, 3000000, /*6000000*/
|
||||
};
|
||||
usb.open();
|
||||
Assume.assumeFalse("only for non PL2303G*", ProlificWrapper.isDeviceTypeHxn(usb.serialPort)); // HXN does not use divisor
|
||||
Assume.assumeFalse("only for non PL2303G*", ProlificSerialPortWrapper.isDeviceTypeHxn(usb.serialPort)); // HXN does not use divisor
|
||||
|
||||
int minBaudRate = ProlificWrapper.isDeviceTypeT(usb.serialPort) ? 6 : 46;
|
||||
int minBaudRate = ProlificSerialPortWrapper.isDeviceTypeT(usb.serialPort) ? 6 : 46;
|
||||
try {
|
||||
usb.setParameters(minBaudRate-1, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
fail("baud rate to low expected");
|
||||
@ -505,7 +479,7 @@ public class DeviceTest {
|
||||
}
|
||||
|
||||
for(int baudRate : new int[] {300, 2400, 19200, 115200} ) {
|
||||
if(baudRate == 300 && isCp21xxRestrictedPort) {
|
||||
if(baudRate == 300 && usb.isCp21xxRestrictedPort) {
|
||||
try {
|
||||
usb.setParameters(baudRate, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
fail("baudrate 300 on cp21xx restricted port");
|
||||
@ -518,7 +492,7 @@ public class DeviceTest {
|
||||
|
||||
doReadWrite(baudRate+"/8N1");
|
||||
}
|
||||
if(rfc2217_server_nonstandard_baudrates && !isCp21xxRestrictedPort) {
|
||||
if(rfc2217_server_nonstandard_baudrates && !usb.isCp21xxRestrictedPort) {
|
||||
usb.setParameters(42000, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
telnet.setParameters(42000, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
|
||||
@ -604,7 +578,7 @@ public class DeviceTest {
|
||||
data = telnet.read(2);
|
||||
assertThat("19000/7N1", data, equalTo(new byte[]{(byte) 0x80, (byte) 0xff}));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
if(!isCp21xxRestrictedPort)
|
||||
if(!usb.isCp21xxRestrictedPort)
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
@ -615,7 +589,7 @@ public class DeviceTest {
|
||||
data = telnet.read(2);
|
||||
assertThat("19000/6N1", data, equalTo(new byte[]{(byte) 0xc0, (byte) 0xff}));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
if (!(isCp21xxRestrictedPort || usb.serialDriver instanceof FtdiSerialDriver))
|
||||
if (!(usb.isCp21xxRestrictedPort || usb.serialDriver instanceof FtdiSerialDriver))
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
@ -626,7 +600,7 @@ public class DeviceTest {
|
||||
data = telnet.read(2);
|
||||
assertThat("19000/5N1", data, equalTo(new byte[] {(byte)0xe0, (byte)0xff}));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
if (!(isCp21xxRestrictedPort || usb.serialDriver instanceof FtdiSerialDriver))
|
||||
if (!(usb.isCp21xxRestrictedPort || usb.serialDriver instanceof FtdiSerialDriver))
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@ -649,7 +623,7 @@ public class DeviceTest {
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
if(isCp21xxRestrictedPort) {
|
||||
if(usb.isCp21xxRestrictedPort) {
|
||||
usb.setParameters(19200, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
usb.setParameters(19200, 8, 1, UsbSerialPort.PARITY_EVEN);
|
||||
usb.setParameters(19200, 8, 1, UsbSerialPort.PARITY_ODD);
|
||||
@ -779,7 +753,7 @@ public class DeviceTest {
|
||||
data = telnet.read(2);
|
||||
assertThat("19200/8N1", data, equalTo(new byte[]{1, 11}));
|
||||
} catch(UnsupportedOperationException e) {
|
||||
if(!isCp21xxRestrictedPort)
|
||||
if(!usb.isCp21xxRestrictedPort)
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
@ -816,33 +790,24 @@ public class DeviceTest {
|
||||
assertEquals(availableDrivers.get(0).getClass(), usb.serialDriver.getClass());
|
||||
}
|
||||
|
||||
// return [write packet size, write buffer size(s)]
|
||||
private int[] getWriteSizes() {
|
||||
if (usb.serialDriver instanceof Cp21xxSerialDriver) {
|
||||
if (usb.serialDriver.getPorts().size() == 1) return new int[]{64, 576};
|
||||
else if (usb.serialPort.getPortNumber() == 0) return new int[]{64, 320};
|
||||
else return new int[]{32, 128, 160}; // write buffer size detection is unreliable
|
||||
} else if (usb.serialDriver instanceof Ch34xSerialDriver) {
|
||||
return new int[]{32, 64};
|
||||
} else if (usb.serialDriver instanceof ProlificSerialDriver) {
|
||||
return new int[]{64, 256};
|
||||
} else if (usb.serialDriver instanceof FtdiSerialDriver) {
|
||||
switch (usb.serialDriver.getPorts().size()) {
|
||||
case 1: return new int[]{64, 128};
|
||||
case 2: return new int[]{512, 4096};
|
||||
case 4: return new int[]{512, 2048};
|
||||
default: return null;
|
||||
}
|
||||
} else if (usb.serialDriver instanceof CdcAcmSerialDriver) {
|
||||
return new int[]{64, 128};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeTimeout() throws Exception {
|
||||
public void writeSizes() throws Exception {
|
||||
assertNull(CommonUsbSerialPortWrapper.getWriteBuffer(usb.serialPort));
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(12);
|
||||
assertEquals(12, CommonUsbSerialPortWrapper.getWriteBuffer(usb.serialPort).length);
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(-1);
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(-1);
|
||||
assertNull(CommonUsbSerialPortWrapper.getWriteBuffer(usb.serialPort));
|
||||
usb.open();
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(12);
|
||||
assertEquals(12, CommonUsbSerialPortWrapper.getWriteBuffer(usb.serialPort).length);
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(-1);
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(-1);
|
||||
assertEquals(usb.serialPort.getWriteEndpoint().getMaxPacketSize(),
|
||||
CommonUsbSerialPortWrapper.getWriteBuffer(usb.serialPort).length);
|
||||
assertEquals(usb.serialPort.getWriteEndpoint().getMaxPacketSize(),
|
||||
usb.serialPort.getReadEndpoint().getMaxPacketSize());
|
||||
|
||||
int baudRate = 300;
|
||||
if(usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() > 1)
|
||||
baudRate = 2400;
|
||||
@ -866,27 +831,32 @@ public class DeviceTest {
|
||||
|
||||
int writeBufferSize = writePacketSize * writePackets;
|
||||
Log.d(TAG, "write packet size = " + writePacketSize + ", write buffer size = " + writeBufferSize);
|
||||
int[] writeSizes = getWriteSizes();
|
||||
assertNotNull(writeSizes);
|
||||
assertEquals("write packet size", writeSizes[0], writePacketSize);
|
||||
assertTrue("write buffer size", Arrays.binarySearch(writeSizes, writeBufferSize) > 0);
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
if(usb.serialDriver instanceof CdcAcmSerialDriver)
|
||||
return; // serial processing to slow for tests below, but they anyway only check shared code in CommonUsbSerialPort
|
||||
if(usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() > 1)
|
||||
return; // write buffer size detection unreliable as baud rate to high
|
||||
assertEquals("write packet size", usb.writePacketSize, writePacketSize);
|
||||
if (usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() == 1) // write buffer size detection is unreliable
|
||||
assertTrue("write buffer size " + writeBufferSize, writeBufferSize == usb.writeBufferSize || writeBufferSize == usb.writeBufferSize + 64);
|
||||
else
|
||||
assertEquals("write buffer size", usb.writeBufferSize, writeBufferSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeTimeout() throws Exception {
|
||||
// serial processing to slow for tests below, but they anyway only check shared code in CommonUsbSerialPort
|
||||
Assume.assumeFalse(usb.serialDriver instanceof CdcAcmSerialDriver);
|
||||
// write buffer size detection unreliable as baud rate to high
|
||||
Assume.assumeFalse(usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() > 1);
|
||||
|
||||
usb.open();
|
||||
usb.setParameters(9600, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
telnet.setParameters(9600, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
TestBuffer tbuf;
|
||||
int purgeTimeout = 250;
|
||||
|
||||
// total write timeout
|
||||
tbuf = new TestBuffer(writeBufferSize + writePacketSize);
|
||||
int timeout = writePacketSize / 32 * 50; // time for 1.5 packets. write 48 byte in 50 msec at 9600 baud
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(writePacketSize);
|
||||
tbuf = new TestBuffer(usb.writeBufferSize + usb.writePacketSize);
|
||||
int timeout = usb.writePacketSize / 32 * 50; // time for 1.5 packets. write 48 byte in 50 msec at 9600 baud
|
||||
usb.serialPort.write(tbuf.buf, timeout);
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
tbuf = new TestBuffer(writeBufferSize + 2*writePacketSize);
|
||||
tbuf = new TestBuffer(usb.writeBufferSize + 2*usb.writePacketSize);
|
||||
try {
|
||||
usb.serialPort.write(tbuf.buf, timeout); // would not fail if each block has own timeout
|
||||
fail("write error expected");
|
||||
@ -894,12 +864,11 @@ public class DeviceTest {
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
|
||||
// infinite wait
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(writePacketSize);
|
||||
usb.serialPort.write(tbuf.buf, 0);
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
|
||||
// timeout in bulkTransfer + SerialTimeoutException.bytesTransferred
|
||||
int readWait = writePacketSize > 64 ? 250 : 50;
|
||||
int readWait = usb.writePacketSize > 64 ? 250 : 50;
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(tbuf.buf.length);
|
||||
try {
|
||||
usb.serialPort.write(tbuf.buf, timeout);
|
||||
@ -911,10 +880,10 @@ public class DeviceTest {
|
||||
tbuf.testRead(data);
|
||||
}
|
||||
assertEquals(0, ex.bytesTransferred);
|
||||
assertEquals(writeBufferSize + writePacketSize, tbuf.len);
|
||||
assertEquals(usb.writeBufferSize + usb.writePacketSize, tbuf.len);
|
||||
}
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(writePacketSize);
|
||||
((CommonUsbSerialPort)usb.serialPort).setWriteBufferSize(-1);
|
||||
tbuf.len = 0;
|
||||
try {
|
||||
usb.serialPort.write(tbuf.buf, timeout);
|
||||
@ -925,8 +894,8 @@ public class DeviceTest {
|
||||
data = telnet.read(-1, readWait)) {
|
||||
tbuf.testRead(data);
|
||||
}
|
||||
assertEquals(writeBufferSize + writePacketSize, ex.bytesTransferred);
|
||||
assertEquals(writeBufferSize + writePacketSize, tbuf.len);
|
||||
assertEquals(usb.writeBufferSize + usb.writePacketSize, ex.bytesTransferred);
|
||||
assertEquals(usb.writeBufferSize + usb.writePacketSize, tbuf.len);
|
||||
}
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
|
||||
@ -967,15 +936,12 @@ public class DeviceTest {
|
||||
if(usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() == 1)
|
||||
purge = false; // purge is blocking
|
||||
|
||||
int[] writeSizes = getWriteSizes();
|
||||
int writePacketSize = writeSizes[0];
|
||||
int writeBufferSize = writeSizes[1];
|
||||
int purgeTimeout = 250;
|
||||
TestBuffer tbuf;
|
||||
long begin;
|
||||
int duration1, duration2, retries, i;
|
||||
retries = purge ? 10 : 1;
|
||||
tbuf = new TestBuffer(writeBufferSize);
|
||||
tbuf = new TestBuffer(usb.writeBufferSize);
|
||||
|
||||
((CommonUsbSerialPort) usb.serialPort).setWriteBufferSize(tbuf.buf.length);
|
||||
Log.d(TAG, "writeDuration: full write begin");
|
||||
@ -989,7 +955,7 @@ public class DeviceTest {
|
||||
if(!purge)
|
||||
purgeWriteBuffer(purgeTimeout);
|
||||
Log.d(TAG, "writeDuration: full write end, duration " + duration1/(float)(retries) + " msec");
|
||||
((CommonUsbSerialPort) usb.serialPort).setWriteBufferSize(writePacketSize);
|
||||
((CommonUsbSerialPort) usb.serialPort).setWriteBufferSize(-1);
|
||||
Log.d(TAG, "writeDuration: packet write begin");
|
||||
begin = System.currentTimeMillis();
|
||||
for(i=0; i<retries; i++) {
|
||||
@ -1010,7 +976,7 @@ public class DeviceTest {
|
||||
usb.setParameters(115200, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
telnet.setParameters(115200, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
|
||||
((CommonUsbSerialPort) usb.serialPort).setWriteBufferSize(12);
|
||||
((CommonUsbSerialPort) usb.serialPort).setWriteBufferSize(12); // init buffer
|
||||
((CommonUsbSerialPort) usb.serialPort).setWriteBufferSize(12); // keeps last buffer
|
||||
TestBuffer buf = new TestBuffer(256);
|
||||
usb.serialPort.write(buf.buf, 5000);
|
||||
@ -1291,7 +1257,7 @@ public class DeviceTest {
|
||||
@Test
|
||||
public void purgeHwBuffers() throws Exception {
|
||||
// purge write buffer
|
||||
// 2400 is slowest baud rate for isCp21xxRestrictedPort
|
||||
// 2400 is slowest baud rate for usb.isCp21xxRestrictedPort
|
||||
usb.open();
|
||||
usb.setParameters(2400, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
telnet.setParameters(2400, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
@ -1338,7 +1304,7 @@ public class DeviceTest {
|
||||
Thread.sleep(10); // ~ 20 bytes
|
||||
if(purged) {
|
||||
if(usb.serialDriver instanceof Cp21xxSerialDriver) { // only working on some devices/ports
|
||||
if(isCp21xxRestrictedPort) {
|
||||
if(usb.isCp21xxRestrictedPort) {
|
||||
assertThat(usb.read(2), equalTo("xy".getBytes())); // cp2105/1
|
||||
} else if(usb.serialDriver.getPorts().size() > 1) {
|
||||
assertThat(usb.read(1), equalTo("y".getBytes())); // cp2105/0
|
||||
@ -1726,40 +1692,15 @@ public class DeviceTest {
|
||||
byte[] data;
|
||||
int sleep = 10;
|
||||
|
||||
// output lines are supported by all drivers
|
||||
// input lines are supported by all drivers except CDC
|
||||
boolean inputLinesSupported = false;
|
||||
boolean inputLinesConnected = false;
|
||||
boolean onlyRtsCts = false;
|
||||
if (usb.serialDriver instanceof FtdiSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
if(usb.serialDriver.getDevice().getProductId() == UsbId.FTDI_FT2232H)
|
||||
inputLinesConnected = true; // I only have 74LS138 connected at FT2232, not at FT232
|
||||
if(usb.serialDriver.getDevice().getProductId() == UsbId.FTDI_FT231X) {
|
||||
inputLinesConnected = true;
|
||||
onlyRtsCts = true; // I only test with FT230X that has only these 2 control lines. DTR is silently ignored
|
||||
}
|
||||
} else if (usb.serialDriver instanceof Cp21xxSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
if(usb.serialDriver.getPorts().size() == 1)
|
||||
inputLinesConnected = true; // I only have 74LS138 connected at CP2102, not at CP2105
|
||||
} else if (usb.serialDriver instanceof ProlificSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
inputLinesConnected = true;
|
||||
} else if (usb.serialDriver instanceof Ch34xSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
if(usb.serialDriver.getDevice().getProductId() == UsbId.QINHENG_CH340)
|
||||
inputLinesConnected = true; // I only have 74LS138 connected at CH230, not connected at CH341A
|
||||
}
|
||||
Boolean inputLineFalse = inputLinesSupported ? Boolean.FALSE : null;
|
||||
Boolean inputLineTrue = inputLinesConnected ? Boolean.TRUE : inputLineFalse;
|
||||
Boolean inputLineFalse = usb.inputLinesSupported ? Boolean.FALSE : null;
|
||||
Boolean inputLineTrue = usb.inputLinesConnected ? Boolean.TRUE : inputLineFalse;
|
||||
|
||||
EnumSet<UsbSerialPort.ControlLine> supportedControlLines = EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.DTR);
|
||||
if(inputLinesSupported) {
|
||||
supportedControlLines.add(UsbSerialPort.ControlLine.CTS);
|
||||
supportedControlLines.add(UsbSerialPort.ControlLine.DSR);
|
||||
supportedControlLines.add(UsbSerialPort.ControlLine.CD);
|
||||
supportedControlLines.add(UsbSerialPort.ControlLine.RI);
|
||||
EnumSet<ControlLine> supportedControlLines = EnumSet.of(ControlLine.RTS, ControlLine.DTR);
|
||||
if(usb.inputLinesSupported) {
|
||||
supportedControlLines.add(ControlLine.CTS);
|
||||
supportedControlLines.add(ControlLine.DSR);
|
||||
supportedControlLines.add(ControlLine.CD);
|
||||
supportedControlLines.add(ControlLine.RI);
|
||||
}
|
||||
|
||||
// UsbSerialProber creates new UsbSerialPort objects which resets control lines,
|
||||
@ -1774,16 +1715,16 @@ public class DeviceTest {
|
||||
|
||||
// control lines reset on initial open
|
||||
data = "none".getBytes();
|
||||
assertEquals(inputLinesConnected && !onlyRtsCts
|
||||
? EnumSet.of(UsbSerialPort.ControlLine.RI)
|
||||
: EnumSet.noneOf(UsbSerialPort.ControlLine.class),
|
||||
assertEquals(usb.inputLinesConnected && !usb.inputLinesOnlyRtsCts
|
||||
? EnumSet.of(ControlLine.RI)
|
||||
: EnumSet.noneOf(ControlLine.class),
|
||||
usb.serialPort.getControlLines());
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRTS), equalTo(Boolean.FALSE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCTS), equalTo(inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDTR), equalTo(Boolean.FALSE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDSR), equalTo(inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCD), equalTo(inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRI), equalTo(onlyRtsCts ? Boolean.FALSE : inputLineTrue));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRI), equalTo(usb.inputLinesOnlyRtsCts ? Boolean.FALSE : inputLineTrue));
|
||||
telnet.write(data);
|
||||
if(usb.serialDriver instanceof CdcAcmSerialDriver)
|
||||
// arduino: control line feedback as serial_state notification is not implemented.
|
||||
@ -1797,9 +1738,9 @@ public class DeviceTest {
|
||||
data = "rts ".getBytes();
|
||||
usb.serialPort.setRTS(true);
|
||||
Thread.sleep(sleep);
|
||||
assertEquals(inputLinesConnected
|
||||
? EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.CTS)
|
||||
: EnumSet.of(UsbSerialPort.ControlLine.RTS),
|
||||
assertEquals(usb.inputLinesConnected
|
||||
? EnumSet.of(ControlLine.RTS, ControlLine.CTS)
|
||||
: EnumSet.of(ControlLine.RTS),
|
||||
usb.serialPort.getControlLines());
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRTS), equalTo(Boolean.TRUE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCTS), equalTo(inputLineTrue));
|
||||
@ -1815,17 +1756,17 @@ public class DeviceTest {
|
||||
data = "both".getBytes();
|
||||
usb.serialPort.setDTR(true);
|
||||
Thread.sleep(sleep);
|
||||
assertEquals(onlyRtsCts
|
||||
? EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.DTR, UsbSerialPort.ControlLine.CTS)
|
||||
: inputLinesConnected
|
||||
? EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.DTR, UsbSerialPort.ControlLine.CD)
|
||||
: EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.DTR),
|
||||
assertEquals(usb.inputLinesOnlyRtsCts
|
||||
? EnumSet.of(ControlLine.RTS, ControlLine.DTR, ControlLine.CTS)
|
||||
: usb.inputLinesConnected
|
||||
? EnumSet.of(ControlLine.RTS, ControlLine.DTR, ControlLine.CD)
|
||||
: EnumSet.of(ControlLine.RTS, ControlLine.DTR),
|
||||
usb.serialPort.getControlLines());
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRTS), equalTo(Boolean.TRUE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCTS), equalTo(onlyRtsCts ? Boolean.TRUE : inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCTS), equalTo(usb.inputLinesOnlyRtsCts ? Boolean.TRUE : inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDTR), equalTo(Boolean.TRUE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDSR), equalTo(inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCD), equalTo(onlyRtsCts ? Boolean.FALSE : inputLineTrue));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCD), equalTo(usb.inputLinesOnlyRtsCts ? Boolean.FALSE : inputLineTrue));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRI), equalTo(inputLineFalse));
|
||||
telnet.write(data);
|
||||
assertThat(Arrays.toString(data), usb.read(4), equalTo(data));
|
||||
@ -1835,14 +1776,14 @@ public class DeviceTest {
|
||||
data = "dtr ".getBytes();
|
||||
usb.serialPort.setRTS(false);
|
||||
Thread.sleep(sleep);
|
||||
assertEquals(inputLinesConnected && !onlyRtsCts
|
||||
? EnumSet.of(UsbSerialPort.ControlLine.DTR, UsbSerialPort.ControlLine.DSR)
|
||||
: EnumSet.of(UsbSerialPort.ControlLine.DTR),
|
||||
assertEquals(usb.inputLinesConnected && !usb.inputLinesOnlyRtsCts
|
||||
? EnumSet.of(ControlLine.DTR, ControlLine.DSR)
|
||||
: EnumSet.of(ControlLine.DTR),
|
||||
usb.serialPort.getControlLines());
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRTS), equalTo(Boolean.FALSE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCTS), equalTo(inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDTR), equalTo(Boolean.TRUE));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDSR), equalTo(onlyRtsCts ? Boolean.FALSE : inputLineTrue));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getDSR), equalTo(usb.inputLinesOnlyRtsCts ? Boolean.FALSE : inputLineTrue));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCD), equalTo(inputLineFalse));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRI), equalTo(inputLineFalse));
|
||||
telnet.write(data);
|
||||
@ -1851,7 +1792,7 @@ public class DeviceTest {
|
||||
assertThat(Arrays.toString(data), telnet.read(4), equalTo(data));
|
||||
|
||||
// control lines retained over close+open
|
||||
boolean inputRetained = inputLinesConnected;
|
||||
boolean inputRetained = usb.inputLinesConnected;
|
||||
boolean outputRetained = true;
|
||||
usb.serialPort.setRTS(true);
|
||||
usb.serialPort.setDTR(false);
|
||||
@ -1859,9 +1800,9 @@ public class DeviceTest {
|
||||
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT, UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD));
|
||||
usb.setParameters(19200, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||
|
||||
EnumSet<UsbSerialPort.ControlLine> retainedControlLines = EnumSet.noneOf(UsbSerialPort.ControlLine.class);
|
||||
if(outputRetained) retainedControlLines.add(UsbSerialPort.ControlLine.RTS);
|
||||
if(inputRetained) retainedControlLines.add(UsbSerialPort.ControlLine.CTS);
|
||||
EnumSet<ControlLine> retainedControlLines = EnumSet.noneOf(ControlLine.class);
|
||||
if(outputRetained) retainedControlLines.add(ControlLine.RTS);
|
||||
if(inputRetained) retainedControlLines.add(ControlLine.CTS);
|
||||
assertEquals(retainedControlLines, usb.serialPort.getControlLines());
|
||||
assertThat(usb.getControlLine(usb.serialPort::getRTS), equalTo(outputRetained));
|
||||
assertThat(usb.getControlLine(usb.serialPort::getCTS), equalTo(inputRetained ? inputLineTrue : inputLineFalse));
|
||||
@ -1875,25 +1816,25 @@ public class DeviceTest {
|
||||
usb.serialPort.setDTR(false);
|
||||
usb.close(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT));
|
||||
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT, UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD));
|
||||
assertEquals(EnumSet.of(UsbSerialPort.ControlLine.RI), usb.serialPort.getControlLines());
|
||||
assertEquals(EnumSet.of(ControlLine.RI), usb.serialPort.getControlLines());
|
||||
|
||||
usb.serialPort.setRTS(true);
|
||||
usb.serialPort.setDTR(false);
|
||||
usb.close(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT));
|
||||
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT, UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD));
|
||||
assertEquals(EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.CTS), usb.serialPort.getControlLines());
|
||||
assertEquals(EnumSet.of(ControlLine.RTS, ControlLine.CTS), usb.serialPort.getControlLines());
|
||||
|
||||
usb.serialPort.setRTS(false);
|
||||
usb.serialPort.setDTR(true);
|
||||
usb.close(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT));
|
||||
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT, UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD));
|
||||
assertEquals(EnumSet.of(UsbSerialPort.ControlLine.DTR, UsbSerialPort.ControlLine.DSR), usb.serialPort.getControlLines());
|
||||
assertEquals(EnumSet.of(ControlLine.DTR, ControlLine.DSR), usb.serialPort.getControlLines());
|
||||
|
||||
usb.serialPort.setRTS(true);
|
||||
usb.serialPort.setDTR(true);
|
||||
usb.close(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT));
|
||||
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_CONTROL_LINE_INIT, UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD));
|
||||
assertEquals(EnumSet.of(UsbSerialPort.ControlLine.RTS, UsbSerialPort.ControlLine.DTR, UsbSerialPort.ControlLine.CD), usb.serialPort.getControlLines());
|
||||
assertEquals(EnumSet.of(ControlLine.RTS, ControlLine.DTR, ControlLine.CD), usb.serialPort.getControlLines());
|
||||
}
|
||||
|
||||
// force error
|
||||
@ -1944,7 +1885,7 @@ public class DeviceTest {
|
||||
if (usb.serialDriver instanceof CdcAcmSerialDriver) {
|
||||
// BREAK forwarding not implemented by arduino_leonardo_bridge.ino
|
||||
assertThat("<break>", data, equalTo(new byte[]{}));
|
||||
} else if(isCp21xxRestrictedPort) {
|
||||
} else if(usb.isCp21xxRestrictedPort) {
|
||||
assertThat("<break>", data, equalTo(new byte[]{0x26})); // send the last byte again?
|
||||
} else {
|
||||
assertThat("<break>", data, equalTo(new byte[]{0}));
|
||||
@ -2030,7 +1971,7 @@ public class DeviceTest {
|
||||
fail("setBreak error expected");
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
usb.close();
|
||||
usb.close(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_DEVICE_CONNECTION));
|
||||
try {
|
||||
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD, UsbWrapper.OpenCloseFlags.NO_DEVICE_CONNECTION));
|
||||
fail("open error expected");
|
||||
@ -2060,8 +2001,6 @@ public class DeviceTest {
|
||||
usb.open();
|
||||
assertTrue(usb.serialPort.isOpen());
|
||||
|
||||
assertEquals(usb.serialPort.getWriteEndpoint().getMaxPacketSize(),
|
||||
usb.serialPort.getReadEndpoint().getMaxPacketSize());
|
||||
s = usb.serialPort.getSerial();
|
||||
// with target sdk 29 can throw SecurityException before USB permission dialog is confirmed
|
||||
// not all devices implement serial numbers. some observed values are:
|
||||
@ -2110,7 +2049,7 @@ public class DeviceTest {
|
||||
long t3 = System.currentTimeMillis();
|
||||
ftdiSerialPort.setLatencyTimer(lt);
|
||||
assertTrue("latency 1: expected < 100, got "+ (t2-t1), (t2-t1) < 100);
|
||||
assertTrue("latency 100: expected > 100, got " + (t3-t2), (t3-t2) > 100);
|
||||
assertTrue("latency 100: expected >= 100, got " + (t3-t2), (t3-t2) >= 100);
|
||||
|
||||
usb.deviceConnection.close();
|
||||
try {
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.hoho.android.usbserial.driver;
|
||||
|
||||
public class CommonUsbSerialPortWrapper {
|
||||
public static byte[] getWriteBuffer(UsbSerialPort serialPort) {
|
||||
CommonUsbSerialPort commonSerialPort = (CommonUsbSerialPort) serialPort;
|
||||
return commonSerialPort.mWriteBuffer;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.hoho.android.usbserial.driver;
|
||||
|
||||
public class ProlificWrapper {
|
||||
public class ProlificSerialPortWrapper {
|
||||
public static boolean isDeviceTypeT(UsbSerialPort serialPort) {
|
||||
ProlificSerialDriver.ProlificSerialPort prolificSerialPort = (ProlificSerialDriver.ProlificSerialPort) serialPort;
|
||||
return prolificSerialPort.mDeviceType == ProlificSerialDriver.DeviceType.DEVICE_TYPE_T;
|
@ -0,0 +1,32 @@
|
||||
package com.hoho.android.usbserial.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestBuffer {
|
||||
public final byte[] buf;
|
||||
public int len;
|
||||
|
||||
public TestBuffer(int length) {
|
||||
len = 0;
|
||||
buf = new byte[length];
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
for (j = 0; j < length / 16; j++)
|
||||
for (int k = 0; k < 16; k++)
|
||||
buf[i++] = (byte) j;
|
||||
while (i < length)
|
||||
buf[i++] = (byte) j;
|
||||
}
|
||||
|
||||
public boolean testRead(byte[] data) {
|
||||
assertNotEquals(0, data.length);
|
||||
assertTrue("got " + (len + data.length) + " bytes", (len + data.length) <= buf.length);
|
||||
for (int j = 0; j < data.length; j++)
|
||||
assertEquals("at pos " + (len + j), (byte) ((len + j) / 16), data[j]);
|
||||
len += data.length;
|
||||
//Log.d(TAG, "read " + len);
|
||||
return len == buf.length;
|
||||
}
|
||||
}
|
@ -9,10 +9,16 @@ import android.hardware.usb.UsbDeviceConnection;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hoho.android.usbserial.driver.CdcAcmSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.Ch34xSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.CommonUsbSerialPort;
|
||||
import com.hoho.android.usbserial.driver.Cp21xxSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.FtdiSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.ProlificSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.UsbId;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialDriver;
|
||||
import com.hoho.android.usbserial.driver.UsbSerialPort;
|
||||
|
||||
@ -48,6 +54,13 @@ public class UsbWrapper implements SerialInputOutputManager.Listener {
|
||||
public boolean readBlock = false;
|
||||
long readTime = 0;
|
||||
|
||||
// device properties
|
||||
public boolean isCp21xxRestrictedPort; // second port of Cp2105 has limited dataBits, stopBits, parity
|
||||
public boolean inputLinesSupported;
|
||||
public boolean inputLinesConnected;
|
||||
public boolean inputLinesOnlyRtsCts;
|
||||
public int writePacketSize = -1;
|
||||
public int writeBufferSize = -1;
|
||||
|
||||
public UsbWrapper(Context context, UsbSerialDriver serialDriver, int devicePort) {
|
||||
this.context = context;
|
||||
@ -71,7 +84,8 @@ public class UsbWrapper implements SerialInputOutputManager.Listener {
|
||||
granted[0] = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
|
||||
}
|
||||
};
|
||||
PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, new Intent("com.android.example.USB_PERMISSION"), 0);
|
||||
int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0;
|
||||
PendingIntent permissionIntent = PendingIntent.getBroadcast(context, 0, new Intent("com.android.example.USB_PERMISSION"), flags);
|
||||
IntentFilter filter = new IntentFilter("com.android.example.USB_PERMISSION");
|
||||
context.registerReceiver(usbReceiver, filter);
|
||||
usbManager.requestPermission(serialDriver.getDevice(), permissionIntent);
|
||||
@ -80,8 +94,52 @@ public class UsbWrapper implements SerialInputOutputManager.Listener {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
Log.d(TAG,"USB permission "+granted[0]);
|
||||
assertTrue("USB permission dialog not confirmed", granted[0]==null?false:granted[0]);
|
||||
assertTrue("USB permission dialog not confirmed", granted[0] != null && granted[0]);
|
||||
}
|
||||
|
||||
// extract some device properties:
|
||||
isCp21xxRestrictedPort = serialDriver instanceof Cp21xxSerialDriver && serialDriver.getPorts().size()==2 && serialPort.getPortNumber() == 1;
|
||||
// output lines are supported by all drivers
|
||||
// input lines are supported by all drivers except CDC
|
||||
if (serialDriver instanceof FtdiSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
if(serialDriver.getDevice().getProductId() == UsbId.FTDI_FT2232H)
|
||||
inputLinesConnected = true; // I only have 74LS138 connected at FT2232, not at FT232
|
||||
if(serialDriver.getDevice().getProductId() == UsbId.FTDI_FT231X) {
|
||||
inputLinesConnected = true;
|
||||
inputLinesOnlyRtsCts = true; // I only test with FT230X that has only these 2 control lines. DTR is silently ignored
|
||||
}
|
||||
} else if (serialDriver instanceof Cp21xxSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
if(serialDriver.getPorts().size() == 1)
|
||||
inputLinesConnected = true; // I only have 74LS138 connected at CP2102, not at CP2105
|
||||
} else if (serialDriver instanceof ProlificSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
inputLinesConnected = true;
|
||||
} else if (serialDriver instanceof Ch34xSerialDriver) {
|
||||
inputLinesSupported = true;
|
||||
if(serialDriver.getDevice().getProductId() == UsbId.QINHENG_CH340)
|
||||
inputLinesConnected = true; // I only have 74LS138 connected at CH340, not connected at CH341A
|
||||
}
|
||||
|
||||
if (serialDriver instanceof Cp21xxSerialDriver) {
|
||||
if (serialDriver.getPorts().size() == 1) { writePacketSize = 64; writeBufferSize = 576; }
|
||||
else if (serialPort.getPortNumber() == 0) { writePacketSize = 64; writeBufferSize = 320; }
|
||||
else { writePacketSize = 32; writeBufferSize = 128; }; //, 160}; // write buffer size detection is unreliable
|
||||
} else if (serialDriver instanceof Ch34xSerialDriver) {
|
||||
writePacketSize = 32; writeBufferSize = 64;
|
||||
} else if (serialDriver instanceof ProlificSerialDriver) {
|
||||
writePacketSize = 64; writeBufferSize = 256;
|
||||
} else if (serialDriver instanceof FtdiSerialDriver) {
|
||||
switch (serialDriver.getPorts().size()) {
|
||||
case 1: writePacketSize = 64; writeBufferSize = 128; break;
|
||||
case 2: writePacketSize = 512; writeBufferSize = 4096; break;
|
||||
case 4: writePacketSize = 512; writeBufferSize = 2048; break;
|
||||
}
|
||||
} else if (serialDriver instanceof CdcAcmSerialDriver) {
|
||||
writePacketSize = 64; writeBufferSize = 128;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void tearDown() {
|
||||
@ -246,15 +304,40 @@ public class UsbWrapper implements SerialInputOutputManager.Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// return [write packet size, write buffer size(s)]
|
||||
public int[] getWriteSizes() {
|
||||
if (serialDriver instanceof Cp21xxSerialDriver) {
|
||||
if (serialDriver.getPorts().size() == 1) return new int[]{64, 576};
|
||||
else if (serialPort.getPortNumber() == 0) return new int[]{64, 320};
|
||||
else return new int[]{32, 128, 160}; // write buffer size detection is unreliable
|
||||
} else if (serialDriver instanceof Ch34xSerialDriver) {
|
||||
return new int[]{32, 64};
|
||||
} else if (serialDriver instanceof ProlificSerialDriver) {
|
||||
return new int[]{64, 256};
|
||||
} else if (serialDriver instanceof FtdiSerialDriver) {
|
||||
switch (serialDriver.getPorts().size()) {
|
||||
case 1: return new int[]{64, 128};
|
||||
case 2: return new int[]{512, 4096};
|
||||
case 4: return new int[]{512, 2048};
|
||||
default: return null;
|
||||
}
|
||||
} else if (serialDriver instanceof CdcAcmSerialDriver) {
|
||||
return new int[]{64, 128};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNewData(byte[] data) {
|
||||
long now = System.currentTimeMillis();
|
||||
if(readTime == 0)
|
||||
readTime = now;
|
||||
if(data.length > 64) {
|
||||
Log.d(TAG, "usb read: time+=" + String.format("%-3d",now- readTime) + " len=" + String.format("%-4d",data.length) + " data=" + new String(data, 0, 32) + "..." + new String(data, data.length-32, 32));
|
||||
Log.d(TAG, "usb " + devicePort + " read: time+=" + String.format("%-3d",now- readTime) + " len=" + String.format("%-4d",data.length) + " data=" + new String(data, 0, 32) + "..." + new String(data, data.length-32, 32));
|
||||
} else {
|
||||
Log.d(TAG, "usb read: time+=" + String.format("%-3d",now- readTime) + " len=" + String.format("%-4d",data.length) + " data=" + new String(data));
|
||||
Log.d(TAG, "usb " + devicePort + " read: time+=" + String.format("%-3d",now- readTime) + " len=" + String.format("%-4d",data.length) + " data=" + new String(data));
|
||||
}
|
||||
readTime = now;
|
||||
|
||||
|
@ -303,24 +303,33 @@ public class CdcAcmSerialDriver implements UsbSerialDriver {
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_VAN_OOIJEN_TECH,
|
||||
new int[] {
|
||||
UsbId.VAN_OOIJEN_TECH_TEENSYDUINO_SERIAL,
|
||||
UsbId.VAN_OOIJEN_TECH_TEENSYDUINO_SERIAL,
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_ATMEL,
|
||||
new int[] {
|
||||
UsbId.ATMEL_LUFA_CDC_DEMO_APP,
|
||||
UsbId.ATMEL_LUFA_CDC_DEMO_APP,
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_LEAFLABS,
|
||||
new int[] {
|
||||
UsbId.LEAFLABS_MAPLE,
|
||||
UsbId.LEAFLABS_MAPLE,
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_ARM,
|
||||
new int[] {
|
||||
UsbId.ARM_MBED,
|
||||
UsbId.ARM_MBED,
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_ST,
|
||||
new int[] {
|
||||
UsbId.ST_CDC,
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_RASPBERRY_PI,
|
||||
new int[] {
|
||||
UsbId.RASPBERRY_PI_PICO_MICROPYTHON,
|
||||
UsbId.RASPBERRY_PI_PICO_SDK,
|
||||
});
|
||||
supportedDevices.put(UsbId.VENDOR_QINHENG,
|
||||
new int[] {
|
||||
UsbId.QINHENG_CH9102F,
|
||||
});
|
||||
return supportedDevices;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
||||
public static boolean DEBUG = false;
|
||||
|
||||
private static final String TAG = CommonUsbSerialPort.class.getSimpleName();
|
||||
private static final int DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024;
|
||||
private static final int MAX_READ_SIZE = 16 * 1024; // = old bulkTransfer limit
|
||||
|
||||
protected final UsbDevice mDevice;
|
||||
@ -40,15 +39,18 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
||||
protected UsbEndpoint mWriteEndpoint;
|
||||
protected UsbRequest mUsbRequest;
|
||||
|
||||
protected final Object mWriteBufferLock = new Object();
|
||||
/** Internal write buffer. Guarded by {@link #mWriteBufferLock}. */
|
||||
/**
|
||||
* Internal write buffer.
|
||||
* Guarded by {@link #mWriteBufferLock}.
|
||||
* Default length = mReadEndpoint.getMaxPacketSize()
|
||||
**/
|
||||
protected byte[] mWriteBuffer;
|
||||
protected final Object mWriteBufferLock = new Object();
|
||||
|
||||
|
||||
public CommonUsbSerialPort(UsbDevice device, int portNumber) {
|
||||
mDevice = device;
|
||||
mPortNumber = portNumber;
|
||||
|
||||
mWriteBuffer = new byte[DEFAULT_WRITE_BUFFER_SIZE];
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,11 +89,19 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
||||
* Sets the size of the internal buffer used to exchange data with the USB
|
||||
* stack for write operations. Most users should not need to change this.
|
||||
*
|
||||
* @param bufferSize the size in bytes
|
||||
* @param bufferSize the size in bytes, <= 0 resets original size
|
||||
*/
|
||||
public final void setWriteBufferSize(int bufferSize) {
|
||||
synchronized (mWriteBufferLock) {
|
||||
if (bufferSize == mWriteBuffer.length) {
|
||||
if (bufferSize <= 0) {
|
||||
if (mWriteEndpoint != null) {
|
||||
bufferSize = mWriteEndpoint.getMaxPacketSize();
|
||||
} else {
|
||||
mWriteBuffer = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mWriteBuffer != null && bufferSize == mWriteBuffer.length) {
|
||||
return;
|
||||
}
|
||||
mWriteBuffer = new byte[bufferSize];
|
||||
@ -219,6 +229,9 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
||||
synchronized (mWriteBufferLock) {
|
||||
final byte[] writeBuffer;
|
||||
|
||||
if (mWriteBuffer == null) {
|
||||
mWriteBuffer = new byte[mWriteEndpoint.getMaxPacketSize()];
|
||||
}
|
||||
requestLength = Math.min(src.length - offset, mWriteBuffer.length);
|
||||
if (offset == 0) {
|
||||
writeBuffer = src;
|
||||
|
@ -35,7 +35,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
||||
28800, 38400, 57600, 115200, 128000, 134400, 161280, 201600, 230400, 268800,
|
||||
403200, 460800, 614400, 806400, 921600, 1228800, 2457600, 3000000, 6000000
|
||||
};
|
||||
protected enum DeviceType { DEVICE_TYPE_01, DEVICE_TYPE_T, DEVICE_TYPE_HX, DEVICE_TYPE_HXN}
|
||||
protected enum DeviceType { DEVICE_TYPE_01, DEVICE_TYPE_T, DEVICE_TYPE_HX, DEVICE_TYPE_HXN }
|
||||
|
||||
private final UsbDevice mDevice;
|
||||
private final UsbSerialPort mPort;
|
||||
@ -139,7 +139,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
||||
byte[] buffer = new byte[length];
|
||||
int result = mConnection.controlTransfer(requestType, request, value, index, buffer, length, USB_READ_TIMEOUT_MILLIS);
|
||||
if (result != length) {
|
||||
throw new IOException(String.format("ControlTransfer 0x%x failed: %d",value, result));
|
||||
throw new IOException(String.format("ControlTransfer %s 0x%x failed: %d",mDeviceType.name(), value, result));
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
@ -148,7 +148,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
||||
int length = (data == null) ? 0 : data.length;
|
||||
int result = mConnection.controlTransfer(requestType, request, value, index, data, length, USB_WRITE_TIMEOUT_MILLIS);
|
||||
if (result != length) {
|
||||
throw new IOException( String.format("ControlTransfer 0x%x failed: %d", value, result));
|
||||
throw new IOException( String.format("ControlTransfer %s 0x%x failed: %d", mDeviceType.name(), value, result));
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,15 +299,19 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
||||
byte maxPacketSize0 = rawDescriptors[7];
|
||||
if (mDevice.getDeviceClass() == 0x02 || maxPacketSize0 != 64) {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_01;
|
||||
} else if(deviceVersion == 0x300 && usbVersion == 0x200) {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_T; // TA
|
||||
} else if(deviceVersion == 0x500) {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_T; // TB
|
||||
} else if(usbVersion == 0x200 && !testHxStatus()) {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_HXN;
|
||||
} else if(usbVersion == 0x200) {
|
||||
if(deviceVersion == 0x300 && testHxStatus()) {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_T; // TA
|
||||
} else if(deviceVersion == 0x500 && testHxStatus()) {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_T; // TB
|
||||
} else {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_HXN;
|
||||
}
|
||||
} else {
|
||||
mDeviceType = DeviceType.DEVICE_TYPE_HX;
|
||||
}
|
||||
Log.d(TAG, String.format("usbVersion=%x, deviceVersion=%x, deviceClass=%d, packetSize=%d => deviceType=%s",
|
||||
usbVersion, deviceVersion, mDevice.getDeviceClass(), maxPacketSize0, mDeviceType.name()));
|
||||
resetDevice();
|
||||
doBlackMagic();
|
||||
setControlLines(mControlLinesValue);
|
||||
|
@ -61,6 +61,7 @@ public final class UsbId {
|
||||
public static final int VENDOR_QINHENG = 0x1a86;
|
||||
public static final int QINHENG_CH340 = 0x7523;
|
||||
public static final int QINHENG_CH341A = 0x5523;
|
||||
public static final int QINHENG_CH9102F = 0x55D4;
|
||||
|
||||
// at www.linux-usb.org/usb.ids listed for NXP/LPC1768, but all processors supported by ARM mbed DAPLink firmware report these ids
|
||||
public static final int VENDOR_ARM = 0x0d28;
|
||||
@ -69,6 +70,10 @@ public final class UsbId {
|
||||
public static final int VENDOR_ST = 0x0483;
|
||||
public static final int ST_CDC = 0x5740;
|
||||
|
||||
public static final int VENDOR_RASPBERRY_PI = 0x2e8a;
|
||||
public static final int RASPBERRY_PI_PICO_MICROPYTHON = 0x0005;
|
||||
public static final int RASPBERRY_PI_PICO_SDK = 0x000a;
|
||||
|
||||
private UsbId() {
|
||||
throw new IllegalAccessError("Non-instantiable class");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user