kopia lustrzana https://github.com/felHR85/UsbSerial
Merge branch 'master' of https://github.com/felHR85/UsbSerial
commit
35cb3ea98e
|
@ -1,9 +1,11 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
google()
|
||||||
|
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.2.0'
|
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ apply plugin: 'com.android.application'
|
||||||
android {
|
android {
|
||||||
|
|
||||||
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
||||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.felhr.serialportexample"
|
applicationId "com.felhr.serialportexample"
|
||||||
|
@ -21,9 +20,9 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:support-v4:23.1.1'
|
implementation 'com.android.support:support-v4:23.1.1'
|
||||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
implementation 'com.android.support:appcompat-v7:23.1.1'
|
||||||
compile 'com.android.support:design:23.1.1'
|
implementation 'com.android.support:design:23.1.1'
|
||||||
|
|
||||||
compile project(':usbserial')
|
implementation project(':usbserial')
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ public class UsbService extends Service {
|
||||||
int deviceVID = device.getVendorId();
|
int deviceVID = device.getVendorId();
|
||||||
int devicePID = device.getProductId();
|
int devicePID = device.getProductId();
|
||||||
|
|
||||||
if (deviceVID != 0x1d6b && (devicePID != 0x0001 && devicePID != 0x0002 && devicePID != 0x0003)) {
|
if (deviceVID != 0x1d6b && (devicePID != 0x0001 && devicePID != 0x0002 && devicePID != 0x0003) && deviceVID != 0x5c6 && devicePID != 0x904c) {
|
||||||
|
|
||||||
// There is a device connected to our Android device. Try to open it as a Serial Port.
|
// There is a device connected to our Android device. Try to open it as a Serial Port.
|
||||||
requestUserPermission();
|
requestUserPermission();
|
||||||
keep = false;
|
keep = false;
|
||||||
|
|
|
@ -3,7 +3,6 @@ apply plugin: 'com.android.application'
|
||||||
android {
|
android {
|
||||||
|
|
||||||
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
||||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.felhr.serialportexamplesync"
|
applicationId "com.felhr.serialportexamplesync"
|
||||||
|
@ -21,9 +20,9 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:support-v4:23.1.1'
|
implementation 'com.android.support:support-v4:23.1.1'
|
||||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
implementation 'com.android.support:appcompat-v7:23.1.1'
|
||||||
compile 'com.android.support:design:23.1.1'
|
implementation 'com.android.support:design:23.1.1'
|
||||||
|
|
||||||
compile project(':usbserial')
|
implementation project(':usbserial')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
VERSION_NAME=1.0
|
VERSION_NAME=1.0
|
||||||
VERSION_CODE=1
|
VERSION_CODE=1
|
||||||
|
|
||||||
ANDROID_BUILD_MIN_SDK_VERSION=12
|
ANDROID_BUILD_MIN_SDK_VERSION=12
|
||||||
ANDROID_BUILD_TARGET_SDK_VERSION=23
|
ANDROID_BUILD_TARGET_SDK_VERSION=27
|
||||||
ANDROID_BUILD_SDK_VERSION=23
|
ANDROID_BUILD_SDK_VERSION=27
|
||||||
ANDROID_BUILD_TOOLS_VERSION=23.0.2
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||||
|
|
|
@ -6,7 +6,6 @@ android {
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
|
|
||||||
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
|
||||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
|
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
encoding "UTF-8"
|
encoding "UTF-8"
|
||||||
|
@ -20,12 +19,12 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GroovyAssignabilityCheck
|
//noinspection GroovyAssignabilityCheck
|
||||||
task deleteJar(type: org.gradle.api.tasks.Delete){
|
task deleteJar(type: org.gradle.api.tasks.Delete) {
|
||||||
delete 'eclipse_lib/usbserial.jar'
|
delete 'eclipse_lib/usbserial.jar'
|
||||||
}
|
}
|
||||||
|
|
||||||
//noinspection GroovyAssignabilityCheck
|
//noinspection GroovyAssignabilityCheck
|
||||||
task createJar(type: org.gradle.api.tasks.Copy){
|
task createJar(type: org.gradle.api.tasks.Copy) {
|
||||||
from('build/intermediates/bundles/release/')
|
from('build/intermediates/bundles/release/')
|
||||||
into('eclipse_lib/')
|
into('eclipse_lib/')
|
||||||
include('classes.jar')
|
include('classes.jar')
|
||||||
|
|
|
@ -555,6 +555,7 @@ public class FTDISioIds
|
||||||
new ConcreteDevice(0x05d1, 0x9006),
|
new ConcreteDevice(0x05d1, 0x9006),
|
||||||
new ConcreteDevice(0x05d1, 0x9007),
|
new ConcreteDevice(0x05d1, 0x9007),
|
||||||
new ConcreteDevice(0x05d1, 0x9008),
|
new ConcreteDevice(0x05d1, 0x9008),
|
||||||
|
new ConcreteDevice(0x0403, 0x0), //fake FTDI reprogrammed by driver
|
||||||
};
|
};
|
||||||
|
|
||||||
public static boolean isDeviceSupported(int vendorId, int productId)
|
public static boolean isDeviceSupported(int vendorId, int productId)
|
||||||
|
|
|
@ -11,7 +11,8 @@ public class XdcVcpIds
|
||||||
private static final ConcreteDevice[] xdcvcpDevices = new ConcreteDevice[]
|
private static final ConcreteDevice[] xdcvcpDevices = new ConcreteDevice[]
|
||||||
{
|
{
|
||||||
new ConcreteDevice(0x264D, 0x0232), // VCP (Virtual Com Port)
|
new ConcreteDevice(0x264D, 0x0232), // VCP (Virtual Com Port)
|
||||||
new ConcreteDevice(0x264D, 0x0120) // USI (Universal Sensor Interface)
|
new ConcreteDevice(0x264D, 0x0120), // USI (Universal Sensor Interface)
|
||||||
|
new ConcreteDevice(0x0483, 0x5740) //CC3D (STM)
|
||||||
};
|
};
|
||||||
|
|
||||||
public static boolean isDeviceSupported(int vendorId, int productId)
|
public static boolean isDeviceSupported(int vendorId, int productId)
|
||||||
|
|
|
@ -118,6 +118,7 @@ public class SerialBuffer
|
||||||
|
|
||||||
public synchronized void put(byte[] src)
|
public synchronized void put(byte[] src)
|
||||||
{
|
{
|
||||||
|
if(src == null || src.length == 0) return;
|
||||||
if(position == -1)
|
if(position == -1)
|
||||||
position = 0;
|
position = 0;
|
||||||
if(debugging)
|
if(debugging)
|
||||||
|
@ -148,6 +149,7 @@ public class SerialBuffer
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(position <= -1 ) return new byte[0];
|
||||||
byte[] dst = Arrays.copyOfRange(buffer, 0, position);
|
byte[] dst = Arrays.copyOfRange(buffer, 0, position);
|
||||||
if(debugging)
|
if(debugging)
|
||||||
UsbSerialDebugger.printLogGet(dst, true);
|
UsbSerialDebugger.printLogGet(dst, true);
|
||||||
|
|
|
@ -304,7 +304,8 @@ public abstract class UsbSerialDevice implements UsbSerialInterface
|
||||||
while(working.get())
|
while(working.get())
|
||||||
{
|
{
|
||||||
byte[] data = serialBuffer.getWriteBuffer();
|
byte[] data = serialBuffer.getWriteBuffer();
|
||||||
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
if(data.length > 0)
|
||||||
|
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,8 @@ public abstract class UsbSpiDevice implements UsbSpiInterface
|
||||||
while(working.get())
|
while(working.get())
|
||||||
{
|
{
|
||||||
byte[] data = serialBuffer.getWriteBuffer();
|
byte[] data = serialBuffer.getWriteBuffer();
|
||||||
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
if(data.length > 0)
|
||||||
|
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue