NModbus4 源码引用方式
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Modbus.IO; //NModbus4添加
using Modbus.Device; //NModbus4添加
using System.IO.Ports; //NModbus4添加
namespace NModbus4_Demo1
{
public partial class Form1 : Form
{
private SerialPort sp = null;
private ModbusSerialMaster msm;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
sp= new SerialPort("COM2",9600);
sp.Open();
msm= ModbusSerialMaster.CreateRtu(sp);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (sp.IsOpen)
{
sp.Close();
}
}
}
}
删除NModbus4 不必要的 ,留下如下列:
版权声明:本文为u010029229原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。