IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Import driver USBSerial


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 7
    Par défaut Import driver USBSerial
    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:
    Infortunately, PL2303HXDSimpleTest has stopped
    Voici le source de mon prog (bien elagué par rapport à l'original) :
    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
     
    }
    Sur l'écran
    5554:AVD_for_mydevice:

    Infortunately, PL2303HXDSimpleTest has stopped.
    sortie de DDMS
    11-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)
    Et le AndroidManifest.xml
    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>
    Quelqu'un saurait-il m'indiquer comment résoudre ce problème ?

    Merci d'avance pour votre aide.

  2. #2
    Expert confirmé

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Par défaut
    Salut,

    Tu as bien rajouté ce jar dans le dossier libs de ton projet Android ?

  3. #3
    Membre éclairé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2007
    Messages
    697
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2007
    Messages : 697
    Par défaut
    Je plussoie la réponse de Feanorin, le jar n'est problablement pas dans le dossier lib.

    Sinon, si ça ne corrige pas le problème, j'ai travaillé sur la même chose et j'ai utilisé le projet suivant : https://github.com/mik3y/usb-serial-for-android qui dans mon cas marche très bien. Dans mon cas j'ai testé seulement le driver FTDI mais il y a aussi un driver Profilic.

Discussions similaires

  1. Réponses: 3
    Dernier message: 08/06/2015, 16h36
  2. [FOP] import org.apache.fop.apps.Driver non trouvé
    Par touane dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 16/04/2008, 15h12
  3. [DEV-C++]#import de fichier .tlb
    Par pdl dans le forum Dev-C++
    Réponses: 6
    Dernier message: 19/07/2002, 22h46
  4. Importer des objets de 3dsMax
    Par Anonymous dans le forum OpenGL
    Réponses: 3
    Dernier message: 06/05/2002, 13h53
  5. IMPORTANT! A lire avant tout chose
    Par Aurelien.Regat-Barrel dans le forum Windows
    Réponses: 0
    Dernier message: 01/05/2002, 16h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo