资源简介
用于连接s7plc设备,从谷歌下载,包含所需jar包,为完整项目
代码片段和文件信息
/*
Part of Libnodave a free communication libray for Siemens S7 300/400 via
the MPI adapter 6ES7 972-0CA22-0XAC
or MPI adapter 6ES7 972-0CA33-0XAC
or MPI adapter 6ES7 972-0CA11-0XAC.
(C) Thomas Hergenhahn (thomas.hergenhahn@web.de) 2002..2005
Libnodave is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 or (at your option)
any later version.
Libnodave is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this; see the file COPYING. If not write to
the Free Software Foundation 675 Mass Ave Cambridge MA 02139 USA.
*/
package org.libnodave;
public class IBH_MPIConnection extends S7Connection {
byte MPI;
public IBH_MPIConnection(PLCinterface ifa int mpi) {
super(ifa);
this.MPI = (byte) mpi;
PDUstartIn = 8 + 7;
PDUstartOut = 8 + 7;
}
private int readPacket() {
int res = iface.read(msgIn 0 4);
if (res == 4) {
int len = 0x100 * msgIn[2] + msgIn[3];
res += iface.read(msgIn 4 len);
}
return res;
}
int writeIBH(byte[] buffer int len) {
iface.write(buffer 0 len);
if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) {
Nodave.dump(“writeIBH “ buffer 0 len);
}
return 0;
}
int readIBHPacket() {
// System.out.println(“readIBHPacket“);
int i res = 0;
res = iface.read(msgIn 0 3);
// System.out.println(“readIBHPacket res:“ + res);
if (res == 3) {
int len = Nodave.USByte(msgIn 2) + 5;
res += iface.read(msgIn 3 len);
} else {
if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) {
System.out.println(“res “ + res);
Nodave.dump(“readIBHpacket: short packet“ msgIn 0 res);
}
return (0); // short packet
}
if ((Nodave.Debug & Nodave.DEBUG_IFACE) != 0) {
System.out.println(
“readIBHpacket: “
+ res
+ “ bytes read “
+ (msgIn[2] + 8)
+ “ needed“);
Nodave.dump(“readIBHpacket: “ msgIn 0 res);
}
return (res);
};
/*
This performs initialization steps with sampled byte sequences. If chal is <>NULL
it will send this byte sequence.
It will then wait for a packet and compare it to the sample.
*/
int initStepIBH(byte[] chal int[] resp int rl) {
int res = 0 a = 0;
int res2;
if ((Nodave.Debug & Nodave.DEBUG_CONNECT) != 0)
System.out.println(“_daveInitStepIBH before write.\n“);
res = writeIBH(chal chal.length);
if ((Nodave.Debug & Nodave.DEBUG_CONNECT) != 0)
System.out.println(“_daveInitStepIBH write returned “ + res);
//if (res < 0)
// return 100;
res = readIBHPacket();
/*
We may get a network layer ackknowledge and an MPI layer ackknowledge which we discard.
So normally at least the 3rd packet should h
相关资源
- java swing 实现ios7毛玻璃效果,高斯模
- 64位Win2008下IIS7.5与Tomcat7共用80端口,
- android手机和西门子s1200 PLC通讯socke通
- Windows7和10亲测可破解myeclipse 2015 sta
- java开发的社会养老保险系统,仿win
- KepOPC工业互联网数据交换平台
- VB6通过Snap7控件与西门子PLC(S7-200SM
- Android程序开发使用Modbus,Modbus4j读写
- 松下PLC解密
- KepOPC工业互联网数据交换平台V2.4.9
- 西门子s7-200 Smart plc modbus tcp 通讯代码
- java与plc通讯
- 原生JAVA读写PLC
- JAVA程序与PLC通信——学习使用
- 北京联通全网有关网上订购和点播接
- 一头扎进 centos7 视频教程 java1234出品
- centos7.4 opencv-341.jar + libopencv_java341.s
- Centos7 环境下部署Jenkins 构建Android a
- Android 通过USB与PLC设备通信(USB转串口
- jboss-modules-1.15.GA.jar
- s7-200 224xp plc发送高频脉冲控制步进电
- Centos7上安装FastDFS并用-java7-实现上传
- JAVA程序与PLC之间的通信
- Java AES128加密解密 (AES/ECB/PKCS7Paddin
评论
共有 条评论