Accueil > > > TEST DE COMMUNICATION PC-PC PAR NULL MODEM (PORT SÉRIE RS232)
TEST DE COMMUNICATION PC-PC PAR NULL MODEM (PORT SÉRIE RS232)
Information sur la source
Description
Ceci n'est pas une appli mirrobolante, mais elle a l'avantage de résumer les bases de la communication par port série RS232 entre 2 PCs sous VB6. Assistance technique : câblage d'un "Null Modem" DB9 nécessite deux prises femelles 9 broches _______ \54321/ \9876/ 1 --> 7-8 : DCD vers RTS/CTS 2 <-- 3 : RXD sur TXD 3 --> 2 : TXD vers RXD 5 ---- 5 : Ground sur Ground 7-8 --> 1 : RTS/CTS sur DCD Remarque : Cette appli nécessite : Microsoft Form2.0 Object Library Microsoft Comm Control 6.0
Source
- ' Ce projet est un test de communication entre deux ordinateurs
- ' via un port série RS232.
- ' En connectant un PC à un autre, ce programme permet d'envoyer des
- ' chaînes de 8 caractères maximum.
- ' La configuration des ports est basique : "9600,n,8,1".
-
- ' This project is a communication test between 2 computers on a
- ' RS232 serial port.
- ' After connecting the computers, you can send strings
- ' of 8 characters maximum.
- ' The configuration of ports is classical : "9600,n,8,1".
-
-
-
- ' Il est aussi là à titre d'exemple pour ceux qui s'adonnent à la
- ' communication par port série. On rappellera que ce port sert
- ' essentiellement aujourd'hui pour les modems et les appareils industriels.
-
- ' This software can else be used by those who want to train themselves
- ' on communication with serial port. We can remember that, nowadays,
- ' this port is essentially used for modems and industrials equipements.
-
- 'P S :
- ' Les deux fenêtres des COM 1 et 2 sont identiques en tous points.
- '
- ' The two windows for COM 1 and 2 are exactly the same.
-
- Private Sub Form_Load()
- Comm.InputMode = comInputModeText
- Comm.RThreshold = 1 'permet de gérer l'événement CommEvent : réception
- Comm.SThreshold = 1 'permet de gérer l'événement CommEvent : envoi
- End Sub
-
- Private Sub Comm_OnComm()
-
- ' Cette procédure permet de gérer les événements présents autour et sur le port
- ' Le cas présent, je teste l'envoi, la réception avec l'affichage du contenu du
- ' buffer d'entrée, et l'événement Break de blocage du buffer de sortie.
-
- ' This process work on events in and arround the port. Present case, I test
- ' sending, reception followed by displaying the input buffer, and the event
- ' Break which block the output buffer.
-
- Select Case Comm.CommEvent
- Case 0: Text1.Text = Text1.Text & "Travail terminé" & vbCrLf
- Case 1: Text1.Text = Text1.Text & "Envoi en cours" & vbCrLf
- Case 2: Text1.Text = Text1.Text & "Reception en cours" & vbCrLf
- Text1.Text = Text1.Text & Comm.Input & " -- reçu" & vbCrLf
- Case 1001: Text1.Text = Text1.Text & "Blocage" & vbCrLf
- End Select
- End Sub
-
- Private Sub Command1_Click() 'Bouton Envoyer / Send button
- On Error Resume Next
- Comm.Output = Text2.Text
- End Sub
-
- Private Sub Command2_Click() 'Bouton Ouvrir Port / Open serial button
- Comm.PortOpen = True
- End Sub
-
- Private Sub Command3_Click() 'Bouton Fermer Port / Close serial button
- Comm.PortOpen = False
- End Sub
-
- Private Sub Command4_Click() 'Bouton Break / Break button
- If Comm.PortOpen = True Then
- Select Case Comm.Break
- Case vbFalse
- Comm.Break = True
- Command4.BackColor = vbRed
- Case vbTrue
- Comm.Break = False
- Command4.BackColor = vbGreen
- End Select
- Else
- Comm.Break = False
- Command4.BackColor = vbGreen
- End If
- End Sub
-
- Private Sub Timer1_Timer() 'Une routine de test sur l'état du port / a loopback on testing state of port
- If Comm.PortOpen = True Then
- Label1.Caption = "Ouvert"
- Command2.Enabled = False
- Command3.Enabled = True
- Else
- Label1.Caption = "Fermé"
- Command2.Enabled = True
- Command3.Enabled = False
- End If
- Text3.Text = "OutBuffer : " & Comm.OutBufferCount & " | InputBuffer : " & Comm.InBufferCount
- End Sub
-
-
' Ce projet est un test de communication entre deux ordinateurs
' via un port série RS232.
' En connectant un PC à un autre, ce programme permet d'envoyer des
' chaînes de 8 caractères maximum.
' La configuration des ports est basique : "9600,n,8,1".
' This project is a communication test between 2 computers on a
' RS232 serial port.
' After connecting the computers, you can send strings
' of 8 characters maximum.
' The configuration of ports is classical : "9600,n,8,1".
' Il est aussi là à titre d'exemple pour ceux qui s'adonnent à la
' communication par port série. On rappellera que ce port sert
' essentiellement aujourd'hui pour les modems et les appareils industriels.
' This software can else be used by those who want to train themselves
' on communication with serial port. We can remember that, nowadays,
' this port is essentially used for modems and industrials equipements.
'P S :
' Les deux fenêtres des COM 1 et 2 sont identiques en tous points.
'
' The two windows for COM 1 and 2 are exactly the same.
Private Sub Form_Load()
Comm.InputMode = comInputModeText
Comm.RThreshold = 1 'permet de gérer l'événement CommEvent : réception
Comm.SThreshold = 1 'permet de gérer l'événement CommEvent : envoi
End Sub
Private Sub Comm_OnComm()
' Cette procédure permet de gérer les événements présents autour et sur le port
' Le cas présent, je teste l'envoi, la réception avec l'affichage du contenu du
' buffer d'entrée, et l'événement Break de blocage du buffer de sortie.
' This process work on events in and arround the port. Present case, I test
' sending, reception followed by displaying the input buffer, and the event
' Break which block the output buffer.
Select Case Comm.CommEvent
Case 0: Text1.Text = Text1.Text & "Travail terminé" & vbCrLf
Case 1: Text1.Text = Text1.Text & "Envoi en cours" & vbCrLf
Case 2: Text1.Text = Text1.Text & "Reception en cours" & vbCrLf
Text1.Text = Text1.Text & Comm.Input & " -- reçu" & vbCrLf
Case 1001: Text1.Text = Text1.Text & "Blocage" & vbCrLf
End Select
End Sub
Private Sub Command1_Click() 'Bouton Envoyer / Send button
On Error Resume Next
Comm.Output = Text2.Text
End Sub
Private Sub Command2_Click() 'Bouton Ouvrir Port / Open serial button
Comm.PortOpen = True
End Sub
Private Sub Command3_Click() 'Bouton Fermer Port / Close serial button
Comm.PortOpen = False
End Sub
Private Sub Command4_Click() 'Bouton Break / Break button
If Comm.PortOpen = True Then
Select Case Comm.Break
Case vbFalse
Comm.Break = True
Command4.BackColor = vbRed
Case vbTrue
Comm.Break = False
Command4.BackColor = vbGreen
End Select
Else
Comm.Break = False
Command4.BackColor = vbGreen
End If
End Sub
Private Sub Timer1_Timer() 'Une routine de test sur l'état du port / a loopback on testing state of port
If Comm.PortOpen = True Then
Label1.Caption = "Ouvert"
Command2.Enabled = False
Command3.Enabled = True
Else
Label1.Caption = "Fermé"
Command2.Enabled = True
Command3.Enabled = False
End If
Text3.Text = "OutBuffer : " & Comm.OutBufferCount & " | InputBuffer : " & Comm.InBufferCount
End Sub
Conclusion
Je n'est pas poussé la gestion d'erreurs. Alors, si vous constatez un bug,...vous savez à quelle porte sonner...
Dernière mise à jour: pour ceux qui ne l'on pas, me laisser un message sur le site
PrX
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|