资源简介
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# 调用win32 api函数-user32.dll详细说明
- C# 调用BarTender打印条码DEMO
- 大型比赛竞赛抽签系统 可打印 c# vs
- C#编写的Gerber查看器
- lua C# .Net4.0 vs2010 LuaInterface
- C#十六进制编辑器
- 明华URF-35H读卡器 C#读写源码 为大家
- C#文件流读取CSV文件
- c#读写PDF文件sql
- C# winform Socket大文件传输
- c#车牌识别系统附30张测试图片
- 《C#面向对象程序设计》源代码(CS)
- 金旭亮《C#面向对象程序设计》教案
- 试题库管理系统毕业论文(C#)源程序
- 学校网站原代码(C#.NET)
- C#-数据库操作技术-员工管理系统
- c#web开发入门经典
- C#与Matlab混合编程的几种方式
- c# 开发与 mysql数据库实现的增删改查
- C#异步操作 异步查询数据库 异步处理
- Basler相机通过IO触发源码
- [源代码] 《领域驱动设计 (C# 2008 实
- 松下PLC与C#通讯串口调试入门教程.z
- USB 继电器控制器 LCUS-1 保证能用 c#
- C# AES加密解密小工具
- C#圆形按钮,非常漂亮动态~~
- [精]C#仿QQ右下角弹出提示框()
- C#进程间通信-共享内存代码
- 有史以来最简单的三层(C#)
- vb调用c#编写的串口DLL文件(vb源码
评论
共有 条评论