C#に基づくMODBUS TCPモジュールとのシリアルCommunicationルーチン

Paid ¥6.99Paid ¥6.99

该内容已接入现有会员/付费系统,解锁后可查看完整资料或下载附件。

查看解锁方式
C#に基づくMODBUS TCPモジュールとのシリアルCommunicationルーチン

MODBUSライブラリのインスタンス化

//summary>
///MODBUSライブラリのインスタンス化
////summary>
//param name="tempAddr"デフォルトのスレーブアドレス/param>
///param name="tempNum"初期パケット番号/param>
public AndyModbusLib byte tempAddr ushort temp

 

MODBUS TCP要求メッセージ生成方法

/*
データパケットの生成
int addrTe =読み書きの開始アドレス
int cmdTe =機能コード
int lenTe =読み取りデータ長
byte[] msgBuf =書き込みされるデータのバッファ期間、各ワードは2 BYTE
int msgLen =書き込まれるデータの長さ
*********************************************************************/
public byte[] makeModbusTcp_Packaget int cmdTe int addrTe int lenTe byte[] msgBuf int msgLen

 

MODBUS TCP応答メッセージ解析方法

/*
MODBUS RTUパケットのParse
int addrTe =開始アドレス
byte[] msgBuf =受信したデータのバッファリング期間、各ワードは2 BYTE
int msgLen =受信されたデータ长BYTEの
*********************************************************************/
public int decodeModbusRtuMsg int addrTe byte[] msgBuf int msgLen

 

イベント委任

//summary>
///イベントに関するデリゲートを宣言し、引数を返すデータ型にします
////summary>
///param name=""=ファンクションコード/param>
//param name="msg"読み出された数値/param>
//param name="len"長さ/param>
public delegate void MDTCP_EventHandler byte cmd byte[] msg int len;

このページからダウンロード

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.