首页 > Linux操作系统 > Linux操作系统 > Upload weight
How to get the true weight after goods was placed on a scale?
private void Mscom_Initial()
{
try
{
this.axMSComm1.CommPort = 1;
this.axMSComm1.Settings = "9600,n,8,1";
if (!this.axMSComm1.PortOpen)
this.axMSComm1.PortOpen = true;
this.axMSComm1.InputLen = 0;
this.axMSComm1.DTREnable = true;
this.axMSComm1.RTSEnable = true;
this.axMSComm1.InputMode = MSCommLib.InputModeConstants.comInputModeText;
this.axMSComm1.RThreshold = 1;
this.axMSComm1.NullDiscard = true;
}
catch
{
MessageBox.Show("CommPort Pailed!");
}
}
private void axMSComm1_OnComm(object sender, EventArgs e)
{
string strTmp = "";
System.Threading.Thread.Sleep(500);
if (this.axMSComm1.InBufferCount > 0)
strTmp = this.axMSComm1.Input.ToString();
int i = strTmp.IndexOf("GW");
int j = strTmp.IndexOf("kg");
if (i > 0 && j > 0)
{
this.txtWeight.Text = strTmp.Substring(i + 2, j - i - 2);
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15053694/viewspace-442178/ ,如需转载,请注明出处,否则将追究法律责任。