Commit 6243dbac authored by Don Gagne's avatar Don Gagne

parent 6580a544
...@@ -41,8 +41,8 @@ public class CdcAcmSerialDriver extends CommonUsbSerialDriver { ...@@ -41,8 +41,8 @@ public class CdcAcmSerialDriver extends CommonUsbSerialDriver {
private static final int SET_CONTROL_LINE_STATE = 0x22; private static final int SET_CONTROL_LINE_STATE = 0x22;
private static final int SEND_BREAK = 0x23; private static final int SEND_BREAK = 0x23;
public CdcAcmSerialDriver(UsbDevice device, UsbDeviceConnection connection) { public CdcAcmSerialDriver(UsbDevice device) {
super(device, connection); super(device);
} }
@Override @Override
......
...@@ -36,25 +36,41 @@ abstract class CommonUsbSerialDriver implements UsbSerialDriver { ...@@ -36,25 +36,41 @@ abstract class CommonUsbSerialDriver implements UsbSerialDriver {
public static final int DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024; public static final int DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024;
protected final UsbDevice mDevice; protected final UsbDevice mDevice;
protected final UsbDeviceConnection mConnection;
protected final Object mReadBufferLock = new Object(); protected final Object mReadBufferLock = new Object();
protected final Object mWriteBufferLock = new Object(); protected final Object mWriteBufferLock = new Object();
protected UsbDeviceConnection mConnection = null;
private int _permissionStatus = permissionStatusRequestRequired;
/** Internal read buffer. Guarded by {@link #mReadBufferLock}. */ /** Internal read buffer. Guarded by {@link #mReadBufferLock}. */
protected byte[] mReadBuffer; protected byte[] mReadBuffer;
/** Internal write buffer. Guarded by {@link #mWriteBufferLock}. */ /** Internal write buffer. Guarded by {@link #mWriteBufferLock}. */
protected byte[] mWriteBuffer; protected byte[] mWriteBuffer;
public CommonUsbSerialDriver(UsbDevice device, UsbDeviceConnection connection) { public CommonUsbSerialDriver(UsbDevice device) {
mDevice = device; mDevice = device;
mConnection = connection;
mReadBuffer = new byte[DEFAULT_READ_BUFFER_SIZE]; mReadBuffer = new byte[DEFAULT_READ_BUFFER_SIZE];
mWriteBuffer = new byte[DEFAULT_WRITE_BUFFER_SIZE]; mWriteBuffer = new byte[DEFAULT_WRITE_BUFFER_SIZE];
} }
@Override
public void setConnection(UsbDeviceConnection connection) {
mConnection = connection;
}
@Override
public int permissionStatus() {
return _permissionStatus;
}
@Override
public void setPermissionStatus(int permissionStatus) {
_permissionStatus = permissionStatus;
}
/** /**
* Returns the currently-bound USB device. * Returns the currently-bound USB device.
* *
......
...@@ -61,8 +61,8 @@ public class Cp2102SerialDriver extends CommonUsbSerialDriver { ...@@ -61,8 +61,8 @@ public class Cp2102SerialDriver extends CommonUsbSerialDriver {
private UsbEndpoint mReadEndpoint; private UsbEndpoint mReadEndpoint;
private UsbEndpoint mWriteEndpoint; private UsbEndpoint mWriteEndpoint;
public Cp2102SerialDriver(UsbDevice device, UsbDeviceConnection connection) { public Cp2102SerialDriver(UsbDevice device) {
super(device, connection); super(device);
} }
private int setConfigSingle(int request, int value) { private int setConfigSingle(int request, int value) {
......
...@@ -211,8 +211,8 @@ public class FtdiSerialDriver extends CommonUsbSerialDriver { ...@@ -211,8 +211,8 @@ public class FtdiSerialDriver extends CommonUsbSerialDriver {
* @throws UsbSerialRuntimeException if the given device is incompatible * @throws UsbSerialRuntimeException if the given device is incompatible
* with this driver * with this driver
*/ */
public FtdiSerialDriver(UsbDevice usbDevice, UsbDeviceConnection usbConnection) { public FtdiSerialDriver(UsbDevice usbDevice) {
super(usbDevice, usbConnection); super(usbDevice);
mType = null; mType = null;
} }
......
...@@ -231,8 +231,8 @@ public class ProlificSerialDriver extends CommonUsbSerialDriver { ...@@ -231,8 +231,8 @@ public class ProlificSerialDriver extends CommonUsbSerialDriver {
return ((getStatus() & flag) == flag); return ((getStatus() & flag) == flag);
} }
public ProlificSerialDriver(UsbDevice device, UsbDeviceConnection connection) { public ProlificSerialDriver(UsbDevice device) {
super(device, connection); super(device);
} }
@Override @Override
......
...@@ -83,6 +83,16 @@ public interface UsbSerialDriver { ...@@ -83,6 +83,16 @@ public interface UsbSerialDriver {
/** 2 stop bits. */ /** 2 stop bits. */
public static final int STOPBITS_2 = 2; public static final int STOPBITS_2 = 2;
public static final int permissionStatusSuccess = 0;
public static final int permissionStatusDenied = 1;
public static final int permissionStatusRequested = 2;
public static final int permissionStatusRequestRequired = 3;
public static final int permissionStatusOpen = 4;
public int permissionStatus();
public void setPermissionStatus(int permissionStatus);
public void setConnection(UsbDeviceConnection connection);
/** /**
* Returns the currently-bound USB device. * Returns the currently-bound USB device.
* *
......
...@@ -65,11 +65,7 @@ public enum UsbSerialProber { ...@@ -65,11 +65,7 @@ public enum UsbSerialProber {
if (!testIfSupported(usbDevice, FtdiSerialDriver.getSupportedDevices())) { if (!testIfSupported(usbDevice, FtdiSerialDriver.getSupportedDevices())) {
return Collections.emptyList(); return Collections.emptyList();
} }
final UsbDeviceConnection connection = manager.openDevice(usbDevice); final UsbSerialDriver driver = new FtdiSerialDriver(usbDevice);
if (connection == null) {
return Collections.emptyList();
}
final UsbSerialDriver driver = new FtdiSerialDriver(usbDevice, connection);
return Collections.singletonList(driver); return Collections.singletonList(driver);
} }
}, },
...@@ -80,11 +76,7 @@ public enum UsbSerialProber { ...@@ -80,11 +76,7 @@ public enum UsbSerialProber {
if (!testIfSupported(usbDevice, CdcAcmSerialDriver.getSupportedDevices())) { if (!testIfSupported(usbDevice, CdcAcmSerialDriver.getSupportedDevices())) {
return Collections.emptyList(); return Collections.emptyList();
} }
final UsbDeviceConnection connection = manager.openDevice(usbDevice); final UsbSerialDriver driver = new CdcAcmSerialDriver(usbDevice);
if (connection == null) {
return Collections.emptyList();
}
final UsbSerialDriver driver = new CdcAcmSerialDriver(usbDevice, connection);
return Collections.singletonList(driver); return Collections.singletonList(driver);
} }
}, },
...@@ -95,11 +87,7 @@ public enum UsbSerialProber { ...@@ -95,11 +87,7 @@ public enum UsbSerialProber {
if (!testIfSupported(usbDevice, Cp2102SerialDriver.getSupportedDevices())) { if (!testIfSupported(usbDevice, Cp2102SerialDriver.getSupportedDevices())) {
return Collections.emptyList(); return Collections.emptyList();
} }
final UsbDeviceConnection connection = manager.openDevice(usbDevice); final UsbSerialDriver driver = new Cp2102SerialDriver(usbDevice);
if (connection == null) {
return Collections.emptyList();
}
final UsbSerialDriver driver = new Cp2102SerialDriver(usbDevice, connection);
return Collections.singletonList(driver); return Collections.singletonList(driver);
} }
}, },
...@@ -110,11 +98,7 @@ public enum UsbSerialProber { ...@@ -110,11 +98,7 @@ public enum UsbSerialProber {
if (!testIfSupported(usbDevice, ProlificSerialDriver.getSupportedDevices())) { if (!testIfSupported(usbDevice, ProlificSerialDriver.getSupportedDevices())) {
return Collections.emptyList(); return Collections.emptyList();
} }
final UsbDeviceConnection connection = manager.openDevice(usbDevice); final UsbSerialDriver driver = new ProlificSerialDriver(usbDevice);
if (connection == null) {
return Collections.emptyList();
}
final UsbSerialDriver driver = new ProlificSerialDriver(usbDevice, connection);
return Collections.singletonList(driver); return Collections.singletonList(driver);
} }
}; };
......
...@@ -197,7 +197,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode) ...@@ -197,7 +197,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
if (deviceId == BAD_PORT) if (deviceId == BAD_PORT)
{ {
qWarning() << "Error opening %s" << systemLocation.toLatin1().data(); qWarning() << "Error opening" << systemLocation.toLatin1().data();
q_ptr->setError(QSerialPort::DeviceNotFoundError); q_ptr->setError(QSerialPort::DeviceNotFoundError);
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment