1
0
mirror of https://github.com/mik3y/usb-serial-for-android synced 2025-06-07 07:56:20 +00:00

Added error management inside read function to get more appropriate exception (#529)

This commit is contained in:
ExPl0siF 2023-08-24 18:49:29 +02:00 committed by GitHub
parent 54ff9bfa44
commit 399d3c9c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,7 +170,7 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
} }
protected int read(final byte[] dest, final int timeout, boolean testConnection) throws IOException { protected int read(final byte[] dest, final int timeout, boolean testConnection) throws IOException {
if(mConnection == null) { if(mConnection == null || mUsbRequest == null) {
throw new IOException("Connection closed"); throw new IOException("Connection closed");
} }
if(dest.length <= 0) { if(dest.length <= 0) {