15,902,275 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Dammak Karim (Top 2 by date)
Dammak Karim
29-Apr-22 6:59am
View
Imports System.IO.Ports
Public Class Form1
Dim dataIN As String
Dim dataOUT As String
Private Delegate Sub AccesDelegue(ByVal AjouterText As String)
Private Sub AccesFormPrinpal(ByVal TextForms As String)
dataOUT = TextForms
dataIN=Replace(dataIN,"04", Environment.NewLine & "04")
TxtDonnesRecus.Text += dataOUT
End Sub
Private Sub PortAcceesInteruption(ByVal bufferin As String)
Dim textinteruption As Object = {bufferin}
Dim delegateinteruption As AccesDelegue
delegateinteruption = New AccesDelegue(AddressOf AccesFormPrinpal)
MyBase.Invoke(delegateinteruption, bufferin)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
dataIN = ""
dataOUT = ""
BtnConnecter.Enabled = False
BtnEnvoyesData.Enabled = False
End Sub
Private Sub BtnChercherPorts_Click(sender As Object, e As EventArgs) Handles BtnChercherPorts.Click
CboxPorts.Items.Clear()
For Each PortDinsponible As String In My.Computer.Ports.SerialPortNames
CboxPorts.Items.Add(PortDinsponible)
Next
If CboxPorts.Items.Count > 0 Then
CboxPorts.Text = CboxPorts.Items(0)
MessageBox.Show("selectionner le port de travail")
BtnConnecter.Enabled = True
Else
MessageBox.Show("NON Port Trouve")
BtnConnecter.Enabled = False
BtnEnvoyesData.Enabled = False
CboxPorts.Items.Clear()
End If
End Sub
Private Sub BtnConnecter_Click(sender As Object, e As EventArgs) Handles BtnConnecter.Click
If BtnConnecter.Text = "Connecter" Then
Try
With SerialPort1
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.StopBits = IO.Ports.StopBits.One
.DataBits = 8
.PortName = CboxPorts.Text
.Open()
End With
BtnConnecter.Text = "deconnecter"
BtnEnvoyesData.Enabled = True
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
ElseIf BtnConnecter.Text = "deconnecter" Then
BtnConnecter.Text = "Connecter"
BtnEnvoyesData.Enabled = False
SerialPort1.Close()
End If
End Sub
Private Sub BtnEnvoyesData_Click(sender As Object, e As EventArgs) Handles BtnEnvoyesData.Click
SerialPort1.DiscardOutBuffer()
dataIN = TxtEnvoyerDonnes.Text
SerialPort1.Write(dataIN)
End Sub
Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim datainterruption As String
datainterruption = SerialPort1.ReadExisting
PortAcceesInteruption(datainterruption)
End Sub
End Class
this is the serial communication
Dammak Karim
29-Apr-22 6:56am
View
in my project I make a serial communication between my pc and another device I receive the data in my pc in series and do the accumulation with each other
so I want to limit the size of this flux so I want to do when it finds "04" it starts accumulating data then it stops with the next "04" and like the example I describe above