- ' 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