Bonjour,
Je voudrais connecter un contrôleur USB-to-Serial sur une tablette Android et programmer une application pour celle-ci.
Le chip est un PL2303HXD de chez Prolific Technology. Leur site fourni un bundle pour Linux comprenant entre autres un exemple en java et une Lib avec les drivers BaudRate, parity, ReadData routine, etc, sous forme .class, (exemple PL2303Driver$BaudRate.class) le tout dans un module .jar
Dans Project/Property d'Eclipse j'ai indiqué Java Build Path / Libraries / Add External JARs l'adresse de ce module .jar.
A l'exécution, une erreur survient au premier accès au driver:Voici le source de mon prog (bien elagué par rapport à l'original) :Infortunately, PL2303HXDSimpleTest has stopped
Sur l'écran
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 package com.prolific.pl2303hxdsimpletest; import tw.com.prolific.driver.pl2303.PL2303Driver; import tw.com.prolific.driver.pl2303.PL2303Driver.DataBits; import tw.com.prolific.driver.pl2303.PL2303Driver.FlowControl; import tw.com.prolific.driver.pl2303.PL2303Driver.Parity; import tw.com.prolific.driver.pl2303.PL2303Driver.StopBits; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class PL2303HXDSimpleTest extends Activity { // PL2303Driver mSerial; // String TAG = "PL2303HXD_APLog"; // // // //BaudRate.B4800, DataBits.D8, StopBits.S1, Parity.NONE, FlowControl.RTSCTS private PL2303Driver.BaudRate mBaudrate = PL2303Driver.BaudRate.B9600; // private PL2303Driver.DataBits mDataBits = PL2303Driver.DataBits.D8; // private PL2303Driver.Parity mParity = PL2303Driver.Parity.NONE; // private PL2303Driver.StopBits mStopBits = PL2303Driver.StopBits.S1; // private PL2303Driver.FlowControl mFlowControl = PL2303Driver.FlowControl.OFF; // @Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "Enter onCreate"); // super.onCreate(savedInstanceState); setContentView(R.layout.activity_pl2303_hxdsimple_test); Log.d(TAG, "Leave onCreate"); }//onCreate protected void onStop() { Log.d(TAG, "Enter onStop"); super.onStop(); Log.d(TAG, "Leave onStop"); }//onStop @Override protected void onDestroy() { Log.d(TAG, "Enter onDestroy"); if(mSerial!=null) { mSerial.end(); mSerial = null; } super.onDestroy(); Log.d(TAG, "Leave onDestroy"); }//onDestroy public void onStart() { Log.d(TAG, "Enter onStart"); super.onStart(); Log.d(TAG, "Leave onStart"); }//onStart public void onResume() { Log.d(TAG, "Enter onResume"); Log.d(TAG, "Leave onResume"); }//onResume public void SetNewVIDPID(){ }//SetNewVIDPID private void openUsbSerial() { }//openUsbSerial private void readDataFromSerial() { }//readDataFromSerial private void writeDataToSerial() { }//writeDataToSerial }sortie de DDMS5554:AVD_for_mydevice:
Infortunately, PL2303HXDSimpleTest has stopped.
Et le AndroidManifest.xml11-27 11:37:59.650: W/dalvikvm(2343): VFY: unable to resolve static field 786 (B9600) in Ltw/com/prolific/driver/pl2303/PL2303Driver$BaudRate;
11-27 11:37:59.650: D/dalvikvm(2343): VFY: replacing opcode 0x62 at 0x0007
11-27 11:37:59.670: I/dalvikvm(2343): Could not find method tw.com.prolific.driver.pl2303.PL2303Driver.end, referenced from method com.prolific.pl2303hxdsimpletest.PL2303HXDSimpleTest.onDestroy
11-27 11:37:59.670: W/dalvikvm(2343): VFY: unable to resolve virtual method 3173: Ltw/com/prolific/driver/pl2303/PL2303Driver;.end ()V
11-27 11:37:59.670: D/dalvikvm(2343): VFY: replacing opcode 0x6e at 0x000d
11-27 11:37:59.700: D/AndroidRuntime(2343): Shutting down VM
11-27 11:37:59.700: W/dalvikvm(2343): threadid=1: thread exiting with uncaught exception (group=0xb4b0ab90)
11-27 11:37:59.720: E/AndroidRuntime(2343): FATAL EXCEPTION: main
11-27 11:37:59.720: E/AndroidRuntime(2343): Process: com.prolific.pl2303hxdsimpletest, PID: 2343
11-27 11:37:59.720: E/AndroidRuntime(2343): java.lang.NoClassDefFoundError: tw.com.prolific.driver.pl2303.PL2303Driver$BaudRate
11-27 11:37:59.720: E/AndroidRuntime(2343): at com.prolific.pl2303hxdsimpletest.PL2303HXDSimpleTest.<init>(PL2303HXDSimpleTest.java:21)
Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.prolific.pl2303hxdsimpletest" android:versionCode="13" android:versionName="2.0.2.13" > <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="15" /> <uses-feature android:name="android.hardware.usb.host"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".PL2303HXDSimpleTest" android:label="@string/title_activity_pl2303_hxdsimple_test" android:screenOrientation="landscape" android:launchMode="singleTop" android:theme="@style/AppTheme" > <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" /> <!-- action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /> --> </intent-filter> <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" /> </activity> </application> </manifest>
Merci d'avance pour votre aide.
Partager