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

API, COM et SDKs Delphi Discussion :

Fonctionnement du composant TComPort


Sujet :

API, COM et SDKs Delphi

  1. #1
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2015
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 131
    Points : 46
    Points
    46
    Par défaut Fonctionnement du composant TComPort
    bonjour,
    voila j'ai un code source qui est fait en delphi qui réalise une communication entre l'interface delphi et une commande d'axe MCS. connecter avec un port série.

    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
     
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, CPort, ComCtrls, Buttons, CPortCtl, ExtCtrls;
     
    type
      TForm1 = class(TForm)
        ComPort1: TComPort;
        ProgressBar1: TProgressBar;
        GroupBox1: TGroupBox;
        BitBtn1: TBitBtn;
        BitBtn2: TBitBtn;
        Bevel1: TBevel;
        ComLed1: TComLed;
        ComLed2: TComLed;
        Label1: TLabel;
        Label2: TLabel;
        StatusBar1: TStatusBar;
        Bevel2: TBevel;
        ListBox1: TListBox;
        BitBtn3: TBitBtn;
        Edit1: TEdit;
        BitBtn4: TBitBtn;
        BitBtn5: TBitBtn;
        GroupBox2: TGroupBox;
        OpenDialog1: TOpenDialog;
        SaveDialog1: TSaveDialog;
        BitBtn6: TBitBtn;
        Bevel3: TBevel;
        ListBox2: TListBox;
        Edit2: TEdit;
        Bevel4: TBevel;
        BitBtn7: TBitBtn;
        BitBtn8: TBitBtn;
        ComPort2: TComPort;
        ComLed4: TComLed;
        ComLed5: TComLed;
        ComLed6: TComLed;
        ProgressBar3: TProgressBar;
        Label4: TLabel;
        Label5: TLabel;
        Label6: TLabel;
        ProgressBar2: TProgressBar;
        Image1: TImage;
        Label3: TLabel;
        ComComboBox1: TComComboBox;
        ComComboBox2: TComComboBox;
        ComLed3: TComLed;
        ProgressBar4: TProgressBar;
        BitBtn9: TBitBtn;
        BitBtn10: TBitBtn;
        procedure ComPort1RxFlag(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure BitBtn1Click(Sender: TObject);
        procedure BitBtn2Click(Sender: TObject);
        procedure BitBtn3Click(Sender: TObject);
        procedure ListBox1Click(Sender: TObject);
        procedure BitBtn4Click(Sender: TObject);
        procedure BitBtn5Click(Sender: TObject);
        procedure BitBtn7Click(Sender: TObject);
        procedure ListBox2Click(Sender: TObject);
        procedure BitBtn9Click(Sender: TObject);
        procedure BitBtn10Click(Sender: TObject);
        procedure BitBtn8Click(Sender: TObject);
        procedure ComPort2RxFlag(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
      i,nboucles : integer;
      tampon : integer;
      a,b,c,d,e,f,g,h,j : string;
      car,paquet : string;
      chaine : widestring;
     
    implementation
     
    {$R *.DFM}
     
    procedure TForm1.ComPort1RxFlag(Sender: TObject);
    begin
    if (tampon)<=128977 then   //128876
    begin
         while tampon<101*nboucles do
               tampon := comport1.inputcount;
         progressbar1.StepIt;
         statusbar1.simpletext:=formatfloat('##0',(tampon*100/101)/127800*100)+'% Transférés';
         comport1.writestr(chr(13));
         nboucles:=nboucles+1;
         tampon := comport1.inputcount;
    end
    else
    begin
         statusbar1.SimpleText:='Transfert Terminé';
    end;
    end;
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    nboucles:=1;
    tampon := 0;
    chaine := '';
    end;
     
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
    if comport2.connected=true then
    begin
    comport2.clearbuffer(true,true);
    comport2.connected:=false;
    end;
    comport1.connected:=true;
    comport1.clearbuffer(true,true);
    statusbar1.simpletext:='Connecté...';
    end;
     
    procedure TForm1.BitBtn2Click(Sender: TObject);
    begin
    listbox1.Clear;
    statusbar1.SimpleText:='Appuyez sur "F6" de la commande numérique puis patientez...';
    comport1.writestr(chr(13));
    end;
     
    procedure TForm1.BitBtn3Click(Sender: TObject);
    begin
    statusbar1.simpletext:='Ecriture du programme en cours; Patientez s.v.p...';
    for i:=1 to 1278 do
    begin
         comport1.readstr(car,1);
         comport1.readstr(paquet,100);
         chaine := chaine + paquet;
         progressbar2.stepit;
    end;
    for i:=0 to 14199 do
    begin
    a:=chaine[i*9+1];
    b:=chaine[i*9+2];
    c:=chaine[i*9+3];
    d:=chaine[i*9+4];
    e:=chaine[i*9+5];
    f:=chaine[i*9+6];
    g:=chaine[i*9+7];
    h:=chaine[i*9+8];
    j:=chaine[i*9+9];
    listbox1.items.add(a+b+c+d+e+f+g+h+j);
    end;
    statusbar1.simpletext:='Terminé.';
    chaine := '';
    end;
     
    procedure TForm1.ListBox1Click(Sender: TObject);
    begin
    edit1.text:=inttostr(listbox1.itemindex);
    end;
     
    procedure TForm1.BitBtn4Click(Sender: TObject);
    begin
    if savedialog1.execute then
    listbox1.items.savetofile(savedialog1.filename+'.pcn');
    end;
     
    procedure TForm1.BitBtn5Click(Sender: TObject);
    begin
    chaine := '';
    if opendialog1.execute then
    listbox2.items.loadfromfile(opendialog1.filename);
    statusbar1.simpletext:='Chargement du fichier...';
    for i:=0 to 14199 do
    begin
    chaine:=chaine+listbox2.Items[i];
    progressbar4.stepit;
    end;
    statusbar1.SimpleText:='Fichier chargé.';
    end;
     
    procedure TForm1.BitBtn7Click(Sender: TObject);
    begin
    if listbox2.items.count=14200 then
    begin
       if comport1.connected=true then
       begin
          comport1.clearbuffer(true,true);
          comport1.connected:=false;
       end;
    comport2.Connected:=true;
    comport2.clearbuffer(true,true);
    statusbar1.SimpleText:='Connecté...';
    end
    else
    showmessage('Impossible de se connecter : Le programme à envoyer est incomplet');
    end;
     
    procedure TForm1.ListBox2Click(Sender: TObject);
    begin
    edit2.text:=inttostr(listbox2.ItemIndex);
    end;
     
    procedure TForm1.BitBtn9Click(Sender: TObject);
    var
    tampon : string;
    begin
    comport2.readstr(tampon,comport2.inputcount);
    comport2.ClearBuffer(true,true);
    comport2.connected:=false;
    statusbar1.simpletext:='Déconnecté.';
    end;
     
    procedure TForm1.BitBtn10Click(Sender: TObject);
    var
    tampon : string;
    begin
    comport1.readstr(tampon,comport1.inputcount);
    comport1.ClearBuffer(true,true);
    comport1.connected:=false;
    statusbar1.simpletext:='Déconnecté.'
    end;
     
    procedure TForm1.BitBtn8Click(Sender: TObject);
    begin
    nboucles:=0;
    statusbar1.SimpleText:='Appuyez sur "F6" de la commande numérique puis patientez...';
    comport2.writestr(chr(10));
    end;
     
    procedure TForm1.ComPort2RxFlag(Sender: TObject);
    begin
    if nboucles<=1278 then
    begin
         paquet:='';
         for i:=1 to 100 do
             paquet := paquet + chaine[i+100*nboucles];
         nboucles:=nboucles+1;
         progressbar3.stepit;
         statusbar1.SimpleText:=formatfloat('##0',nboucles/1278*100)+'% Transférés';
         comport2.writestr(paquet);
    end
    else
    statusbar1.simpletext:='Transfert terminé.';
    end;
     
    end.
    voila l'interface :

    Nom : Capture.PNG
Affichages : 1246
Taille : 12,2 Ko

    pouvez-vous m'explique le code en détail ?
    ça fait 2 semaine que j'essaye de comprendre mais j'arrive pas, vu que je maîtrise pas trop ?

    dans mon projet que je réalise il me demande de faire la même chose avec le même matériel mais avec un autre langage, donc je suis parti sur le langage vb.net, et la j'ai vraiment besoin de comprendre ce code pour pouvoir avancer dans ma réalisation.

  2. #2
    Membre averti Avatar de pascalCH
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Juillet 2006
    Messages
    187
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 66
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Juillet 2006
    Messages : 187
    Points : 369
    Points
    369
    Par défaut
    Bonjour,

    il manque un fichier essentiel : unit1.dfm qui contient la définition de l'interface et la déclaration des événements.

    sinon, pas de bol, c'est codé "avec les pieds" .. bouton1, bouton2 ...comment on s'y retrouve

    sinon, a mon sens, tant qu'a faire changer de langage, prend plutot du C# plus proche du delphi
    La nature fait des choses extraordinaires, observons la et restons humble, on ne nous demande pas de refaire le monde mais juste de reproduire virtuellement des choses existantes ....

    et n'oubliez pas si vous aimez et quand vous avez la réponse

  3. #3
    Membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2015
    Messages
    131
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : France, Sarthe (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 131
    Points : 46
    Points
    46
    Par défaut
    bonjour,
    oui si ça le souci, j'ai télécharger Delphi rien que pour l'ouvrir mais ça marche pas j'ai réussi juste a voir que ce code.
    cette interface est faite de puis bien longtemps sous windows 98.

    voila le code de fichier .dfm

    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
     
    object Form1: TForm1
      Left = 161
      Top = 143
      BorderIcons = [biSystemMenu, biMinimize]
      BorderStyle = bsSingle
      Caption = 'Transfert du Fichier de 128Ko PC<->MCS'
      ClientHeight = 354
      ClientWidth = 556
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Image1: TImage
        Left = 0
        Top = 296
        Width = 217
        Height = 33
        Picture.Data = {
         }
      end
      object GroupBox2: TGroupBox
        Left = 280
        Top = 24
        Width = 273
        Height = 273
        Caption = 'Transfert PC -> MCS'
        TabOrder = 5
        object Bevel3: TBevel
          Left = 8
          Top = 24
          Width = 257
          Height = 129
        end
        object Bevel4: TBevel
          Left = 8
          Top = 160
          Width = 257
          Height = 105
        end
        object ComLed4: TComLed
          Left = 136
          Top = 168
          Width = 25
          Height = 25
          ComPort = ComPort2
          LedSignal = lsConn
          Kind = lkGreenLight
        end
        object ComLed5: TComLed
          Left = 192
          Top = 168
          Width = 25
          Height = 25
          ComPort = ComPort2
          LedSignal = lsRx
          Kind = lkBlueLight
        end
        object ComLed6: TComLed
          Left = 224
          Top = 168
          Width = 25
          Height = 25
          ComPort = ComPort2
          LedSignal = lsTx
          Kind = lkYellowLight
        end
        object Label4: TLabel
          Left = 128
          Top = 192
          Width = 46
          Height = 13
          Caption = 'Connecté'
        end
        object Label5: TLabel
          Left = 200
          Top = 192
          Width = 13
          Height = 13
          Caption = 'Rx'
        end
        object Label6: TLabel
          Left = 232
          Top = 192
          Width = 12
          Height = 13
          Caption = 'Tx'
        end
        object ListBox2: TListBox
          Left = 128
          Top = 32
          Width = 129
          Height = 113
          Color = clBtnFace
          ItemHeight = 13
          TabOrder = 0
          OnClick = ListBox2Click
        end
        object Edit2: TEdit
          Left = 16
          Top = 64
          Width = 105
          Height = 21
          Color = clBtnFace
          ReadOnly = True
          TabOrder = 1
        end
        object BitBtn7: TBitBtn
          Left = 16
          Top = 168
          Width = 105
          Height = 25
          Caption = '2. Connecter'
          TabOrder = 2
          OnClick = BitBtn7Click
          Kind = bkRetry
        end
        object BitBtn8: TBitBtn
          Left = 16
          Top = 200
          Width = 105
          Height = 25
          Caption = '3. Envoyer'
          TabOrder = 3
          OnClick = BitBtn8Click
          Kind = bkOK
        end
        object ProgressBar3: TProgressBar
          Left = 128
          Top = 208
          Width = 126
          Height = 17
          Min = 0
          Max = 1278
          Smooth = True
          Step = 1
          TabOrder = 4
        end
        object ProgressBar4: TProgressBar
          Left = 16
          Top = 88
          Width = 105
          Height = 17
          Min = 0
          Max = 14199
          Smooth = True
          Step = 1
          TabOrder = 5
        end
        object BitBtn9: TBitBtn
          Left = 16
          Top = 232
          Width = 105
          Height = 25
          Caption = '4. Déconnecter'
          TabOrder = 6
          OnClick = BitBtn9Click
          Kind = bkAbort
        end
      end
      object GroupBox1: TGroupBox
        Left = 0
        Top = 24
        Width = 273
        Height = 273
        Caption = 'Transfert MCS -> PC'
        TabOrder = 1
        object Bevel1: TBevel
          Left = 8
          Top = 24
          Width = 257
          Height = 73
        end
        object ComLed1: TComLed
          Left = 136
          Top = 32
          Width = 25
          Height = 25
          ComPort = ComPort1
          LedSignal = lsConn
          Kind = lkGreenLight
        end
        object ComLed2: TComLed
          Left = 192
          Top = 32
          Width = 25
          Height = 25
          ComPort = ComPort1
          LedSignal = lsRx
          Kind = lkBlueLight
        end
        object Label1: TLabel
          Left = 128
          Top = 56
          Width = 46
          Height = 13
          Caption = 'Connecté'
        end
        object Label2: TLabel
          Left = 200
          Top = 56
          Width = 13
          Height = 13
          Caption = 'Rx'
        end
        object Bevel2: TBevel
          Left = 8
          Top = 104
          Width = 257
          Height = 161
        end
        object Label3: TLabel
          Left = 232
          Top = 56
          Width = 12
          Height = 13
          Caption = 'Tx'
        end
        object ComLed3: TComLed
          Left = 224
          Top = 32
          Width = 25
          Height = 25
          LedSignal = lsTx
          Kind = lkYellowLight
        end
        object BitBtn1: TBitBtn
          Left = 16
          Top = 32
          Width = 105
          Height = 25
          Caption = '1. Connecter'
          TabOrder = 0
          OnClick = BitBtn1Click
          Kind = bkRetry
        end
        object BitBtn2: TBitBtn
          Left = 16
          Top = 64
          Width = 105
          Height = 25
          Caption = '2. Recevoir'
          TabOrder = 1
          OnClick = BitBtn2Click
          Kind = bkOK
        end
        object ListBox1: TListBox
          Left = 128
          Top = 112
          Width = 129
          Height = 145
          Color = clBtnFace
          ItemHeight = 13
          TabOrder = 2
          OnClick = ListBox1Click
        end
        object BitBtn3: TBitBtn
          Left = 16
          Top = 112
          Width = 105
          Height = 25
          Caption = '3. Ecrire Prog.'
          TabOrder = 3
          OnClick = BitBtn3Click
          Kind = bkOK
        end
        object Edit1: TEdit
          Left = 16
          Top = 168
          Width = 105
          Height = 21
          Color = clBtnFace
          ReadOnly = True
          TabOrder = 4
        end
        object ProgressBar2: TProgressBar
          Left = 16
          Top = 144
          Width = 105
          Height = 17
          Min = 0
          Max = 1277
          Smooth = True
          Step = 1
          TabOrder = 5
        end
        object BitBtn10: TBitBtn
          Left = 16
          Top = 200
          Width = 105
          Height = 25
          Caption = '4. Déconnecter'
          TabOrder = 6
          OnClick = BitBtn10Click
          Kind = bkAbort
        end
      end
      object ProgressBar1: TProgressBar
        Left = 128
        Top = 96
        Width = 129
        Height = 17
        Min = 0
        Max = 127700
        Smooth = True
        Step = 100
        TabOrder = 0
      end
      object StatusBar1: TStatusBar
        Left = 0
        Top = 335
        Width = 556
        Height = 19
        Panels = <>
        ParentShowHint = False
        ShowHint = True
        SimplePanel = False
      end
      object BitBtn4: TBitBtn
        Left = 16
        Top = 256
        Width = 105
        Height = 25
        Caption = '5. Sauvegarder'
        TabOrder = 2
        OnClick = BitBtn4Click
      end
      object BitBtn5: TBitBtn
        Left = 296
        Top = 56
        Width = 105
        Height = 25
        Caption = '1. Charger'
        TabOrder = 3
        OnClick = BitBtn5Click
      end
      object BitBtn6: TBitBtn
        Left = 448
        Top = 304
        Width = 105
        Height = 25
        Caption = '&Quitter'
        TabOrder = 6
        Kind = bkClose
      end
      object ComComboBox1: TComComboBox
        Left = 0
        Top = 0
        Width = 113
        Height = 21
        ComPort = ComPort1
        ComProperty = cpPort
        AutoApply = True
        Text = 'COM1'
        Style = csDropDownList
        Color = clBtnFace
        ItemHeight = 13
        ItemIndex = 0
        TabOrder = 7
      end
      object ComComboBox2: TComComboBox
        Left = 280
        Top = 0
        Width = 113
        Height = 21
        ComPort = ComPort2
        ComProperty = cpPort
        AutoApply = True
        Text = 'COM1'
        Style = csDropDownList
        Color = clBtnFace
        ItemHeight = 13
        ItemIndex = 0
        TabOrder = 8
      end
      object ComPort1: TComPort
        BaudRate = br9600
        Port = 'COM1'
        Parity.Bits = prEven
        Parity.Check = True
        StopBits = sbOneStopBit
        DataBits = dbEight
        EventChar = #13
        Events = [evRxChar, evTxEmpty, evRxFlag, evRing, evBreak, evCTS, evDSR, evError, evRLSD, evRx80Full]
        Buffer.InputSize = 159750
        Buffer.OutputSize = 159750
        FlowControl.OutCTSFlow = False
        FlowControl.OutDSRFlow = False
        FlowControl.ControlDTR = dtrDisable
        FlowControl.ControlRTS = rtsDisable
        FlowControl.XonXoffOut = False
        FlowControl.XonXoffIn = False
        OnRxFlag = ComPort1RxFlag
        Left = 184
        Top = 224
      end
      object OpenDialog1: TOpenDialog
        Left = 496
        Top = 120
      end
      object SaveDialog1: TSaveDialog
        Left = 216
        Top = 224
      end
      object ComPort2: TComPort
        BaudRate = br9600
        Port = 'COM1'
        Parity.Bits = prEven
        Parity.Check = True
        StopBits = sbOneStopBit
        DataBits = dbEight
        EventChar = #10
        Events = [evRxChar, evTxEmpty, evRxFlag, evRing, evBreak, evCTS, evDSR, evError, evRLSD, evRx80Full]
        Buffer.InputSize = 159750
        Buffer.OutputSize = 159750
        FlowControl.OutCTSFlow = False
        FlowControl.OutDSRFlow = False
        FlowControl.ControlDTR = dtrDisable
        FlowControl.ControlRTS = rtsDisable
        FlowControl.XonXoffOut = False
        FlowControl.XonXoffIn = False
        OnRxFlag = ComPort2RxFlag
        Left = 456
        Top = 128
      end
    end
    ce que j'ai réussi a déchiffrée que:

    quand tu choisi l’interface MCS=> PC:
    tu branche le port com sur le pc il s'affiche dans la bar d'en haut, puis quand tu Click sur connecter il y a la led qui s'allume.
    quand tu Click sur recevoir il attend que tu Click sur F6 dans MCS pour commencer le transféré et il y a la led Rx qui s'allume.

  4. #4
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 419
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 419
    Points : 5 818
    Points
    5 818
    Par défaut
    salut

    effectivement c'est pas tres clair comme code
    bon alors la premiere chose a savoir
    c'est que le composant COMPORT2 sert a la communication dans le sens PC->MCS
    et le COMPORT1 sert a la communication dans le sens MCS->PC

    le but est de, soit lire la lisbox2, soit de remplir la listebox1
    dans tout les cas la listbox doit comporter 14200 ligne

    le transfert doit se faire par paquet de 100 caractère
    le nombre total de boucle est de 1278
    ce qui nous fait un transfert de 1278*100 octet environs

    pour les listebox tu as 14200 ligne de 9 caractère
    donc 14200*9 = 127800 = 1278*100
    Nous souhaitons la vérité et nous trouvons qu'incertitude. [...]
    Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
    Blaise Pascal
    PS : n'oubliez pas le tag

  5. #5
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Bonjour !

    La bibliothèque ComPort est livrée avec un fichier d'aide : ça peut servir.

    Télécharger la bibliothèque ComPort

    Il y a aussi un tutoriel en français :

    Utilisation de TComPort

    Bonne continuation !
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

Discussions similaires

  1. Installer le composant TComPort sous Delphi5
    Par GI_GI dans le forum Composants VCL
    Réponses: 19
    Dernier message: 03/09/2008, 08h07
  2. Réponses: 2
    Dernier message: 15/09/2007, 18h04
  3. Réponses: 2
    Dernier message: 03/09/2006, 10h03
  4. pb de lieur à la compilation avec le composant TComPort
    Par Revan777 dans le forum C++Builder
    Réponses: 3
    Dernier message: 16/01/2006, 17h20
  5. installation du composant tComport
    Par Duan dans le forum Composants VCL
    Réponses: 2
    Dernier message: 11/09/2005, 05h52

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