lucgabon
Messages postés3Date d'inscriptiondimanche 21 janvier 2007StatutMembreDernière intervention17 juin 2007
-
13 juin 2007 à 20:23
lucgabon
Messages postés3Date d'inscriptiondimanche 21 janvier 2007StatutMembreDernière intervention17 juin 2007
-
17 juin 2007 à 10:48
je viens de débuter en VB, je cherche simplement pour l'instant d'afficher les bytes qui vienent sur le port com3 dans n RichTextBox
j'envoie sur le port rs232 des série de 17 bytes donc le premier et $FF
Merci pour vos réponse
Public Class FormBoeBot
Private Sub ButtonGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGo.Click
If LedGo.BackColor = Color.SandyBrown Then
LedGo.BackColor = Color.OrangeRed
Else
LedGo.BackColor = Color.SandyBrown
End If
End Sub
Private Sub SerialPortBoeBot_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPortBoeBot.DataReceived
While SerialPortBoeBot.BytesToRead > 0
RichTextBoxRS232.Text &= SerialPortBoeBot.ReadChar()
End While
End Sub
Private Sub FormBoeBot_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPortBoeBot.Open()
MsgBox("OK", MsgBoxStyle.Information)
End Sub
Private Sub FormBoeBot_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Leave
SerialPortBoeBot.Close()
End Sub
lucgabon
Messages postés3Date d'inscriptiondimanche 21 janvier 2007StatutMembreDernière intervention17 juin 2007 17 juin 2007 à 10:48
voici mon nouveau code
Public Class FormBoeBot
Private Sub ButtonGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGo.Click
If LedGo.BackColor = Color.SandyBrown Then
LedGo.BackColor = Color.OrangeRed
Else
LedGo.BackColor = Color.SandyBrown
End If
End Sub
Private Sub SerialPortBoeBot_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPortBoeBot.DataReceived
While SerialPortBoeBot.BytesToRead > 0
RichTextBoxRS232.Text &= SerialPortBoeBot.ReadChar()
End While
End Sub
Private Sub FormBoeBot_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'initialise Timer
EchRS232.Interval = 1000
EchRS232.Start()
'initialise le port Com
SerialPortBoeBot.BaudRate = 9600
SerialPortBoeBot.PortName = "COM3"
SerialPortBoeBot.DataBits = 8
SerialPortBoeBot.StopBits = IO.Ports.StopBits.One
SerialPortBoeBot.Parity = IO.Ports.Parity.None
SerialPortBoeBot.Handshake = IO.Ports.Handshake.None
SerialPortBoeBot.Open()
End Sub
Private Sub FormBoeBot_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Leave
SerialPortBoeBot.Close()
End Sub
Private Sub EchRS232_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EchRS232.Tick
LedRx.BackColor = Color.Green
RichTextBoxRS232.Text &= "Lecture " & SerialPortBoeBot.BytesToRead & Chr(13)
While SerialPortBoeBot.BytesToRead > 0
RichTextBoxRS232.Text &= Chr(SerialPortBoeBot.ReadChar())
End While
LedRx.BackColor = Color.PaleGreen
EchRS232.Start()
End Sub
End Class
et voici ce que j'obtien dans la fenetre RichTextBox