资源简介
C#三菱FX系列PLC纯串口命令各区域读写,对于D区,各类型数据均有涉及:short,int,float,简单的demo,并非项目,一目了然

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
using System.IO;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
try
{
SerialPort sp = new SerialPort(“COM3“ 9600 Parity.Even 7 StopBits.One);
sp.Open();
sp.Write(MethodHx.GenerateMitsubishiPlcReadCommand(“D“ 110 1));
byte[] br = new byte[144];
int b = 0 i = 0;
while (true)
{
b = sp.ReadByte();
if (b == 3)
{
sp.ReadByte();
sp.ReadByte();
break;
}
br[i] = (byte)b;
i++;
}
short D110 = 0;
if (br[0] == 2)
D110 = MethodHx.DecodeMitsubishiPlcData_D_Short(br);
Console.WriteLine(D110);
sp.Close();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void button2_Click(object sender EventArgs e)
{
try
{
SerialPort sp = new SerialPort(“COM3“ 9600 Parity.Even 7 StopBits.One);
sp.Open();
sp.Write(MethodHx.GenerateMitsubishiPlcReadCommand(“D“ 510 10));
byte[] br = new byte[144];
int b = 0 i = 0;
while (true)
{
b = sp.ReadByte();
if (b == 3)
{
sp.ReadByte();
sp.ReadByte();
break;
}
br[i] = (byte)b;
i++;
}
string D800 = ““;
if (br[0] == 2)
D800 = MethodHx.DecodeMitsubishiPlcData_D_String(br 10);
Console.WriteLine(D800);
Console.WriteLine(“**********************“);
sp.Write(MethodHx.GenerateMitsubishiPlcReadCommand(“D“ 510 10));
b = 0;
i = 0;
while (true)
{
b = sp.ReadByte();
if (b == 3)
{
sp.ReadByte();
sp.ReadByte();
break;
}
br[i] = (byte)b;
i++;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-12-21 15:45 WindowsFormsApplication2\
目录 0 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\
文件 7614 2017-12-23 14:07 WindowsFormsApplication2\WindowsFormsApplication2\Form1.Designer.cs
文件 8069 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs
文件 5817 2017-12-23 14:07 WindowsFormsApplication2\WindowsFormsApplication2\Form1.resx
文件 16418 2017-12-23 15:05 WindowsFormsApplication2\WindowsFormsApplication2\MethodHx.cs
文件 505 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Program.cs
目录 0 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Properties\
文件 1372 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Properties\AssemblyInfo.cs
文件 2900 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.Designer.cs
文件 5612 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Properties\Resources.resx
文件 1111 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.Designer.cs
文件 249 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\Properties\Settings.settings
文件 3801 2017-12-21 15:52 WindowsFormsApplication2\WindowsFormsApplication2\WindowsFormsApplication2.csproj
目录 0 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\bin\
目录 0 2017-12-23 15:05 WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\
文件 17920 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
文件 44544 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
文件 24216 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
文件 490 2017-09-29 21:43 WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
目录 0 2017-12-21 15:45 WindowsFormsApplication2\WindowsFormsApplication2\obj\
目录 0 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\
文件 1453 2017-12-21 16:51 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6884 2017-12-21 15:46 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2017-12-23 15:22 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\TempPE\
文件 180 2017-12-23 15:05 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Form1.resources
文件 180 2017-12-23 15:05 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.Properties.Resources.resources
文件 946 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.FileListAbsolute.txt
文件 977 2017-12-23 15:05 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csproj.GenerateResource.Cache
文件 2211 2017-12-23 15:06 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.csprojResolveAssemblyReference.cache
文件 17920 2017-12-23 15:09 WindowsFormsApplication2\WindowsFormsApplication2\obj\Debug\WindowsFormsApplication2.exe
............此处省略3个文件信息
- 上一篇:C# SHA1withRsa的各种操作
- 下一篇:c# 访问USB摄像头 拍照 录像
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论