mirror of
https://github.com/mik3y/usb-serial-for-android.git
synced 2026-08-11 08:22:52 +00:00
fix typos
This commit is contained in:
+1
-1
@@ -125,7 +125,7 @@ public class TerminalFragment extends Fragment implements SerialInputOutputManag
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_terminal, container, false);
|
View view = inflater.inflate(R.layout.fragment_terminal, container, false);
|
||||||
receiveText = view.findViewById(R.id.receive_text); // TextView performance decreases with number of spans
|
receiveText = view.findViewById(R.id.receive_text); // TextView performance decreases with number of spans
|
||||||
receiveText.setTextColor(getResources().getColor(R.color.colorRecieveText)); // set as default color to reduce number of spans
|
receiveText.setTextColor(getResources().getColor(R.color.colorReceiveText)); // set as default color to reduce number of spans
|
||||||
receiveText.setMovementMethod(ScrollingMovementMethod.getInstance());
|
receiveText.setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||||
TextView sendText = view.findViewById(R.id.send_text);
|
TextView sendText = view.findViewById(R.id.send_text);
|
||||||
View sendBtn = view.findViewById(R.id.send_btn);
|
View sendBtn = view.findViewById(R.id.send_btn);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<color name="colorPrimaryDark">#61671B</color>
|
<color name="colorPrimaryDark">#61671B</color>
|
||||||
<color name="colorAccent">#D8E33B</color>
|
<color name="colorAccent">#D8E33B</color>
|
||||||
|
|
||||||
<color name="colorRecieveText">#00FF00</color>
|
<color name="colorReceiveText">#00FF00</color>
|
||||||
<color name="colorSendText">#82CAFF</color>
|
<color name="colorSendText">#82CAFF</color>
|
||||||
<color name="colorStatusText">#FFDB58</color>
|
<color name="colorStatusText">#FFDB58</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -372,18 +372,18 @@ public class DeviceTest {
|
|||||||
int minBaudRate = ProlificSerialPortWrapper.isDeviceTypeT(usb.serialPort) ? 6 : 46;
|
int minBaudRate = ProlificSerialPortWrapper.isDeviceTypeT(usb.serialPort) ? 6 : 46;
|
||||||
try {
|
try {
|
||||||
usb.setParameters(minBaudRate-1, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(minBaudRate-1, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
fail("baud rate to low expected");
|
fail("baud rate too low expected");
|
||||||
} catch(UnsupportedOperationException ignored) {}
|
} catch(UnsupportedOperationException ignored) {}
|
||||||
usb.setParameters(minBaudRate, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(minBaudRate, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
usb.setParameters(384_000_000, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(384_000_000, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
try {
|
try {
|
||||||
usb.setParameters(384_000_001, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(384_000_001, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
fail("baud rate to high expected");
|
fail("baud rate too high expected");
|
||||||
} catch(UnsupportedOperationException ignored) {}
|
} catch(UnsupportedOperationException ignored) {}
|
||||||
usb.setParameters(11_636_363, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(11_636_363, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
try {
|
try {
|
||||||
usb.setParameters(11_636_364, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(11_636_364, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
fail("baud rate deviation to high expected");
|
fail("baud rate deviation too high expected");
|
||||||
} catch(UnsupportedOperationException ignored) {}
|
} catch(UnsupportedOperationException ignored) {}
|
||||||
|
|
||||||
for(int baudRate : baudRates) {
|
for(int baudRate : baudRates) {
|
||||||
@@ -428,7 +428,7 @@ public class DeviceTest {
|
|||||||
usb.open();
|
usb.open();
|
||||||
try {
|
try {
|
||||||
usb.setParameters(183, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(183, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
fail("baud rate to low expected");
|
fail("baud rate too low expected");
|
||||||
} catch (UnsupportedOperationException ignored) {
|
} catch (UnsupportedOperationException ignored) {
|
||||||
}
|
}
|
||||||
usb.setParameters(184, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(184, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
@@ -459,7 +459,7 @@ public class DeviceTest {
|
|||||||
usb.setParameters(3000000, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(3000000, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
try {
|
try {
|
||||||
usb.setParameters(4000000, 8, 1, UsbSerialPort.PARITY_NONE);
|
usb.setParameters(4000000, 8, 1, UsbSerialPort.PARITY_NONE);
|
||||||
fail("baud rate to high expected");
|
fail("baud rate too high expected");
|
||||||
} catch (UnsupportedOperationException ignored) {
|
} catch (UnsupportedOperationException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -914,7 +914,7 @@ public class DeviceTest {
|
|||||||
public void writeTimeout() throws Exception {
|
public void writeTimeout() throws Exception {
|
||||||
// serial processing to slow for tests below, but they anyway only check shared code in CommonUsbSerialPort
|
// serial processing to slow for tests below, but they anyway only check shared code in CommonUsbSerialPort
|
||||||
Assume.assumeFalse(usb.serialDriver instanceof CdcAcmSerialDriver);
|
Assume.assumeFalse(usb.serialDriver instanceof CdcAcmSerialDriver);
|
||||||
// write buffer size detection unreliable as baud rate to high
|
// write buffer size detection unreliable as baud rate too high
|
||||||
Assume.assumeFalse(usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() > 1);
|
Assume.assumeFalse(usb.serialDriver instanceof Cp21xxSerialDriver && usb.serialDriver.getPorts().size() > 1);
|
||||||
|
|
||||||
usb.open();
|
usb.open();
|
||||||
@@ -2513,12 +2513,12 @@ public class DeviceTest {
|
|||||||
try {
|
try {
|
||||||
byte[] buffer = new byte[0];
|
byte[] buffer = new byte[0];
|
||||||
usb.serialPort.read(buffer, UsbWrapper.USB_READ_WAIT);
|
usb.serialPort.read(buffer, UsbWrapper.USB_READ_WAIT);
|
||||||
fail("read buffer to small expected");
|
fail("read buffer too small expected");
|
||||||
} catch(IllegalArgumentException ignored) {}
|
} catch(IllegalArgumentException ignored) {}
|
||||||
try {
|
try {
|
||||||
byte[] buffer = new byte[1];
|
byte[] buffer = new byte[1];
|
||||||
usb.serialPort.read(buffer, 0, UsbWrapper.USB_READ_WAIT);
|
usb.serialPort.read(buffer, 0, UsbWrapper.USB_READ_WAIT);
|
||||||
fail("read length to small expected");
|
fail("read length too small expected");
|
||||||
} catch(IllegalArgumentException ignored) {}
|
} catch(IllegalArgumentException ignored) {}
|
||||||
|
|
||||||
// use driver that does not override base class
|
// use driver that does not override base class
|
||||||
|
|||||||
+3
-3
@@ -276,7 +276,7 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
|||||||
int readMax = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) ? length : Math.min(length, MAX_READ_SIZE);
|
int readMax = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) ? length : Math.min(length, MAX_READ_SIZE);
|
||||||
nread = mConnection.bulkTransfer(mReadEndpoint, dest, readMax, timeout);
|
nread = mConnection.bulkTransfer(mReadEndpoint, dest, readMax, timeout);
|
||||||
// Android error propagation is improvable:
|
// Android error propagation is improvable:
|
||||||
// nread == -1 can be: timeout, connection lost, buffer to small, ???
|
// nread == -1 can be: timeout, connection lost, buffer too small, ???
|
||||||
if(nread == -1 && testConnection)
|
if(nread == -1 && testConnection)
|
||||||
testConnection(MonotonicClock.millis() < endTime);
|
testConnection(MonotonicClock.millis() < endTime);
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
|||||||
}
|
}
|
||||||
nread = Objects.requireNonNull(buf).position();
|
nread = Objects.requireNonNull(buf).position();
|
||||||
// Android error propagation is improvable:
|
// Android error propagation is improvable:
|
||||||
// response != null & nread == 0 can be: connection lost, buffer to small, ???
|
// response != null & nread == 0 can be: connection lost, buffer too small, ???
|
||||||
if(nread == 0) {
|
if(nread == 0) {
|
||||||
testConnection(true);
|
testConnection(true);
|
||||||
}
|
}
|
||||||
@@ -364,7 +364,7 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
|||||||
if (actualLength <= 0) {
|
if (actualLength <= 0) {
|
||||||
String msg = "Error writing " + requestLength + " bytes at offset " + offset + " of total " + src.length + " after " + elapsed + "msec, rc=" + actualLength;
|
String msg = "Error writing " + requestLength + " bytes at offset " + offset + " of total " + src.length + " after " + elapsed + "msec, rc=" + actualLength;
|
||||||
if (timeout != 0) {
|
if (timeout != 0) {
|
||||||
// could be buffer full because: writing to fast, stopped by flow control
|
// could be buffer full because: writing too fast, stopped by flow control
|
||||||
testConnection(elapsed < timeout, msg);
|
testConnection(elapsed < timeout, msg);
|
||||||
throw new SerialTimeoutException(msg, offset);
|
throw new SerialTimeoutException(msg, offset);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-3
@@ -194,7 +194,7 @@ public class FtdiSerialDriver implements UsbSerialDriver {
|
|||||||
private void setBaudrate(int baudRate) throws IOException {
|
private void setBaudrate(int baudRate) throws IOException {
|
||||||
int divisor, subdivisor, effectiveBaudRate;
|
int divisor, subdivisor, effectiveBaudRate;
|
||||||
if (baudRate > 3500000) {
|
if (baudRate > 3500000) {
|
||||||
throw new UnsupportedOperationException("Baud rate to high");
|
throw new UnsupportedOperationException("Baud rate too high");
|
||||||
} else if(baudRate >= 2500000) {
|
} else if(baudRate >= 2500000) {
|
||||||
divisor = 0;
|
divisor = 0;
|
||||||
subdivisor = 0;
|
subdivisor = 0;
|
||||||
@@ -209,7 +209,7 @@ public class FtdiSerialDriver implements UsbSerialDriver {
|
|||||||
subdivisor = divisor & 0x07;
|
subdivisor = divisor & 0x07;
|
||||||
divisor >>= 3;
|
divisor >>= 3;
|
||||||
if (divisor > 0x3fff) // exceeds bit 13 at 183 baud
|
if (divisor > 0x3fff) // exceeds bit 13 at 183 baud
|
||||||
throw new UnsupportedOperationException("Baud rate to low");
|
throw new UnsupportedOperationException("Baud rate too low");
|
||||||
effectiveBaudRate = (24000000 << 1) / ((divisor << 3) + subdivisor);
|
effectiveBaudRate = (24000000 << 1) / ((divisor << 3) + subdivisor);
|
||||||
effectiveBaudRate = (effectiveBaudRate +1) >> 1;
|
effectiveBaudRate = (effectiveBaudRate +1) >> 1;
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ public class FtdiSerialDriver implements UsbSerialDriver {
|
|||||||
int result = mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, MODEM_CONTROL_REQUEST,
|
int result = mConnection.controlTransfer(REQTYPE_HOST_TO_DEVICE, MODEM_CONTROL_REQUEST,
|
||||||
value ? MODEM_CONTROL_RTS_ENABLE : MODEM_CONTROL_RTS_DISABLE, mPortNumber+1, null, 0, USB_WRITE_TIMEOUT_MILLIS);
|
value ? MODEM_CONTROL_RTS_ENABLE : MODEM_CONTROL_RTS_DISABLE, mPortNumber+1, null, 0, USB_WRITE_TIMEOUT_MILLIS);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
throw new IOException("Set DTR failed: result=" + result);
|
throw new IOException("Set RTS failed: result=" + result);
|
||||||
}
|
}
|
||||||
rts = value;
|
rts = value;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -327,7 +327,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
|||||||
mStopReadStatusThread = true;
|
mStopReadStatusThread = true;
|
||||||
mReadStatusThread.join();
|
mReadStatusThread.join();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, "An error occured while waiting for status read thread", e);
|
Log.w(TAG, "An error occurred while waiting for status read thread", e);
|
||||||
}
|
}
|
||||||
mStopReadStatusThread = false;
|
mStopReadStatusThread = false;
|
||||||
mReadStatusThread = null;
|
mReadStatusThread = null;
|
||||||
@@ -376,7 +376,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
|||||||
baseline = 12000000 * 32;
|
baseline = 12000000 * 32;
|
||||||
mantissa = baseline / baudRate;
|
mantissa = baseline / baudRate;
|
||||||
if (mantissa == 0) { // > unrealistic 384 MBaud
|
if (mantissa == 0) { // > unrealistic 384 MBaud
|
||||||
throw new UnsupportedOperationException("Baud rate to high");
|
throw new UnsupportedOperationException("Baud rate too high");
|
||||||
}
|
}
|
||||||
exponent = 0;
|
exponent = 0;
|
||||||
if (mDeviceType == DeviceType.DEVICE_TYPE_T) {
|
if (mDeviceType == DeviceType.DEVICE_TYPE_T) {
|
||||||
@@ -385,7 +385,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
|||||||
mantissa >>= 1; /* divide by 2 */
|
mantissa >>= 1; /* divide by 2 */
|
||||||
exponent++;
|
exponent++;
|
||||||
} else { // < 7 baud
|
} else { // < 7 baud
|
||||||
throw new UnsupportedOperationException("Baud rate to low");
|
throw new UnsupportedOperationException("Baud rate too low");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf = mantissa + ((exponent & ~1) << 12) + ((exponent & 1) << 16) + (1 << 31);
|
buf = mantissa + ((exponent & ~1) << 12) + ((exponent & 1) << 16) + (1 << 31);
|
||||||
@@ -396,7 +396,7 @@ public class ProlificSerialDriver implements UsbSerialDriver {
|
|||||||
mantissa >>= 2; /* divide by 4 */
|
mantissa >>= 2; /* divide by 4 */
|
||||||
exponent++;
|
exponent++;
|
||||||
} else { // < 45.8 baud
|
} else { // < 45.8 baud
|
||||||
throw new UnsupportedOperationException("Baud rate to low");
|
throw new UnsupportedOperationException("Baud rate too low");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf = mantissa + (exponent << 9) + (1 << 31);
|
buf = mantissa + (exponent << 9) + (1 << 31);
|
||||||
|
|||||||
Reference in New Issue
Block a user