Skip to content

Commit

Permalink
docs: 1# upgrade to v1.5.1 (版本升级到v1.5.1); 2# Add comment (添加注释);
Browse files Browse the repository at this point in the history
  • Loading branch information
xingshuangs committed Apr 9, 2024
1 parent 8a7388c commit 97a2b74
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IOT-COMMUNICATION

[![Maven-v1.5.0](https://img.shields.io/badge/Maven-v1.5.0-brightgreen)](https://mvnrepository.com/artifact/com.github.xingshuangs/iot-communication)
[![Maven-v1.5.1](https://img.shields.io/badge/Maven-v1.5.1-brightgreen)](https://mvnrepository.com/artifact/com.github.xingshuangs/iot-communication)
![Language-java8](https://img.shields.io/badge/Language-java8-blue)
![Idea-2022.02.03](https://img.shields.io/badge/Idea-2022.02.03-lightgrey)
![CopyRight-Oscura](https://img.shields.io/badge/CopyRight-Oscura-yellow)
Expand Down Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>com.github.xingshuangs</groupId>
<artifactId>iot-communication</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IOT-COMMUNICATION

[![Maven-v1.5.0](https://img.shields.io/badge/Maven-v1.5.0-brightgreen)](https://mvnrepository.com/artifact/com.github.xingshuangs/iot-communication)
[![Maven-v1.5.1](https://img.shields.io/badge/Maven-v1.5.1-brightgreen)](https://mvnrepository.com/artifact/com.github.xingshuangs/iot-communication)
![Language-java8](https://img.shields.io/badge/Language-java8-blue)
![Idea-2022.02.03](https://img.shields.io/badge/Idea-2022.02.03-lightgrey)
![CopyRight-Oscura](https://img.shields.io/badge/CopyRight-Oscura-yellow)
Expand Down Expand Up @@ -30,7 +30,7 @@ Add the dependency to pom.xml in the JAVA project.
<dependency>
<groupId>com.github.xingshuangs</groupId>
<artifactId>iot-communication</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
</dependency>
```

Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

<groupId>com.github.xingshuangs</groupId>
<artifactId>iot-communication</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
<packaging>jar</packaging>

<name>iot-communication</name>
<description>
目前它只是一个物联网通信的工具,包含
1、西门子S7通信协议,支持西门子S1500,S1200,S400,S300,S200Smart,西门子机床828D
2、Modbus通信协议,支持ModbusTcp,ModbusRtuOverTcp,ModbusAsciiOverTcp
3、三菱MELSEC(MC)通信协议,支持PLC iQ-R系列, Q/L系列, QnA系列, 目前只测试了L系列
4、RTSP, RTCP, RTP, H264, MP4 (FMP4)协议,RTSP + H264 + FMP4 + WebSocket + MSE + WEB
5、基础字节数组解析转换工具
1、西门子S7通信协议,支持西门子S1500,S1200,S400,S300,S200Smart,西门子机床828D;
2、Modbus通信协议,支持ModbusTcp,ModbusRtuOverTcp,ModbusAsciiOverTcp;
3、三菱MELSEC(MC)通信协议,支持PLC iQ-R系列, Q/L系列, QnA系列, 目前只测试了L系列;
4、RTSP, RTCP, RTP, H264, MP4 (FMP4)协议,RTSP + H264 + FMP4 + WebSocket + MSE + WEB;
5、基础字节数组解析转换工具;
</description>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public McGroupItem(int actualLength) {
this.actualLength = actualLength;
}

/**
* 判定是否在有效范围内
*
* @return true:是,false:否
*/
public boolean inRange() {
return this.off + this.len < this.actualLength;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public long readNBit(int size) {
return res;
}

/**
* 跳过指定size的bit数量
*
* @param size bit数量
*/
public void skipBit(int size) {
this.readNBit(size);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,20 @@ public class SeqParameterSet {
private boolean aspectRatioInfoPresentFlag;
private double sarScale = 1;

/**
* 视频宽度
*
* @return 宽度
*/
public int getWidth() {
return (int) Math.ceil((((this.picWidthInMbsMinus1 + 1) * 16) - this.frameCropLeftOffset * 2 - this.frameCropRightOffset * 2) * this.sarScale);
}

/**
* 视频高度
*
* @return 高度
*/
public int getHeight() {
return ((2 - (this.frameMbsOnlyFlag ? 1 : 0)) * (this.picHeightInMapUnitsMinus1 + 1) * 16)
- ((this.frameMbsOnlyFlag ? 2 : 4) * (this.frameCropTopOffset + this.frameCropBottomOffset));
Expand Down Expand Up @@ -262,6 +272,4 @@ private static double calculateSarRatio(ExpGolomb expGolomb) {
return 1;
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class H264VideoParser implements IPayloadParser {
/**
* 负载编号
*/
private Integer payloadNumber;
private final Integer payloadNumber;

/**
* 基准时间戳
Expand All @@ -75,6 +75,7 @@ private H264VideoFrame doBuffers(long timestamp) {
if (this.buffers.isEmpty()) {
throw new RtpCommException("the number of buffers is 0");
}

H264NaluFuA naluFuA = this.buffers.get(0);
int sum = this.buffers.stream().mapToInt(x -> x.getPayload().length).sum();
ByteWriteBuff buff = new ByteWriteBuff(sum);
Expand All @@ -97,6 +98,7 @@ private H264VideoFrame doBuffers(long timestamp) {
*/
@Override
public void processPackage(RtpPackage rtp) {
// 过滤负载编号不一致的rtp
if (rtp.getHeader().getPayloadType() != this.payloadNumber) {
log.warn("payload numbers are inconsistent, expect[{}], actual[{}]", this.payloadNumber, rtp.getHeader().getPayloadType());
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface IPayloadParser {
/**
* 处理数据包
*
* @param rtp rtp数据包
* @param rtp rtp数据包
*/
void processPackage(RtpPackage rtp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ public enum EPlcType {

;

/**
* PLC机架号
*/
private final int rack;

/**
* PLC槽号
*/
private final int slot;

/**
* PDU最大允许长度
*/
private final int pduLength;

EPlcType(int rack, int slot, int pduLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ public class MultiAddressRead {
*/
List<RequestItem> requestItems = new ArrayList<>();

public MultiAddressRead addData(String address, int count){
/**
* 添加数据
*
* @param address 地址
* @param count 字节数量
* @return MultiAddressRead
*/
public MultiAddressRead addData(String address, int count) {
this.requestItems.add(AddressUtil.parseByte(address, count));
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
*/
public class S7PLC extends PLCNetwork {

public static final int DEFAULT_PDU_LENGTH = 240;

public S7PLC() {
this(EPlcType.S1200, LOCALHOST, S7_PORT, EPlcType.S1200.getRack(), EPlcType.S1200.getSlot(), EPlcType.S1200.getPduLength());
}
Expand Down
32 changes: 32 additions & 0 deletions tips/changeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
## v1.5.1

- 更新时间:2024.04.09
- S7: 根据PLC类型自动匹配参数,主要是槽号、机架号和PUDLength,解决300或400PLC需要填写不一样的槽号问题,或者1500PLC自动支持960大小的PDULength,而不是默认240,自动优化性能
- S7: 重写S7服务端的readClientData方法,解决粘包问题
- Modbus: 补充modbus的异常码
- MC: 补充三菱协议添加序列号自增功能
- RTSP: 对视频流为H265协议的识别,直接抛出异常原因,明确问题,目前只支持H264协议
- RTSP: 添加SPS数据解析的指数哥伦布编码,从中提取视频的宽高数据,追加到视频轨道中
- RTSP: 解决因SDP中缺失SPS和PPS等信息导致的视频无法播放问题,采用RTP中的SPS和PPS进行兼容处理
- All: 所有异常消息和日志信息修改为英文,更加国际化

## v1.5.0

- 更新时间:2023.12.11
- MC:添加**三菱MC协议**,并添加相关教程文档
- S7: 修复读18倍数个int16或写12倍数个int16出现的BUG问题
Expand All @@ -9,13 +22,15 @@
- MIT: 所有源程序添加MIT协议声明

## v1.4.4

- 更新时间:2023.10.14
- S7: TSAP统一Remote的参数,基础值采用0x0300
- S7: 修复400PLC无法写入的问题,主要由于偷懒导致写操作最后多了一个没用的字节,1200、1500、200smart都是兼容的,老PLC兼容不了
- RTSP: 修复RtspInterleavedClient的循环线程中由于异常网络断开导致无法退出的问题
- RTSP: 修复Rtsp由于长期占用公共线程导致UDP模式最多只能开2个摄像头的问题,目前采用独立线程,不影响公共线程池

## v1.4.3

- 更新时间:2023.09.28
- S7: S200-smart修改local为0x1000
- S7: 200smart下载功能实现并测试成功,上传功能优化
Expand All @@ -30,6 +45,7 @@
- RTSP: 修复rtsp关闭时因通道断开导致的错误

## v1.4.2

- 更新时间:2023.08.17
- S7添加非注解形式的批量读写,可以进行多地址的任意组合,通过S7Parameter配置参数
- S7重构Datum数据类型,实现上传功能(200smart测试成功),下载功能未测试成功,可能PLC的约束,待研究
Expand All @@ -43,6 +59,7 @@
- 字节数组解析中添加自定义字节数组数据提取的功能,通过ByteArrayParameter配置参数进行批量读取

## v1.4.1

- 更新时间:2023.07.09
- RtspFMp4Proxy添加数据缓存,增加缓存大小,用于重新数据排序,同时将关键帧和普通帧区分开
- RtspClient修复UDP/TCP模式网络异常断开后无法退出循环的问题
Expand All @@ -51,13 +68,15 @@
- S7地址格式兼容DB100.DBX0.0、DB100.DBB5、VB100、MW1

## v1.4.0

- 更新时间:2023.06.20
- 添加RTSP, RTCP, RTP, H264, MP4相关协议解析
- 添加RTSP客户端,获取视频流
- 添加RTSP+FMP4的视频流代理服务,可以构建WebSocket服务端将视频发送到WEB中进行实时监控
- S7协议添加DTL数据格式读写,PDULength采用PLC返回的值,槽号默认值设为1

## v1.3.0

- 更新时间:2023.05.17
- 添加西门子协议中NCK的寻址方式,主要针对西门子机床828D的数据访问
- S7协议添加对time、date、timeOfDay数据类型的读写
Expand All @@ -67,6 +86,7 @@
- modbus添加短连接方式,添加readBoolean方法

## v1.2.7

- 更新时间:2023.03.16
- 修复下S7序列化读取时,由于实体类字段超过18个且读取数据量较小导致报文大小超过PDU的BUG
- S7通信支持短连接操作,默认长连接
Expand All @@ -75,55 +95,67 @@
- 添加Slf4j日志

## v1.2.6

- 更新时间:2022.12.06
- 紧急修复RequestItem中存储区参数一直为DB块导致无法访问其他区的问题
- lombok依赖版本升级到推荐版本

## v1.2.5

- 更新时间:2022.12.01
- 修改基础的sourceTSAP和destinationTSAP
- SocketBasic的方法暴露出来
- ByteReadBuff和ByteWriteBuff添加littleEndian字段

## v1.2.4

- 更新时间:2022.11.09
- 完善pduLength的数据大小约束
- 自动分割数据量大于pduLength的报文,支持大数据量的读写

## v1.2.3

- 更新时间:2022.10.31
- 添加S7协议的序列化访问功能
- 添加字节数组序列化解析功能

## v1.2.2

- 更新时间:2022.09.29
- 添加对200smart的PLC兼容,其V区就是DB1区

## v1.2.1

- 更新时间:2022.09.27
- 重构字节数组的读写方式,添加ByteReadBuff和ByteWriteBuff两个类

## v1.2.0

- 更新时间:2022.07.08
- 添加modbusTcp通信协议

## v1.1.1

- 更新时间:2022.05.17
- 移除没用的依赖包

## v1.1.0

- 更新时间:2022.05.15
- 添加S7通信协议

## v1.0.2

- 更新时间:2022.04.28
- 修复int16,uint16,int32,uint32的解析错误

## v1.0.1

- 更新时间:2021.02.25
- 修复float32和float64数据解析成list时候的错误

## v1.0.0

- 搭建时间:2021.02.17
- 目的:为了休闲乐趣,简单小尝试
- 项目初始化,添加字节数据解析功能
Expand Down
4 changes: 3 additions & 1 deletion tutorial/README-S7-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,4 +689,6 @@ PLC的网络通信,根据不同型号PLC的PDULength而定,S1200 = 240,S15
| S300 | 240 | **0** | **2** |
| S400 | 480 | **0** | **3** |
| S1200 | 240 | **0** | **1** |
| S1500 | 960 | **0** | **1** |
| S1500 | 960 | **0** | **1** |

> 7、一般PLC同时在线连接数量有限,切勿重复new S7PLC()!!!
4 changes: 3 additions & 1 deletion tutorial/README-S7-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,4 +692,6 @@ Receive:The maximum byte write length is 225 = 240 - 15, 15(response PDU) = 12
| S300 | 240 | **0** | **2** |
| S400 | 480 | **0** | **3** |
| S1200 | 240 | **0** | **1** |
| S1500 | 960 | **0** | **1** |
| S1500 | 960 | **0** | **1** |

> 7、General PLC online connection number is limited, do not repeat new S7PLC()!!!

0 comments on commit 97a2b74

Please sign in to comment.