欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
C#串口MudbudRTU協議編程
[打印本頁]
作者:
Liruonn
時間:
2018-7-24 19:50
標題:
C#串口MudbudRTU協議編程
Modbus串口通信協議
0.png
(43.21 KB, 下載次數: 104)
下載附件
2018-7-24 23:38 上傳
全部資料51hei下載地址:
C#串口MudbudRTU協議編程.zip
(260.39 KB, 下載次數: 131)
2018-7-24 19:50 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
部分源碼預覽:
/*
//讀取串口中一個字節的數據
String ch = mySerialPort.ReadExisting();
switch (ch)
{
case "$":
//接收到串口頭
ReceiveData = "";
break;
case "\n":
//接收到串口尾
//在擁有此控件的基礎窗口句柄的線程上執行委托Invoke(Delegate)
//即在控件textBoxInformation的父窗口form中執行委托.
textBoxInformation.Invoke
(
new MethodInvoker
(
delegate
{
//textBoxInformation.AppendText(ReceiveData);
textBoxReceiveData.Text = ReceiveData;
}
)
);
break;
default:
ReceiveData += ch;
break;
}
int ch = mySerialPort.ReadByte();
string str = string.Empty;
switch (ch)
{
case 0x12:
//接收到串口頭,清空數組
Array.Clear(ReceiveData, 0, ReceiveData.Length);
ReceiveDataIndex = 0;
break;
case 0x14:
//接收到串口尾,輸出string
for (int i = 0; i < ReceiveData.Length; i++)
{
str += (ReceiveData[i] - '0').ToString();
}
//在擁有此控件的基礎窗口句柄的線程上執行委托Invoke(Delegate)
//即在控件textBoxInformation的父窗口form中執行委托.
textBoxInformation.Invoke
(
new MethodInvoker
(
delegate
{
//textBoxInformation.AppendText(ReceiveData);
textBoxReceiveData.Text = str;
}
)
);
break;
default:
ReceiveData[ReceiveDataIndex] = ch;
ReceiveDataIndex++;
if (ReceiveDataIndex > ReceiveData.Length)
{
ReceiveDataIndex = ReceiveData.Length - 1;
}
break;
}
復制代碼
作者:
a425623964
時間:
2020-5-16 00:15
多謝分享,謝謝!
作者:
JACKDENG288
時間:
2020-5-26 19:42
很好,多謝
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1