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

C++ Discussion :

fonction dans dll qui fait planter programme


Sujet :

C++

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut fonction dans dll qui fait planter programme
    Bonjour,

    je travail actuellement sur un code C++, sous dev c++. j'utilise une dll au travers d'un *.lib et dans mon programme principal je fais appel a des fonctions de ma dll.

    Mon programme compile, me cree mon *.exe, cependant quand mon prgm arrive a une ligne de code ou je fais appel a une fonction presente dans la dll!, il plante et me met le message d'erreur windows :

    "emulateur_AOA.exe a renconté un probleme et doit fermer, vous pouvez envoyer le rapport d'erreur a Microsoft ... "

    Je n'arrive vraiment pas a comprendre ce qui se passe !!

    Si quelqu'un a une idée?

    Merci d'avance

  2. #2
    Rédacteur

    Avatar de ram-0000
    Homme Profil pro
    Consultant en sécurité
    Inscrit en
    Mai 2007
    Messages
    11 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Consultant en sécurité
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2007
    Messages : 11 517
    Points : 50 367
    Points
    50 367
    Par défaut
    Un problème avec les conventions d'appel peut être

    stdcall, cdecl, ...
    Raymond
    Vous souhaitez participer à la rubrique Réseaux ? Contactez-moi

    Cafuro Cafuro est un outil SNMP dont le but est d'aider les administrateurs système et réseau à configurer leurs équipements SNMP réseau.
    e-verbe Un logiciel de conjugaison des verbes de la langue française.

    Ma page personnelle sur DVP
    .

  3. #3
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Citation Envoyé par ram-0000 Voir le message
    Un problème avec les conventions d'appel peut être

    stdcall, cdecl, ...
    De mauvais paramètres passés en argument...

    As-tu essayé en mode debug de voir ce qu'il se passe ?

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    J'ai lu sur d'autre forum que devc++ n'etais pas comaptible avec les *.lib mais avec des *.a .

    Bizare que ca arrive quand meme a compiler sans me mettre d'erreur !!
    Du coup j'ai essayer avec reimp.exe de WinGW de creer mon *.a a partir de mon .lib, mais je n'y comprend plus rien quand je link mon .a à mon prgm, devc++ me met des erreurs.

    Du coup j'ai abandonner ces librairies et je vais chercher dynamiquement mes fonctions de ma dll avec les routines :
    HINSTANCE load_lib = LoadLibrary("synchro.dll" ); ...


    La maintenant ca marche super bien , enfin je croyais, je dois appeler la meme fonction plusieur fois, et la desque je l'appel plus de 10 fois, mon prgm se coupe et ca me met "monprgm.exe a rencontré un probleme et doit se fermer, vous pouver envoyer le rapport d'erreur a Microsoft ..."


    Je ne sais pas pourquoi, mais j'ai fait plusieurs test, je ne sais pas si c'est une coincidence ou pas, mais si je l'appel 9 fois ca marche, 10 fois ca marche, mais des que j'essaye de l'appeler 11 fois ca beug !

    (Je peut ajouter que ma dll contient des fonctions pour ecrire sur une carte relié sur le port PCI de mon ordi, peut etre que ca a un rapport avec mon beug )

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    J'ai essayer avec d'autre fonction de ma dll et j'ai le meme probleme apres plusieur appel ca beug. Je doit surement mal m'y prendre pour faire appel a mes fonctions de ma dll.
    Un exemple d'une des fonctions (comme elle est déclaré dans le .h qui va avec la dll) : void WINAPI Program_Angle(int Card, int Channel, WORD Angle)

    je peut vous montrer comment je fait pour appeler cette fonction :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    // Déclarer un type de la fonction
    typedef void (PROGRAM_ANGLE) (int, int, WORD);
    // Déclarer les fonctions de la DLL
    PROGRAM_ANGLE *Program_Angle;
    // Récupérer l'adresse des fonctions en DLL
    Program_Angle = (PROGRAM_ANGLE *) GetProcAddress(load_lib, "Program_Angle" );
     
    //appel de ma fonction dans le programme
    (*Program_Angle)(Card,(Channel-1),buffer[j]);

    Quand je fais du pas a pas en debug, je plante bien sur ma ligne d'appel de ma fonction "(*Program_Angle)(Card,(Channel-1),buffer[j])" et windows me met l'erreur : une violation d'acces (erreur de segmentation) est apparue dans votre programme

  6. #6
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Quelle est la valeur de Program_Angle ?

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    Comment ca "quelle est al valeur de Programme_angle" ??

    Programme_angle c'est une fonction qui est implementer dans la dll.

  8. #8
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Et bien quand tu déroules :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Program_Angle = (PROGRAM_ANGLE *) GetProcAddress(load_lib, "Program_Angle" );
    Ton débugger te donne quoi comme valeur pour la variable Program_Angle?

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    Le debuggeur me donne :

    Program_Angle=(PROGRAM_ANGLE*)0x10001760 <_libmsvcrt_a_iname+263945908>

  10. #10
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Ok, donc GetProcAddress réussi.
    Quelles sont les valeurs de buffer et de j avant l'appel ?

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    j vaut bien "0" et mon tableau buffer vaut 0 pour toutes les cases.

    j'ai meme remplacer buffer[j] par directement un entier
    exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    (*Program_Angle)(Card,(Channel-1),5);
    mais le meme probleme.

    Est ce que tu pense que je m'y prend bien pour appeler pour déclarer et appeler mes fonctions de ma DLL.

    Je te remonte le code :

    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
                      /*********************************/    
                      /* Initialisation utilisation DLL*/   
                      /*********************************/ 
     
    // Charger la DLL en mémoire
    HINSTANCE load_lib = LoadLibrary("synchro.dll" );
     
    // Déclarer un type de la fonction
    typedef char* (GET_CARD_TYPE)(int);
    typedef char* (INITIALIZE) (int);
    typedef char* (GET_DLL_VERSION) (void);
    typedef void (CLOSE) (int);
    typedef void (CLEAR_ALL) (int, int);
    typedef void (PROGRAM_ANGLE) (int, int, WORD);
    typedef void (PROGRAM_AMPLITUDE) (int, int);
    typedef void (PROGRAM_FREQUENCY) (int, int);
     
    // Déclarer les fonctions de la DLL
    GET_CARD_TYPE *Get_Card_Type;
    INITIALIZE *Initialize;
    GET_DLL_VERSION *Get_DLL_Version;
    CLOSE *Close;
    CLEAR_ALL *Clear_All;
    PROGRAM_ANGLE *Program_Angle;
    PROGRAM_AMPLITUDE *Program_Amplitude;
    PROGRAM_FREQUENCY* Program_Frequency;
     
    // Récupérer l'adresse des fonctions en DLL
    Get_Card_Type = (GET_CARD_TYPE *) GetProcAddress(load_lib, "Get_Card_Type" );
    Initialize = (INITIALIZE *) GetProcAddress(load_lib, "Initialize" );
    Get_DLL_Version = (GET_DLL_VERSION *) GetProcAddress(load_lib, "Get_DLL_Version" );
    Close = (CLOSE *) GetProcAddress(load_lib, "Close" );
    Clear_All = (CLEAR_ALL *) GetProcAddress(load_lib, "Clear_All" );
    Program_Angle = (PROGRAM_ANGLE *) GetProcAddress(load_lib, "Program_Angle" );
    Program_Amplitude = (PROGRAM_AMPLITUDE *) GetProcAddress(load_lib, "Program_Amplitude" );
    Program_Frequency = (PROGRAM_FREQUENCY *) GetProcAddress(load_lib, "Program_Frequency" );

    et pour appeler mes fonctions je te met que l'exemple de "Program_Angle" :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    //appel de ma fonction dans le programme
    (*Program_Angle)(Card,(Channel-1),buffer[j]);
    J'ai bien sur essayer avec les autres fonctions, mais ca me fait pareil, quand je les appels qu'une fois ca marche, mais des que je les appels plussieurs fois ca beug (ca depend des fonctions mais ca beug a partir de 5/6 appel en général)

    Je reprécise que windows me met l'erreur : une violation d'acces (erreur de segmentation) est apparue dans votre programme

  12. #12
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    En général, je fais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    typedef void (*PROGRAM_ANGLE) (int, int, WORD);
    PROGRAM_ANGLE Program_Angle;
    Program_Angle = (PROGRAM_ANGLE ) GetProcAddress(load_lib, "Program_Angle" );
    Program_Angle(Card,(Channel-1),5);
    Ce qui est presque équivalent à ce que tu fais.
    Effectivement, je me suis pas posé la question de savoir ce que fait :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    (*Program_Angle)(Card,(Channel-1),5);
    Essaies simplement :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Program_Angle(Card,(Channel-1),5);
    L'erreur de segmentation est liée à ce que tu adresses une zone mémoire non valide (problème de pointeur invalide, dépassement d'un tableau etc..).

  13. #13
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    malheuresement ca me fait pareil.

    Je me permet de te joindre le fichier synchro.h qui ma été fournit avec synchro.dll par le constructeur de la carte PCI.

    Le constructeur ma aussi fournit un executable qui utlise cette dll, donc je n'ai aps modifier le synchro.h car il doit fonctionner.
    (Puis je rappel que mon programme et appel au fonctions de la dll fonctionne tres bien quand je les appel un nombre limité de fois)

    synchro.h
    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
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
     
    /******************************************************************************************************************
                                                                    Data Device Corporation Proprietary Information
     
            This document contains proprietary information of Data Device Corporation.  Recipient agrees to use it
            solely for the limited purpose for which it was made available by Data Device Corporation and will not
            transmit it or any of the data contained within it, in whole or in part, for any purpose except with the prior
            written permission of Data Device Corporation.  Recipient further agrees to promptly return or destroy it
            upon the request of Data Device Corporation.
    /*****************************************************************************************************************/
    #ifdef __cplusplus
    extern "C"
    {
    #endif
     
    #include <stdio.h>
    #ifndef _CVI_			// LabWindows CVI doesn't
    #include <windows.h>	// like windows.h
    #endif
     
    #ifndef WINAPI
    	#define WINAPI      __stdcall
    #endif
     
    /* TYPE DEFINITIONS */
     
    #ifndef BYTE
    typedef unsigned char       BYTE;
    #endif
    #ifndef UCHAR
    typedef unsigned char       UCHAR;
    #endif
    #ifndef WORD
    typedef unsigned short      WORD;
    #endif
    #ifndef USHORT
    typedef unsigned short      USHORT;
    #endif
    #ifndef ULONG
    typedef unsigned long      ULONG;
    #endif
    #ifdef _CVI_
    typedef unsigned long		LONG;
    #endif
     
    // Note: int is 32 bits
     
     
     
    #define OS_95							1		// Running Windows 95
    #define OS_NT							2		// Running Windows NT
    #define MAXCARDS						0xB		// Maximum number of cards supported by Control Panel
    #define MAXCHANNEL						0x6		// Maximum number of channels on a card
    #define CARDMASK						0x7
     
    #define TRACK							0x1
    #define INHIBIT							0x0
     
    #ifndef NORMAL
    #define NORMAL							0x1
    #endif
     
    #define BITE							0x0
     
    #define MODE_CONTINUOUS					0x0
    #define MODE_LATCH						0x1
     
    #define ENABLE							0x1
    #define DISABLE							0x0
     
    #define RELAYSETTLE						50 /* Ms */
     
    #define DSC36020						6
    #define DSC36022						4
     
    /* ERROR CONSTANTS */
     
    #define SDC36016_CLEAR					0x00
    #define SDC36016_NO_INIT				0x01
    #define SDC36016_INVALID_CARD			0x02
    #define SDC36016_INVALID_CHANNEL		0x04
     
    /* REGISTER MAPPING */
     
    #define SB3621x_ACSSD					0x00000000
    #define SB3621x_BCSSD					0x00020000
    #define SB3621x_CSTC					0x00800000
    #define SB3621x_STCS					0x00820000
    #define SB3621x_REFCS					0x01000000
    #define SB3621x_STATSD					0x00000000
    #define SB3621x_BWSTAT					0x00020000
    #define SB3621x_DBSDchA					0x00800000
    #define SB3621x_DBSDchB					0x00820000
    #define SB3621x_DBSDchC					0x00840000
    #define SB3621x_DBSDchD					0x00860000
    #define SB3621x_DBSDchE					0x00880000
    #define SB3621x_DBSDchF					0x008A0000
    #define SB3621x_DBTCchA					0x01000000
    #define SB3621x_DBTCchB					0x01020000
    #define SB3621x_DBTCchC					0x01040000
    #define SB3621x_DBTCchD					0x01060000
    #define SB3621x_DBTCchE					0x01080000
    #define SB3621x_DBTCchF					0x010A0000
    #define SB3621x_RBSTATACSSD				0x01800000
    #define SB3621x_RBSTATBCSSD				0x01820000
    #define SB3621x_RBSTATREFCS				0x01840000
    #define SB3621x_RBSTATCSTC				0x01860000
    #define SB3621x_RBSTATSTCS				0x01880000
     
    //Write SB3620x Registers///////////////////////////////
    #define SB3620x_ACSSD					0x00000000
    #define SB3620x_BCSSD					0x00020000
    #define SB3620x_CSTC					0x00800000
    #define SB3620x_REFCS					0x01000000
    #define SB3620x_DRDYN					0x01800000
    #define SB3620x_SPDR					0x01820000
    #define SB3620x_FINEL					0x01840000
    #define SB3620x_COARSEL					0x01860000
    #define SB3620x_BRMC					0x01880000
    #define SB3620x_BRMF					0x018A0000
     
    //Read SB3620x Registers///////////////////////////////
     
    #define SB3620x_STATSD					0x00000000
    #define SB3620x_CDAT					0x00020000
    #define SB3620x_FDAT					0x00040000
     
     
    #define SB3620x_DBSD_CHA				0x00800000
    #define SB3620x_DBSD_CHB				0x00820000
    #define SB3620x_DBSD_CHC				0x00840000
    #define SB3620x_DBSD_CHD				0x00860000
     
    #define SB3620x_DBTC_CHA				0x01000000
    #define SB3620x_DBTC_CHB				0x01020000
    #define SB3620x_DBTC_CHC				0x01040000
    #define SB3620x_DBTC_CHD				0x01060000
     
    #define SB3620x_RBSTAT_ACSSD			0x01800000
    #define SB3620x_RBSTAT_BCSSD			0x01820000
    #define SB3620x_RBSTAT_CSREF			0x01840000
    #define SB3620x_RBSTAT_SPDR_TC			0x01860000
    #define SB3620x_RBSTAT_DRDYN			0x01880000
    #define SB3620x_RBSTAT_BRM				0x018A0000
    #define SB3620x_RBSTAT_BRMF				0x018C0000
     
    #define SB3620x_INHIBITall				0x3C00		// Inhibit all 6 channels
    ////////////////////////////////////////////////////////
    #define SB3622x_FBRM_CHB				0x00000000
    #define SB3622x_CBRM_CHA				0x00020000
    #define SB3622x_SR_CHAB 				0x00040000
    #define SB3622x_SLD_CHB 				0x00060000
    #define SB3622x_SLD_CHA 				0x00080000
    #define SB3622x_CSROT_CHAB				0x000A0000
    #define SB3622x_FBRM_CHD				0x00800000
    #define SB3622x_CBRM_CHC				0x00820000
    #define SB3622x_SR_CHCD 				0x00840000
    #define SB3622x_SLD_CHD 				0x00860000
    #define SB3622x_SLD_CHC 				0x00880000
    #define SB3622x_CSROT_CHCD				0x008A0000
    #define SB3622x_FBRM_CHF				0x01000000
    #define SB3622x_CBRM_CHE				0x01020000
    #define SB3622x_SR_CHEF					0x01040000
    #define SB3622x_SLD_CHF 				0x01060000
    #define SB3622x_SLD_CHE 				0x01080000
    #define SB3622x_CSROT_CHEF				0x010A0000
    #define SB3622x_BRDCS					0x01800000
    #define SB3622x_RBSTATCSROT_AB			0x00000000
    #define SB3622x_RBSTATCSROT_CD			0x00020000
    #define SB3622x_RBSTATCSROT_EF			0x00040000
    #define SB3622x_RBSTATBRDCS				0x00060000
    #define SB3622x_RBSTATFBRM_CHB			0x00080000
    #define SB3622x_RBSTATCBRM_CHA			0x000A0000
    #define SB3622x_RBSTATSR_CHAB 			0x000C0000
    #define SB3622x_RBSTATFBRM_CHD			0x000E0000
    #define SB3622x_RBSTATCBRM_CHC			0x00800000
    #define SB3622x_RBSTATSR_CHCD 			0x00820000
    #define SB3622x_RBSTATFBRM_CHF			0x00840000
    #define SB3622x_RBSTATCBRM_CHE			0x00860000
    #define SB3622x_RBSTATSR_CHEF 			0x00880000
    #define SB3622x_RCCDATA       			0x01000000
    #define SB3622x_RCFDATA       			0x01020000
    #define SB3622x_RCCDATB       			0x01040000
    #define SB3622x_RCFDATB       			0x01060000
    #define SB3622x_RCCDATC       			0x01080000
    #define SB3622x_RCFDATC       			0x010A0000
    #define SB3622x_TSECB       			0x010C0000
    ///////////////////////SB-3641x//////////////////////////
    #define SB3641x_POSITION_CHAN1			0
    #define SB3641x_BIT_CHAN1				1
    #define SB3641x_POSITION_CHAN2			2
    #define SB3641x_BIT_CHAN2				3
    #define SB3641x_POSITION_CHAN3			4
    #define SB3641x_BIT_CHAN3				5
    #define SB3641x_POSITION_CHAN4			6
    #define SB3641x_BIT_CHAN4				7
    #define SB3641x_POSITION_CHAN5			8
    #define SB3641x_BIT_CHAN5				9
    #define SB3641x_POSITION_CHAN6			10
    #define SB3641x_BIT_CHAN6				11
    #define SB3641x_POSITION_CHAN7			12
    #define SB3641x_BIT_CHAN7				13
    #define SB3641x_POSITION_CHAN8			14
    #define SB3641x_BIT_CHAN8				15
    #define SB3641x_INHIBIT					16
    //#define SB3641x_ENABLE				17
    #define SB3641x_RESOLUTION				18
    #define SB3641x_BANDWIDTH				19 
    #define SB3641x_ENCODER					20   //MSB A Quad B   LSB  ZI Enable
    //empty									21
    #define SB3641x_SELF_TEST				22
    #define SB3641x_TESTA1					24
    #define SB3641x_TESTA2					25
    #define SB3641x_TEST51					26
    #define SB3641x_TEST52					27
     
     
    /* For Twospeed_Inhibit */
    #define SB3621x_INHIBITa				0x0004		// Inhibit channel A
    #define SB3621x_INHIBITb				0x0008		// Inhibit channel B
    #define SB3621x_INHIBITc				0x0010		// Inhibit channel C
    #define SB3621x_INHIBITd				0x0020		// Inhibit channel D
    #define SB3621x_INHIBITe				0x0040		// Inhibit channel E
    #define SB3621x_INHIBITf				0x0080		// Inhibit channel F
    #define SB3621x_INHIBITall				0x00FC		// Inhibit all 6 channels
     
    #define SDC36016_REG_CONTROL            0x00
    #define SDC36016_REG_STATUS             0x00
    #define SDC36016_REG_CHANNEL_1_LSB      0x02
    #define SDC36016_REG_CHANNEL_1_MSB      0x03
     
    #define SDC36015_REG_CONTROL            0x00
    #define SDC36015_REG_LSB                0x00
    #define SDC36015_REG_MSB                0x01
    #define SDC36015_REG_ERRCOUNT           0x02
    #define SDC36015_REG_STATUS             0x03
     
    #define API36005_REG_CONTROLA			0x04 /* READ/WRITE */
    #define API36005_REG_ANGLE_LSB1			0x05 /* WRITE */
    #define API36005_REG_ANGLE_LSB2			0x06 /* WRITE */
    #define API36005_REG_ANGLE_MSB			0x07 /* WRITE */
     
    #define SIM36010_REGISTER_SPEED_LSB		0x02 /* WRITE */
    #define SIM36010_REGISTER_SPEED_MSB		0x03 /* WRITE */
    #define SIM36010_REGISTER_CONTROLA		0x04 /* WRITE */
    #define SIM36010_REGISTER_CONTROLB		0x05 /* WRITE */
    #define SIM36010_REGISTER_ANGLE_LSB		0x06 /* WRITE */
    #define SIM36010_REGISTER_ANGLE_MSB		0x07 /* WRITE */
    #define SIM36010_REGISTER_STATUS		0x04 /* READ  */
     
    /* FUNCTION PROTOTYPES */
     
    char *WINAPI Initialize(int);				// (Card#)
    void Initialize_PCI_Driver(void);			// Internal to dll
    void Initialize_ISA_Driver(void);			// Internal to dll
    void WINAPI Clear_All(int,int);				// (Card#, Channel)
    void WINAPI Clear_Channel(int,int);			// (Card#, Channel)
    LONG WINAPI Combine_Angle(int,WORD,WORD);	// (Card#, Angle LSB, Angle MSB)
    void WINAPI Dynamic_Rotation(int,int,double,int,int);	// (Card#, Channel, Rate, Direction, # of Turns)
    void WINAPI Enable_Rotation(int,int);		// (Card#, Channel)
    void WINAPI Enable_TwoSpeed(int,int);		// (Card#, Channel)
    void WINAPI Latch_Channel (int,int,int);	// (Card#, Channel, Mode) (0 or 1)
    void WINAPI Latch_TwoSpeed_Data(int,int,int); // (Card#, Channel, Mode) (0 or 1)
    void WINAPI Program_Amplitude(int,int);		// (Card#, Amplitude) (0-0xFF)
    void WINAPI Program_Angle(int,int,WORD);	// (Card#, Channel, Angle to write)
    void WINAPI Program_Bandwidth(int,int,int);	// (Card#, Channel, Bandwidth Mode) (0 or 1)
    void WINAPI Program_Card(int,int);			// (Card#, Channel)
    void WINAPI Program_Encoder(int,int,int);	// (Card#, Channel, Encoder Mode) (0 or 1)
    void WINAPI Program_Frequency(int,int);		// (Card#, Frequency) (0-0xFF)
    void WINAPI Program_Inhibit(int,int,int);	// (Card#, Channel, Inhibit Mode) (0 or 1)
    float WINAPI Program_Multiplier(int,int,float,int,int); // (Card#, Channel, Multiplier, Direction.SpeedMode)
    void WINAPI Program_Ratio(int,int,WORD);	// (Card#, Channel, Ratio)
    void WINAPI Program_Resolution(int,int,int);// (Card#, Channel, Resolution) (10,12,14,16)
    void WINAPI Program_Encoder_Resolution(int,int,int);// (Card#, Channel, Resolution) (10,12,14,16)
    void WINAPI Program_Speed(int,double,int);	// (Card#, Speed to write, Polarity)
    void WINAPI Read_All_Channels(int,WORD[6],int[6]);		// (Card#, Angle array, BITE array)
    long WINAPI Read_Angle(int,int);			// (Card#, Channel) returns long Angle
    WORD WINAPI Read_Angle_WORD(int,int);		// (Card#, Channel) returns WORD Angle
    int  WINAPI Read_Bandwidth(int,int);		// (Card#, Channel) returns BOOL Bandwidth
    int  WINAPI Read_Bite(int,int);				// (Card#, Channel) returns BOOL BITE
    int  WINAPI Read_Control(int,int);			// (Card#, Channel) returns Control Register bits
    WORD WINAPI Read_Converter(int,int);		// (Card#, Channel) Inhibits, Reads Angle, Uninhibits
    int  WINAPI Read_Count(int);				// (Card#) returns SDC36015 counter
    int  WINAPI Read_Counter(int,int);			// (Card#, Channel) returns SB3621x counter
    int  WINAPI Read_Direction(int,int);		// (Card#, Channel) returns BOOL Direction
    int  WINAPI Read_Encoder(int,int);			// (Card#, Channel) returns BOOL Encoder Mode
    int  WINAPI Read_Inhibit(int,int);			// (Card#, Channel) returns BOOL Inhibit
    int  WINAPI Read_Latched_Angle(int,int,int*,int*); // (Card#, Channel Pair, Coarse Angle, Fine Angle) returns 1 if data was Latched, 0 if not
    int  WINAPI Read_LOR(int);					// (Card#) returns BOOL LOR
    int  WINAPI Read_LOS(int);					// (Card#) returns BOOL LOS 
    WORD WINAPI Read_Lsb(int);					// (Card#) returns lower 16 bits of API angle
    WORD WINAPI Read_Msb(int);					// (Card#) returns upper 4 bits of API angle
    int  WINAPI Read_Register(int,int);			// (Card#, Register) returns bits from Register
    int  WINAPI Read_Resolution(int,int);		// (Card#, Channel) returns Resolution (10,12,14,16)
    int  WINAPI Read_Status(int);				// (Card#)
    void WINAPI Reset_Count(int);				// (Card#) resets SDC36015 counter
    void WINAPI Reset_Counter(int,int);			// (Card#, Channel) resets SB3621x counter
    int	 WINAPI SelfTest(int);					// (Card#)
    void WINAPI Start_Rotation(int,int,int);	// (Card#, Channel, Mode) (0 or 1)
    int	 WINAPI Start_SelfTest(int);			// (Card#)
    void WINAPI Start_TwoSpeed(int,int,int);	// (Card#, Channel, Mode) (0 or 1)
    void WINAPI Static_TwoSpeed(int,int,double);// (Card#, Channel Pair(0-2), Coarse Angle)
    int	 WINAPI End_SelfTest(int);				// (Card#)
    void WINAPI Twospeed_Inhibit(int,int);		// (Card#, ORed channels from above mapping)
    void WINAPI Write_Converter(int,int,WORD);	// (Card#, Channel, Data to write)
    void WINAPI Close(int);						// (Card#)
     
    char* WINAPI Get_Card_Type(int);			// (Card#) returns string of card name
    char* WINAPI Get_Card_Address(int);			// (Card#) returns address (ISA) or PCI slot of card
    char* WINAPI Get_DLL_Version(void);			// returns version of current DLL
    WORD  WINAPI DectoBin(double);				// (Decimal angle (360.000)) converts to Synchro binary
    LONG  WINAPI DectoBin_Long(double);			// (Decimal angle) converts to 20 bit Synchro binary
    double WINAPI BintoDec(WORD);				// (Synchro binary) converts to Decimal equivalent
    double WINAPI BintoDec_Long(LONG);			// (Synchro binary) converts to 20 bit Decimal 
    void WINAPI CalculateTwospeed(double,double,double,double*,int*); // (Coarse angle, Fine angle, speed, combined angle, error flag)
    int  WINAPI Get_Last_Error(char*);			// (Empty string) returns char string of error, and error code
     
    WORD WINAPI Synchro_ReadChar (unsigned long);			// Internal to DLL
    WORD WINAPI Synchro_ReadShort(unsigned long);			// Internal to DLL
    LONG WINAPI Synchro_ReadLong (unsigned long);			// Internal to DLL
    BOOL WINAPI Synchro_WriteChar(unsigned long,UCHAR);		// Internal to DLL
    BOOL WINAPI Synchro_WriteShort(unsigned long,USHORT);	// Internal to DLL
    BOOL WINAPI Synchro_WriteLong(unsigned long,ULONG);		// Internal to DLL
     
     
    /* Routines for specific hardware.  Not preferred method.  Use above generic routines. */
    void WINAPI SB3620x_Initialize(int,int);
    void WINAPI SB3620x_Program_Resolution(int,int,int);
    void WINAPI SB3620x_Program_Bandwidth(int,int,int);
    void WINAPI SB3620x_Program_Frequency(int,int);
    void WINAPI SB3620x_Program_Amplitude(int,int);
    int  WINAPI SB3620x_SelfTest(int);
    int  WINAPI SB3620x_Start_SelfTest(int);
    int  WINAPI SB3620x_End_SelfTest(int);
    void WINAPI SB3620x_Program_Inhibit(int,int,int);
    void WINAPI SB3620x_Twospeed_Inhibit(int,int);
    int  WINAPI SB3620x_Read_Inhibit(int,int);
    int  WINAPI SB3620x_Read_Resolution(int,int);
    WORD WINAPI SB3620x_Read_Angle(int,int);
    WORD WINAPI SB3620x_Read_Converter(int,int);
    int  WINAPI SB3620x_Read_Direction(int,int);
    int  WINAPI SB3620x_Read_Bandwidth(int,int);
    int  WINAPI SB3620x_Read_Bite(int,int);
    int  WINAPI SB3620x_Read_Counter(int,int);
    void WINAPI SB3620x_Reset_Counter(int,int);
    void WINAPI SB3620x_Clear_All(int,int);
    void WINAPI SB3620x_Clear_Channel(int,int);
    void WINAPI SB3620x_Enable_Rotation(int,int);
    void WINAPI SB3620x_Enable_TwoSpeed(int,int);
    void WINAPI SB3620x_Latch_Channel (int,int,int);
    void WINAPI SB3620x_Latch_TwoSpeed_Data(int,int,int);
    void WINAPI SB3620x_Program_Angle(int,int,WORD);
    float WINAPI SB3620x_Program_Multiplier(int,int,float,int,int);
    void WINAPI SB3620x_Program_Ratio(int,int,WORD);
    int  WINAPI SB3620x_Read_Latched_Angle(int,int,int*,int*);
    void WINAPI SB3620x_Start_Rotation(int,int,int);
    void WINAPI SB3620x_Start_TwoSpeed(int,int,int);
    void WINAPI SB3620x_Static_TwoSpeed (int,int,double);
    void WINAPI SB3620x_Close(int);
    //////////////////////Not sure/////////////////////////////////////////////////////////////
    void WINAPI SB3620x_Program_Encoder(int,int,int);
    void WINAPI SB3620x_Program_Encoder_Resolution(int,int,int);
    int  WINAPI SB3620x_Read_Encoder(int,int);
    int  WINAPI SB3620x_Read_Encoder_Resolution(int,int);
    int  WINAPI SB3620x_Read_Control(int,int);
    int  WINAPI SB3620x_Read_Register(int,int);
    /////////////////////////////////////////////////////////////////////////////////////////
    void WINAPI SB3621x_Initialize(int,int);
    void WINAPI SB3621x_Program_Resolution(int,int,int);
    void WINAPI SB3621x_Program_Bandwidth(int,int,int);
    void WINAPI SB3621x_Program_Encoder(int,int,int);
    void WINAPI SB3621x_Program_Encoder_Resolution(int,int,int);
    void WINAPI SB3621x_Program_Frequency(int,int);
    void WINAPI SB3621x_Program_Amplitude(int,int);
    int  WINAPI SB3621x_SelfTest(int);
    int  WINAPI SB3621x_Start_SelfTest(int);
    int  WINAPI SB3621x_End_SelfTest(int);
    void WINAPI SB3621x_Program_Inhibit(int,int,int);
    void WINAPI SB3621x_Twospeed_Inhibit(int,int);
    int  WINAPI SB3621x_Read_Inhibit(int,int);
    int  WINAPI SB3621x_Read_Resolution(int,int);
    WORD WINAPI SB3621x_Read_Angle(int,int);
    WORD WINAPI SB3621x_Read_Converter(int,int);
    int  WINAPI SB3621x_Read_Direction(int,int);
    int  WINAPI SB3621x_Read_Bandwidth(int,int);
    int  WINAPI SB3621x_Read_Encoder(int,int);
    int  WINAPI SB3621x_Read_Bite(int,int);
    int  WINAPI SB3621x_Read_Counter(int,int);
    void WINAPI SB3621x_Reset_Counter(int,int);
    void WINAPI SB3621x_Close(int);
     
    void WINAPI SB3622x_Initialize(int,int);
    void WINAPI SB3622x_Clear_All(int,int);
    void WINAPI SB3622x_Clear_Channel(int,int);
    void WINAPI SB3622x_Enable_Rotation(int,int);
    void WINAPI SB3622x_Enable_TwoSpeed(int,int);
    void WINAPI SB3622x_Latch_Channel (int,int,int);
    void WINAPI SB3622x_Latch_TwoSpeed_Data(int,int,int);
    void WINAPI SB3622x_Program_Amplitude(int,int);
    void WINAPI SB3622x_Program_Angle(int,int,WORD);
    void WINAPI SB3622x_Program_Frequency(int,int);
    float WINAPI SB3622x_Program_Multiplier(int,int,float,int,int);
    void WINAPI SB3622x_Program_Ratio(int,int,WORD);
    void WINAPI SB3622x_Program_Resolution (int,int,int);
    int  WINAPI SB3622x_Read_Control(int,int);
    int  WINAPI SB3622x_Read_Latched_Angle(int,int,int*,int*);
    int  WINAPI SB3622x_Read_Register(int,int);
    int  WINAPI SB3622x_Read_Resolution(int,int);
    void WINAPI SB3622x_Start_Rotation(int,int,int);
    void WINAPI SB3622x_Start_TwoSpeed(int,int,int);
    void WINAPI SB3622x_Static_TwoSpeed (int,int,double);
    void WINAPI SB3622x_Close(int);
     
    /////////////////////////////////////////////////////////////////////////////////////////
    void WINAPI SB3641x_Initialize(int,int);
    void WINAPI SB3641x_Program_Resolution(int,int,int);
    void WINAPI SB3641x_Program_Bandwidth(int,int,int);
    void WINAPI SB3641x_Program_AQuadB(int,int,int);
    void WINAPI SB3641x_Program_Zip(int,int,int);
    int  WINAPI SB3641x_SelfTest(int,int);
    int  WINAPI SB3641x_Start_SelfTest(int);
    int  WINAPI SB3641x_Read_SelfTest(int);
    void WINAPI SB3641x_Program_Inhibit(int,int,int);
    WORD WINAPI SB3641X_Mem_Read(int,int);
    int WINAPI  SB3641X_Mem_Write(int,int,int);
     
    WORD WINAPI SB3641x_Read_Angle(int,int);
    int  WINAPI SB3641x_Read_Inhibit(int,int);
    int  WINAPI SB3641x_Read_Resolution(int,int);
    int  WINAPI SB3641x_Read_Bandwidth(int,int);
    int  WINAPI SB3641x_Read_AQuadB(int,int);
    int  WINAPI SB3641x_Read_Zip(int,int);
    int  WINAPI SB3641x_Read_Bite(int,int);
    void WINAPI SB3641x_Close(int);
    ////////////////////////////////////////////////////////////////////////////////////////
    void WINAPI SDC36016_Initialize(int,int);
    WORD WINAPI SDC36016_Read_Angle(int,int);
    int  WINAPI SDC36016_Read_Inhibit(int,int);
    WORD WINAPI SDC36016_Read_Converter(int,int);
    int  WINAPI SDC36016_Read_Bite(int,int);
    void WINAPI SDC36016_Program_Inhibit(int,int,int);
    void WINAPI SDC36016_Close(int);
     
    void WINAPI SDC36015_Initialize(int,int);
    void WINAPI SDC36015_Program(int,WORD);
    WORD WINAPI SDC36015_Read_Angle(int,int);
    int  WINAPI SDC36015_Read_Bite(int);
    void WINAPI SDC36015_Read_All_Channels(int,WORD [6],int [6]);
    int  WINAPI SDC36015_Read_Los(int);
    int  WINAPI SDC36015_Read_Count(int);
    void WINAPI SDC36015_Reset_Count(int);
    int  WINAPI SDC36015_Read_Status(int);
    void WINAPI SDC36015_Close(int);
     
    void WINAPI API36005_Initialize(int,int);
    void WINAPI API36005_Program(int,int);
    int  WINAPI API36005_Read_Bite(int);
    int  WINAPI API36005_Read_Lor(int);
    WORD WINAPI API36005_Read_Lsb(int);
    WORD WINAPI API36005_Read_Msb(int);
    LONG WINAPI API36005_Read_Angle(int);
    LONG WINAPI API36005_Combine_Angle(int,WORD,WORD);
    void WINAPI API36005_Close(int);
     
    void WINAPI DSC_Initialize(int,int,int);
    void WINAPI DSC_Program_Angle(int,int,WORD);
    void WINAPI DSC_Dynamic_Rotation(int,int,double,int,int);
    void WINAPI DSC_Write_Converter(int,int,WORD);
    void WINAPI DSC_Close(int);
     
    void WINAPI SIM36010_Initialize(int,int);
    void WINAPI SIM36010_Program(int,int);
    int	 WINAPI SIM36010_Read_Bite(int);
    int  WINAPI SIM36010_Read_Lor(int);
    void WINAPI SIM36010_Program_Angle(int,WORD);
    void WINAPI SIM36010_Program_Speed(int,double,int);
    void WINAPI SIM36010_Dynamic_Rotation(int,double,int);
    void WINAPI SIM36010_Write_Converter(int,WORD);
    void WINAPI SIM36010_Close(int);
     
    /* COMMANDS */
    					/*  New  Reg#  Posit    Mask   */
    					/*  XXXX  X    XXX   XXXX XXXX */
    #define SDC36015_IRQENA		0x06BF		/*  0000  0    110   1011 1111 */
    #define SDC36015_IRQDIS		0x16BF		/*  0001  0    110   1011 1111 */
    #define SDC36015_INHIBIT	0x04EF		/*  0000  0    100   1110 1111 */
    #define SDC36015_TRACK		0x14EF		/*  0001  0    100   1110 1111 */
    #define SDC36015_CRESET		0x15DF		/*  0000  0    101   1101 1111 */
    #define SDC36015_C1			0x00F8		/*  0000  0    000   1111 1000 */
    #define SDC36015_C2			0x10F8		/*  0001  0    000   1111 1000 */
    #define SDC36015_C3			0x20F8		/*  0010  0    000   1111 1000 */
    #define SDC36015_C4			0x30F8		/*  0011  0    000   1111 1000 */
    #define SDC36015_C5			0x40F8		/*  0100  0    000   1111 1000 */
    #define SDC36015_C6			0x50F8		/*  0101  0    000   1111 1000 */
     
    #define API36005_NORMAL		0x177F
    #define API36005_SELF_TEST	0x077F
    #define API36005_CHANNEL_A	0x16BF
    #define API36005_CHANNEL_B	0x06BF
    #define API36005_REF_26		0x05DF
    #define API36005_REF_115	0x15DF
    #define API36005_TRACK		0x14EF
    #define API36005_INHIBIT	0x04EF
    #define API36005_RES_20		0x13F7
    #define API36005_RES_16		0x03F7
    #define API36005_RESOLVER	0x12FB
    #define API36005_SYNCHRO	0x02FB
    #define API36005_45_DEGREE	0x00FC
    #define API36005_ll_118		0x10FC
    #define API36005_ll_26		0x20FC
    #define API36005_ll_90		0x30FC
     
     
    /*  COMMAND DEFINITION BIT MAP
    	   0 :  00  :    0 : 0000
    	BITS : NEW  : REG# : POSITION */
     
    #define SIM36010_ENABLE						0x25 /* WRITE */
    #define SIM36010_DISABLE					0x05 /* WRITE */
    #define SIM36010_115V						0x24 /* WRITE */
    #define SIM36010_26V						0x04 /* WRITE */
    #define SIM36010_CONNECT					0x23 /* WRITE */
    #define SIM36010_DISCONNECT					0x03 /* WRITE */
    #define SIM36010_RESOLVER					0x22 /* WRITE */
    #define SIM36010_SYNCHRO					0x02 /* WRITE */
    #define SIM36010_118						0x80 /* WRITE */
    #define SIM36010_26							0xC0 /* WRITE */
    #define SIM36010_90							0xE0 /* WRITE */
    #define SIM36010_SPEED_ON					0x33 /* WRITE */
    #define SIM36010_SPEED_OFF					0x13 /* WRITE */
    #define SIM36010_RATE_INTERNAL				0x32 /* WRITE */
    #define SIM36010_RATE_EXTERNAL				0x12 /* WRITE */
    #define SIM36010_RANGE_HI					0x31 /* WRITE */
    #define SIM36010_RANGE_LO					0x11 /* WRITE */
    #define SIM36010_REF_INTERNAL				0x30 /* WRITE */
    #define SIM36010_REF_EXTERNAL				0x10 /* WRITE */
     
    // Device type           -- in the "User Defined" range."
    #define GPD_TYPE 40000
     
    // The IOCTL function codes from 0x800 to 0xFFF are for customer use.
     
    #define IOCTL_GPD_READ_PORT_UCHAR \
        CTL_CODE( GPD_TYPE, 0x900, METHOD_BUFFERED, FILE_READ_ACCESS )
     
    #define IOCTL_GPD_READ_PORT_USHORT \
        CTL_CODE( GPD_TYPE, 0x901, METHOD_BUFFERED, FILE_READ_ACCESS )
     
    #define IOCTL_GPD_READ_PORT_ULONG \
        CTL_CODE( GPD_TYPE, 0x902, METHOD_BUFFERED, FILE_READ_ACCESS )
     
    #define IOCTL_GPD_WRITE_PORT_UCHAR \
        CTL_CODE(GPD_TYPE,  0x910, METHOD_BUFFERED, FILE_WRITE_ACCESS)
     
    #define IOCTL_GPD_WRITE_PORT_USHORT \
        CTL_CODE(GPD_TYPE,  0x911, METHOD_BUFFERED, FILE_WRITE_ACCESS)
     
    #define IOCTL_GPD_WRITE_PORT_ULONG \
        CTL_CODE(GPD_TYPE,  0x912, METHOD_BUFFERED, FILE_WRITE_ACCESS)
     
    	// LabWindows CVI want a name after the union (PortNum)
    #ifdef _CVI_
    typedef struct  _GENPORT_WRITE_INPUT {
        ULONG   PortNumber;     // Port # to write to
        union   {               // Data to be output to port
            ULONG   LongData;
            USHORT  ShortData;
            UCHAR   CharData;
        } PortNum;				// <-- Named union
    }   GENPORT_WRITE_INPUT;
    #endif
     
    	// Microsoft doesn't want the name after the union
    #ifndef _CVI_	
    typedef struct  _GENPORT_WRITE_INPUT {
        ULONG   PortNumber;     // Port # to write to
        union   {               // Data to be output to port
            ULONG   LongData;
            USHORT  ShortData;
            UCHAR   CharData;
        };						// <-- No name
    }   GENPORT_WRITE_INPUT;
    #endif
     
    #ifdef __cplusplus
    }
    #endif

  14. #14
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    En tous cas merci de passer du temps a essayer de resoudre mon probleme

    je te joins aussi mon programme:

    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
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
     
    ////////////////////////////////////////////
    // emulateur AOA application for SB3620x card
    ////////////////////////////////////////////
     
    //#include <cstdlib>
    #include <fstream>
    #include <iostream>
    #include "synchro.h"	// Header file for Synchro library//
    //#include <conio.h>		// Needed for kbhit()
     
    using namespace std;
     
    #define size 4251
     
    int		Card=10;		// Card number (0-7) obtained from the			
    int		Channel=1;		// Current channel (0-3) on the 3622x card
    char*	CardType = NULL ;		// Type of card, obtained from Synchro Manager
    char*	VersionNumber="1.0.5";	// Version Number of this file
     
     
    int main()
    {
                      /*************************/    
                      /* Déclaration variables*/   
                      /************************/ 
    	int		MenuOption = 99;	// Start with an invalid menu option
    	char*	DLLVersion = NULL;
    	int     Valid;
     
    	int		Channel;		// Channel to write to
    	char	CharChannel[80];// String to store the user-entered channel
        char	CharAngle[80];	// String to store the user-entered angle
        float	DecimalAngle;	// Angle converted from String to Double
    	WORD	Angle_;			// Synchro Binary angle written to card
     
    	int     Mode;				// Start or Stop the channel
    	char    CharMode[80];		// String to store the user-entered mode
    	int	    Reference;			// Reference value to write to the card
    	char    CharReference[80];	// String to store the user-entered Reference value
     
     
        //Variable pour lecture *.txt
        WORD buffer[size];
        int i;
     
                      /**********************************************/    
                      /* Lecture tableau valeurs binaires de l'angle*/   
                      /**********************************************/ 
     
        ifstream file("binary_model.txt");
     
        if(!file.is_open())
        {
            cout<<"Impossible d'ouvrir le fichier en lecture !"<<endl;
        }
        else
        {
            for(i=0; i<size; i++)
            {file>>buffer[i];}
        }
        file.close();
     
    //Verif lecture fichier *.txt
    for(i=0;i<14;i++)
    {cout <<buffer[i] <<endl;}
    /******************************************************************************/
     
     
                      /*********************************/    
                      /* Initialisation utilisation DLL*/   
                      /*********************************/ 
     
    // Charger la DLL en mémoire
    HINSTANCE load_lib = LoadLibrary("synchro.dll" );
     
    // Déclarer un type de la fonction
    typedef char* (GET_CARD_TYPE)(int);
    typedef char* (INITIALIZE) (int);
    typedef char* (GET_DLL_VERSION) (void);
    typedef void (CLOSE) (int);
    typedef void (CLEAR_ALL) (int, int);
    typedef void (PROGRAM_ANGLE) (int, int, WORD);
    typedef void (PROGRAM_AMPLITUDE) (int, int);
    typedef void (PROGRAM_FREQUENCY) (int, int);
     
    // Déclarer les fonctions de la DLL
    GET_CARD_TYPE *Get_Card_Type;
    INITIALIZE *Initialize;
    GET_DLL_VERSION *Get_DLL_Version;
    CLOSE *Close;
    CLEAR_ALL *Clear_All;
    PROGRAM_ANGLE *Program_Angle;
    PROGRAM_AMPLITUDE *Program_Amplitude;
    PROGRAM_FREQUENCY* Program_Frequency;
     
    // Récupérer l'adresse des fonctions en DLL
    Get_Card_Type = (GET_CARD_TYPE *) GetProcAddress(load_lib, "Get_Card_Type" );
    Initialize = (INITIALIZE *) GetProcAddress(load_lib, "Initialize" );
    Get_DLL_Version = (GET_DLL_VERSION *) GetProcAddress(load_lib, "Get_DLL_Version" );
    Close = (CLOSE *) GetProcAddress(load_lib, "Close" );
    Clear_All = (CLEAR_ALL *) GetProcAddress(load_lib, "Clear_All" );
    Program_Angle = (PROGRAM_ANGLE *) GetProcAddress(load_lib, "Program_Angle" );
    Program_Amplitude = (PROGRAM_AMPLITUDE *) GetProcAddress(load_lib, "Program_Amplitude" );
    Program_Frequency = (PROGRAM_FREQUENCY *) GetProcAddress(load_lib, "Program_Frequency" );
     
    /******************************************************************************/
     
                      /*************************************/    
                      /* Initialisation, Choix de la carte */   
                      /*************************************/    
        Valid=0;
    	while (Valid==0)	// Loop until valid card number
    	{      
    	       printf("\n Which card do you want to write to? ");			// Get the card number (from Synchro Manager)
    	       scanf("%d",&Card);
     
               CardType = (*Get_Card_Type)(Card); // Verify that the card is actually an SB3620x
     
    		   CardType = "[PCI]SB3620x";         //TEST
     
    	       if (strncmp(CardType,"[PCI]SB3620x",12)!=0) 	// If card selected is not SB3620x, alert the user
    	       {																
    		           printf("\n Card Type is %s.  Please select a SB3620x.\n",CardType); }		      
                }
    	        else
    	        {
                      Valid = 1;
                }
        }
     
    	(*Initialize)(Card);				// Otherwise, Initialize selected card
    	DLLVersion = (*Get_DLL_Version)();	// Get dll version, so we can display it on the screen
     
    	printf("\n DDC SB-3620x Sample Application  Version: %s   DLL Version: %s ",VersionNumber,DLLVersion);
    	Sleep(1000);
     
     
                      /*************************************/    
                      /*        Option choix action        */   
                      /*************************************/  
     
    	while (MenuOption != 0)				// Loop until done
    	{
            printf("\n \n-----------------------------------------\n");
    		printf("           D/R Channels 1 and 2    \n");
    		printf("(1)  Write Angle tab   \n");
    		printf("(2)  Clear All      \n");
    		printf("(3) Program Reference Circuit    \n");
    		printf("(0) Exit  \n");
     
    		printf("\n Please Enter an Option :  ");
    		scanf("%d",&MenuOption);
     
    		switch (MenuOption)		// Branch to chosen subroutine
    		{
    			case 1:	//WriteAngle()			
     
    	            Valid=0;		// Makes sure everything is OK
    	            while (Valid==0)	// Loops until channel is OK
    	            {
    		              printf("\n Which Channel do you want to write to 1->COARSE  or 2->FINE)? ");// Ask for input
    		              scanf("%s",&CharChannel);	// Put data into a String for error checking.  If user enters
    		              sscanf(CharChannel,"%d",&Channel);// bad data, this will handle it during conversion to integer.
     
    		              if ((Channel < 1)||(Channel > 2))
    		              {
    			             printf("\n Invalid Channel.  1 or 2 are valid Channels.\n ");
    		              }
    		              else	// Channel is OK
    		              {		
    			             printf("Writing to Channel %d \n",Channel);
    			             Valid=1;	// Valid Channel
    		              }
    	            }
     
                    printf(" phase d'ecriture de l'angle ... ");
     
                    for(j=0; j<size; j++)
                    {
                           printf("\ntest, j= %d",j);
                           (*Program_Angle)(Card,(Channel-1),buffer[j]);	// Write angle to card  
                           Sleep(3000);
                    }       
    	            system("PAUSE");
    			break;
     
     
    			case 2:  //(Clear all)
    				(*Clear_All)(Card, 0);	// Write data to card
    			break;
     
     
    			case 0:
    				(*Close)(Card); // Close the card properly when finished
    			break;
     
     
     
    			default :
    				printf("\n Invalid Option\n");
    				Sleep(1000);
    			break;
    		}
    	}
     
    	(*Close)(Card);	// Close the card properly when finished
     
     
     
    // On décharge la DLL de la mémoire.
     FreeLibrary( load_lib );
     
    }

  15. #15
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    typedef void (WINAPI *PROGRAM_ANGLE) (int, int, WORD);
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  16. #16
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Question bête : as-tu confiance dans ta DLL ? Ne serait-ce pas elle qui est buggée ?
    Autre question : dans la doc, as-tu le droit d'enchaîner les Program_Angle ? Pourquoi le Sleep(3000) ? Il n'y aurait pas un acquittement à attendre ?

  17. #17
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    Ca a l'air de marcher a premiere vue

    Je vous benit !!!!!

    Enfin je prend des precossion parce que la je n'ai plus la carte avant cet aprem, donc j'ai tester sur mon PC mais sans carte.

    Tu pourrais m'expliquer ca sert a quoi ce WINAPI ??

  18. #18
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    C'est vrai que dans la doc ce n'est pas préciser si j'ai el droit d'enchainer des Program_Angle ou pas.

    j'ai mis sleep(3000) pour la phase de test tout comme j'aurais put mettre un autre valeur de sleep.

    Je fairais des tests sur la carte cet aprem et je vous tiens au courant !!

  19. #19
    Rédacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Points : 13 017
    Points
    13 017
    Par défaut
    Citation Envoyé par chris069 Voir le message
    Tu pourrais m'expliquer ca sert a quoi ce WINAPI ??
    C'est une convention d'appel. #define WINAPI __stdcall.
    J'ai honte de ne pas y avoir pensé tout de suite

  20. #20
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    64
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 64
    Points : 35
    Points
    35
    Par défaut
    Bon alors si toi ta honte de ne pas y'avoir penser, qu'est ce que je dois ressentir moi de meme pas etre au courant que ca existait lol !!

    (Merci encore en tout cas pour ton aide )

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Réponses: 2
    Dernier message: 27/09/2013, 09h40
  2. Exception dans kernel32.dll qui freeze mon programme
    Par Chekov dans le forum Général Dotnet
    Réponses: 1
    Dernier message: 30/03/2009, 13h59
  3. Réponses: 3
    Dernier message: 01/03/2009, 18h09
  4. Réponses: 13
    Dernier message: 02/11/2006, 15h12
  5. Réponses: 12
    Dernier message: 16/03/2004, 14h21

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