1 pièce(s) jointe(s)
Lecture Port Serie - Arduino
Bonjour, j'ai un problème au niveau de la lecture de "string" depuis mon arduino nano, en passant par le port serie COM6. Voici sur un terminal (CoolTerm) ce que mon Arduino envoie :
voici mon code :
Code:
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
| Public Class Form1
Dim InstantMoment1 As String = String.Empty
Dim InstantMoment2 As String = String.Empty
Dim returnStr As String = String.Empty
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GetStatus()
End Sub
Private Sub ParametresToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ParametresToolStripMenuItem.Click
Form2.Show()
End Sub
Private Sub ConnectionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ConnectionToolStripMenuItem.Click
Try
SerialPort1.Open()
InstantMoment1 = Format(Now, "hh:mm:ss")
RichTextBox1.AppendText("--- Connecté au port " & SerialPort1.PortName & " à " & InstantMoment1 & ". ---" & vbNewLine)
Catch
If Err.Description.ToString.Contains("existe pas") Then
RichTextBox1.AppendText("--- Le port " & SerialPort1.PortName & " n'es pas disponible. ---" & vbNewLine)
Else
RichTextBox1.AppendText("--- " & Err.Description.ToString & " ---" & vbNewLine)
End If
End Try
GetStatus()
End Sub
Function GetStatus()
If SerialPort1.IsOpen = True Then
ToolStripStatusLabel2.Text = "Connecté."
Else
ToolStripStatusLabel2.Text = "IDLE."
End If
Return Nothing
End Function
Private Sub DeconnexionToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DeconnexionToolStripMenuItem.Click
SerialPort1.Close()
InstantMoment2 = Format(Now, "hh:mm:ss")
RichTextBox1.AppendText("--- Déconnecté du port " & SerialPort1.PortName & " à " & InstantMoment2 & ". ---" & vbNewLine)
GetStatus()
End Sub
Private Sub ClearToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ClearToolStripMenuItem.Click
RichTextBox1.Clear()
End Sub
Private Sub DebugModeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DebugModeToolStripMenuItem.Click
End Sub
End Class |
Voila, je ne sais pas comment afficher les 2 phrases dans ma richtextbox (terminal).
Merci de votre aide.
Cordialement,
Juaaah.