'C# Read Serial Port Data based on Standard way

its some years i have a software that work with truck scales read data from weight indicator via RS232 serial port and in all devices i just used serial port data received method i want to know whats the standard way to read these data from a serial port i just attached a document from weight indicator company that mentioned the data format Data format manual. i dont want to read data and then play with char to replace it with blank or any other process i just want its Standard way if anyone help me in this section i will be happy its the output of my serial port which the target is the middle number 10

-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0    10     0
-ip0     0     0
>ip0     0     0
>ip0     0     0
>ip0     0     0
>ip0     0     0
>ip0     0     0

ip0 0 0



Solution 1:[1]

you can use the System.IO.Ports.SerialPort class to use the serial port in C#. The data received by the SerialPort class is of byte type and can be converted to string type.

According to your description, each data frame you receive has a fixed length. You can add a processing of parsing the data frame to the receiving function. For example, when data of a certain length is received, it is converted into a data frame, and the extra string On to the next analysis. If the data is not of fixed length, a terminator can be added to the data frame to determine.

The data frames of serial communication are defined according to their actual needs, and the format of the data frames is uncertain, so the parsing process needs to be completed by yourself.

hope to help you

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sync