91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 32KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-11
  • 語言: 其他
  • 標簽: MODBUS??tcp??C#??

資源簡介

MODBUS-CSharp tcp測試正常讀取數據!

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Net;
using?System.Net.Sockets;
using?System.Windows.Forms;


namespace?MODBUS
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????int?port?=?Convert.ToInt32(portm.Text);
????????????????string?host?=?ipAddress.Text;
????????????????IPAddress?ip?=?IPAddress.Parse(host);
????????????????IPEndPoint?ipe?=?new?IPEndPoint(ip?port);
????????????????Socket?c?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream?ProtocolType.Tcp);
????????????????c.Connect(ipe);
????????????????byte[]?obuf?=?strToToHexByte(“00?00?00?00?00?06?01?03?00?00?00?0A“);
????????????????c.Send(obuf?obuf.Length?0);
????????????????byte[]?recvBytes?=?new?byte[256];
????????????????c.Receive(recvBytes?recvBytes.Length?0);
????????????????recent.Text?=?byteToHexStr(recvBytes);
????????????????c.Close();
????????????}
????????????catch?(ArgumentNullException?ex)
????????????{
????????????????recent.Text?=?ex.ToString();
????????????}
????????????catch?(SocketException?ex)
????????????{
????????????????recent.Text?=?ex.ToString();
????????????}

????????}

????????//16進制轉換
????????public?static?string?byteToHexStr(byte[]?bytes)
????????{
????????????string?returnStr?=?““;
????????????if?(bytes?!=?null)
????????????{
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????returnStr?+=?bytes[i].ToString(“X2“)?+?“?“;
????????????????}
????????????}
????????????return?returnStr;
????????}

????????//字符串轉byte
????????private?static?byte[]?strToToHexByte(string?hexString)
????????{
????????????hexString?=?hexString.Replace(“?“?““);
????????????if?((hexString.Length?%?2)?!=?0)
????????????????hexString?+=?“?“;
????????????byte[]?returnBytes?=?new?byte[hexString.Length?/?2];
????????????for?(int?i?=?0;?i?????????????????returnBytes[i]?=?Convert.ToByte(hexString.Substring(i?*?2?2)?16);
????????????return?returnBytes;
????????}

????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????button1_Click(sender?e);
????????}

????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????timer1.Enabled?=?true;
????????}

????????private?void?button3_Click(object?sender?EventArgs?e)
????????{
????????????timer1.Enabled?=?false;
????????}

????????

???????
????}
}


?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????20480??2011-03-17?15:38??MODBUS-C#\MODBUS\bin\Debug\MODBUS.exe

?????文件??????22016??2011-03-17?15:38??MODBUS-C#\MODBUS\bin\Debug\MODBUS.pdb

?????文件???????5632??2005-11-11?22:25??MODBUS-C#\MODBUS\bin\Debug\MODBUS.vshost.exe

?????文件???????2728??2011-03-17?15:38??MODBUS-C#\MODBUS\Form1.cs

?????文件???????6520??2011-03-17?15:37??MODBUS-C#\MODBUS\Form1.Designer.cs

?????文件???????6008??2011-03-17?15:37??MODBUS-C#\MODBUS\Form1.resx

?????文件???????3219??2011-03-17?15:04??MODBUS-C#\MODBUS\MODBUS.csproj

?????文件????????842??2011-03-17?15:37??MODBUS-C#\MODBUS\obj\Debug\MODBUS.csproj.GenerateResource.Cache

?????文件??????20480??2011-03-17?15:38??MODBUS-C#\MODBUS\obj\Debug\MODBUS.exe

?????文件????????180??2011-03-17?15:37??MODBUS-C#\MODBUS\obj\Debug\MODBUS.Form1.resources

?????文件??????22016??2011-03-17?15:38??MODBUS-C#\MODBUS\obj\Debug\MODBUS.pdb

?????文件????????180??2011-03-17?15:05??MODBUS-C#\MODBUS\obj\Debug\MODBUS.Properties.Resources.resources

?????文件????????261??2011-03-17?16:27??MODBUS-C#\MODBUS\obj\MODBUS.csproj.FileList.txt

?????文件????????465??2011-03-17?15:03??MODBUS-C#\MODBUS\Program.cs

?????文件???????1184??2011-03-17?15:03??MODBUS-C#\MODBUS\Properties\AssemblyInfo.cs

?????文件???????2866??2011-03-17?15:03??MODBUS-C#\MODBUS\Properties\Resources.Designer.cs

?????文件???????5612??2011-03-17?15:03??MODBUS-C#\MODBUS\Properties\Resources.resx

?????文件???????1089??2011-03-17?15:03??MODBUS-C#\MODBUS\Properties\Settings.Designer.cs

?????文件????????249??2011-03-17?15:03??MODBUS-C#\MODBUS\Properties\Settings.settings

?????文件????????907??2011-03-17?15:03??MODBUS-C#\MODBUS.sln

????..A..H.?????11264??2011-03-17?16:27??MODBUS-C#\MODBUS.suo

?????目錄??????????0??2011-03-17?15:32??MODBUS-C#\MODBUS\obj\Debug\Refactor

?????目錄??????????0??2011-03-17?15:03??MODBUS-C#\MODBUS\obj\Debug\TempPE

?????目錄??????????0??2011-03-17?15:14??MODBUS-C#\MODBUS\bin\Debug

?????目錄??????????0??2011-03-17?15:38??MODBUS-C#\MODBUS\obj\Debug

?????目錄??????????0??2011-03-17?15:03??MODBUS-C#\MODBUS\bin

?????目錄??????????0??2011-03-17?15:05??MODBUS-C#\MODBUS\obj

?????目錄??????????0??2011-03-17?15:03??MODBUS-C#\MODBUS\Properties

?????目錄??????????0??2011-03-17?15:38??MODBUS-C#\MODBUS

?????目錄??????????0??2011-03-17?15:03??MODBUS-C#

............此處省略3個文件信息

評論

共有 條評論