User: alciro    User
 Original    Translate to:  Deutsch  English  Français  中文  
 

Programación en C++ Builder

 Tableaux (tableaux)
 Pointeurs
3. Exemple de la classe en c + +
8. méthodes de la classe AnsiString
 C + +
 Paquets, de distribuer une application sans installation
 Exchange ou le tri des bulles
 Fonctions de chaîne string.h

9. Communications série RS-232

Borland C + + Builder ne contient aucun objet ou le contrôle pour la communication RS232, il faut donc trouver des ressources de tiers pour remplir cette fonction. RS232 de communication série peut être mise en œuvre de différentes façons, vous pouvez accéder aux API de Windows (travail dur et complexe), vous pouvez installer l'ActiveX de Visual Basic Mscomm32.ocx ou vous pouvez utiliser un contrôleur de point pour le constructeur C + +. Dans notre cas nous allons utiliser un petit contrôle Freeware développé par Victor Chen.

Borland C + + Builder Serial Port Composants

Méthodes:

 void Open (); port de communication ouverte

void Close (); port de communication

bool Enabled (); Communications État du port

Donnez votre int (char Buf [], comte DWORD); Donnez votre mémoire tampon de sortie

int Lire (char Buf [], comte DWORD); lire le tampon d'entrée

int InQueCount (); octets nombre ou dans la mémoire tampon d'entrée, -1 = port fermé

int OutQueCount (); nombre ou d'octets dans la mémoire tampon de sortie, -1 = port fermé

void PurgeIn (); Propreté Tampon

void PurgeOut (); sortie Propreté tampon

/ / Fonctions} {Comm échapper
void SetDTRState (bool Etat);
void SetRTSState (bool Etat);
void SetBREAKState (bool Etat);
void SetXONState (bool Etat);
void UpdateDataControlBlock (); 

TComm Propriétés

BaudRate (Bauds)

    br110, BR300, BR600, br1200, br2400, br4800, br9600, br14400, br19200, br38400, br56000, br57600, br115200, br128000, br256000

    DataBits (bits de données)
    da4, Da5, DA6, DA7, DA8,

    DeviceName (nom de port de communication)
    Com1, Com2 ...

    EventChars

    FlowControl (Flow Control)
    fcNone, fcCTS, fcDTR, fcSoftware, fcDefault

    MonitorEvents (Contrôle des événements)

    Options
    coParityCheck, coDsrSensitivity, coIgnoreXOff, coErrorChar, coNullStrip

    Parité (Parité)
    Panon, paOdd, paEven, paMark, PASPAC

    ReadBufSize (taille mémoire tampon de lecture)
    4096

    ReadTimeout
    1000

    StopBits (Bits d'arrêt)
    SB10, SB 15, SB20

    SuspendTime
    5

    WriteBufSize (écrire la taille du tampon)
    2048

    WriteTimeout (timeout dans le script)
    1000

    les propriétés du contrôle TComm de RS-232

    Evénements

     / / OnBreak
    void __fastcall TForm1:: Comm1Break (TObject * Sender) {
    
    }
    
    / / OnComStatEvent
    void __fastcall TForm1:: Comm1ComStatEvent (TObject * Sender, de la Condition DWORD, COMSTAT COMSTAT) {
    
    }
    
    / / OnCts
    void __fastcall TForm1:: Comm1Cts (TObject * Sender) {
    
    }
    
    / / OnDsr
    void __fastcall TForm1:: Comm1Dsr (TObject * Sender) {
    
    }
    
    / / OnRing
    void __fastcall TForm1:: Comm1Ring (TObject * Sender) {
    
    }
    
    / / OnRlsd
    void __fastcall TForm1:: Comm1Rlsd (TObject * Sender) {
    
    }
    
    / / OnError
    void __fastcall TForm1:: Comm1Error (TObject * Sender, int erreurs) {
    
    }
    
    / / OnRxChar
    void __fastcall TForm1:: Comm1RxChar (TObject * Sender, DWORD Count) {
    
    }
    
    / / OnRxFlag;
    void __fastcall TForm1:: Comm1RxFlag (TObject * Sender) {
    
    }
    
    / / OnTxEmpty;
    void __fastcall TForm1:: Comm1TxEmpty (TObject * Sender) {
    
    } 

    Indicateurs:

     bool Connected = {read = FConnected};
    
    / Indicateurs d'état /} {Comm
    bool CTS = {index = 1, lire = GetModemState};
    DSR bool = {index = 2, lu = GetModemState};
    RING bool = {index = 3, lire = GetModemState};
    bool RLSD = {indice = 4, lu = GetModemState};
    bool CtsHold = {index = 1, lire = GetComState};
    bool DsrHold = {index = 2, lu = GetComState};
    bool RlsdHold = {index = 3, lire = GetComState};
    bool XOffHold = {indice = 4, lu = GetComState};
    bool XOffSent = {indice = 5, lu = GetComState};
    __property Poignée = {read = FHandle}; 
    RS événements de contrôle TComm-232 communications
    Loading
    copyright © 2007-2024  www.alciro.org  All rights reserved.         
    Share |