I am displaying the weight from a weighing scale on into a TextBox using C#/.NET.
This weighing scale is linked to my computer thanks to a serial port connection.
To achieve this, I referred to this post.
My problem :
When I create a new serial port connection I need to declare some constants before that :
_serialPort = new SerialPort(portName, BaudRate, Parity.None, DataBits, StopBits.One);
Here are the constants I need to declare :
private const int BaudRate = 9600;
private const int DataBits = 8;
But BaudRate
and DataBits
values depend on the weighing scale configuration. So everytime I change the weighing scale, the weights are not well displayed anymore.
My question :
How can I automatically detect the weighing scale configuration in order to well display the weights without manually changing the constants' values ?