@@ -42,6 +42,7 @@ public class Cp21xxSerialPort : CommonUsbSerialPort
4242 * Configuration Request Types
4343 */
4444 private const int REQTYPE_HOST_TO_DEVICE = 0x41 ;
45+ private const int REQTYPE_DEVICE_TO_HOST = 0xc1 ;
4546
4647 /*
4748 * Configuration Request Codes
@@ -56,9 +57,7 @@ public class Cp21xxSerialPort : CommonUsbSerialPort
5657 private const int FLUSH_READ_CODE = 0x0a ;
5758 private const int FLUSH_WRITE_CODE = 0x05 ;
5859
59- // https://developer.android.com/reference/android/hardware/usb/UsbConstants#USB_DIR_IN
60- private static int REQTYPE_DEVICE_TO_HOST = UsbConstants . UsbTypeVendor | 0 ; // UsbConstants.USB_DIR_IN;
61- private static int GET_MODEM_STATUS_REQUEST = 5 ;
60+ private static int GET_MODEM_STATUS_REQUEST = 0x08 ; // 0x08 Get modem status.
6261 private static int MODEM_STATUS_CTS = 0x10 ;
6362 private static int MODEM_STATUS_DSR = 0x20 ;
6463 private static int MODEM_STATUS_RI = 0x40 ;
@@ -312,10 +311,10 @@ public override void SetParameters(int baudRate, int dataBits, StopBits stopBits
312311
313312 private int GetStatus ( )
314313 {
315- byte [ ] data = new byte [ 2 ] ;
314+ byte [ ] data = new byte [ 1 ] ;
316315 int result = mConnection . ControlTransfer ( ( UsbAddressing ) REQTYPE_DEVICE_TO_HOST , GET_MODEM_STATUS_REQUEST ,
317- 0 , mPortNumber + 1 , data , data . Length , USB_WRITE_TIMEOUT_MILLIS ) ;
318- if ( result != 2 )
316+ 0 , mPortNumber , data , data . Length , USB_WRITE_TIMEOUT_MILLIS ) ;
317+ if ( result != 1 )
319318 {
320319 throw new IOException ( "Get modem status failed: result=" + result ) ;
321320 }
0 commit comments