received ASTM format in serialport from instrument

kurniawan0219

New member
Joined
Dec 12, 2023
Messages
1
Programming Experience
1-3
please help me,

i want to received value from instrument with rs232 connector. I has connect success with the instrument, but when i send sample from instrument to my application on ASTM format.
i can't see value sample, but when change other format. I can see the value.

Please help me to received value from instrument with rs232 connector on ASTM format.
 
Last edited:
I
Receiving Data from Instrument via RS232:
Imports System.IO.Ports

Public Class Form1
    Private WithEvents serialPort As New SerialPort("COM1", 9600, Parity.None, 8, StopBits.One)

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            serialPort.Open()
        Catch ex As Exception
            MessageBox.Show("Error opening port: " & ex.Message)
        End Try
    End Sub

    Private Sub serialPort_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles serialPort.DataReceived
        Dim data As String = serialPort.ReadExisting()
        ProcessData(data)
    End Sub

    Private Sub ProcessData(data As String)
        If data.StartsWith("ASTM") Then
            ' Handle ASTM formatted data
            MessageBox.Show("Received ASTM Data: " & data)
        End If
    End Sub

    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        If serialPort.IsOpen Then
            serialPort.Close()
        End If
    End Sub
End Class
BELIEVE SOMETHING LIKE THIS:
 
Back
Top