nuget 搜索 HlgSiemensCommunication
目前仅写入了DB块的封装 0x84 其他区域可根据需求自行修改代码
不清楚此协议或查看其他源码无法理解的伙伴可以查阅此代码,代码编写接地气,便于理解与上手。
/// <summary>
/// 拼接命令
/// </summary>
/// <returns></returns>
public byte[] GetReadCommand(List<InputSiemensParams> siemens, out List<SiemensParams> outsiemensParams)
{
var virtualsiemens = InitDBVirtual(siemens);
outsiemensParams = virtualsiemens;
byte[] resultCommand = new byte[19 + (12 * virtualsiemens.Count)];
//TPKT 4位
{
resultCommand[0] = 0x03;
resultCommand[1] = 0x00;
//2-3 整体报文长度
resultCommand[2] = BitConverter.GetBytes(resultCommand.Length)[1];
resultCommand[3] = BitConverter.GetBytes(resultCommand.Length)[0];
}
//ISO 3位
{
resultCommand[4] = 0x02;
resultCommand[5] = 0xF0;
resultCommand[6] = 0x80;
}
//header 10位
{
resultCommand[7] = 0x32;
resultCommand[8] = 0x01;
resultCommand[9] = 0x00;
resultCommand[10] = 0x00;
resultCommand[11] = 0x0