Android与外部rs232设备通信

Android与外部rs232设备通信,android,serial-port,Android,Serial Port,我不熟悉安卓USB通信。在我的项目中,安卓设备必须与外部设备进行通信。我遵循了这一点 http://stackoverflow.com/questions/16916950/android-rs232-communication 但不是为我工作。 所以我尝试了另一种方法 主要活动是 UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); try { if (driver != null) {

我不熟悉安卓USB通信。在我的项目中,安卓设备必须与外部设备进行通信。我遵循了这一点

http://stackoverflow.com/questions/16916950/android-rs232-communication
但不是为我工作。 所以我尝试了另一种方法

主要活动是

UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
try {
    if (driver != null) {
      driver.open();
      Toast.makeText(this, "device opened", Toast.LENGTH_LONG).show();
      try {
        driver.setBaudRate(115200);
        int byteRead = driver.write("#".getBytes(), 1);
        Toast.makeText(this, "wrote bytes "+byteRead, Toast.LENGTH_LONG).show();
        byte buffer[] = new byte[16];
        int numBytesRead = driver.read(buffer, 1000);
        Log.d("read operation", "Read " + numBytesRead + " bytes.");
      } catch (IOException e) {
        // Deal with error.
      } finally {
        driver.close();
      } 
    }
    else
        Toast.makeText(this, "device is null", Toast.LENGTH_LONG).show();

} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
Android清单文件是

<uses-sdk
        android:minSdkVersion="12"
        />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.usbandroid.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
            </intent-filter>
     <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
                android:resource="@xml/device_filter" />
        </activity>
    </application>

设备过滤器是

 <?xml version="1.0" encoding="utf-8"?>

<resources>
      <usb-device vendor-id="0403" product-id="6001" />
</resources>

它显示设备为空。我哪里出错