How to display weight from weighing scale into a t

2019-01-20 02:19发布

I've been assigned to display weight from weighing scale (CAS CI-201A) into a textbox using C#. The weight will be sent via serial port RS-232 or USB converter. The scale is with me but I don't know where to start. How can I achieve my goal?

7条回答
地球回转人心会变
2楼-- · 2019-01-20 02:48

Based on this:

Listening on COM1... 30 30 33 33 20 49 44 5F 30 30 3A 20 20 20 31 30 2E 36 20 6B 67 20 0D 0A 0D 0A

Being the ASCII for this:

0033 ID_00: 10.6 kg

You can get the result by trimming the received string. Assuming your listener puts the bytes into an array byte[] serialReceived :

string reading = System.Text.Encoding.UTF8.GetString(serialReceived);
textBox1.Text = reading.Substring(13);
查看更多
登录 后发表回答