feat: 更新通信协议
This commit is contained in:
@@ -228,15 +228,17 @@ public class UDPClientPool
|
||||
IPEndPoint endPoint, int taskID, uint devAddr, int timeout = 1000)
|
||||
{
|
||||
var ret = false;
|
||||
var opts = new SendAddrPackOptions();
|
||||
var opts = new SendAddrPackOptions()
|
||||
{
|
||||
BurstType = BurstType.FixedBurst,
|
||||
BurstLength = 0,
|
||||
CommandID = Convert.ToByte(taskID),
|
||||
Address = devAddr,
|
||||
IsWrite = false,
|
||||
};
|
||||
|
||||
opts.BurstType = BurstType.FixedBurst;
|
||||
opts.BurstLength = 0;
|
||||
opts.CommandID = Convert.ToByte(taskID);
|
||||
opts.Address = devAddr;
|
||||
|
||||
// Read Jtag State Register
|
||||
opts.IsWrite = false;
|
||||
// Read Register
|
||||
ret = await UDPClientPool.SendAddrPackAsync(endPoint, new SendAddrPackage(opts));
|
||||
if (!ret) return new(new Exception("Send Address Package Failed!"));
|
||||
|
||||
@@ -358,12 +360,16 @@ public class UDPClientPool
|
||||
IPEndPoint endPoint, int taskID, UInt32 devAddr, int dataLength, int timeout = 1000)
|
||||
{
|
||||
var ret = false;
|
||||
var opts = new SendAddrPackOptions();
|
||||
var opts = new SendAddrPackOptions()
|
||||
{
|
||||
BurstLength = 0,
|
||||
Address = 0,
|
||||
BurstType = BurstType.FixedBurst,
|
||||
CommandID = Convert.ToByte(taskID),
|
||||
IsWrite = false,
|
||||
};
|
||||
var resultData = new List<byte>();
|
||||
|
||||
opts.BurstType = BurstType.FixedBurst;
|
||||
opts.CommandID = Convert.ToByte(taskID);
|
||||
opts.IsWrite = false;
|
||||
|
||||
// Check Msg Bus
|
||||
if (!MsgBus.IsRunning)
|
||||
@@ -544,15 +550,17 @@ public class UDPClientPool
|
||||
IPEndPoint endPoint, int taskID, UInt32 devAddr, UInt32 data, int timeout = 1000)
|
||||
{
|
||||
var ret = false;
|
||||
var opts = new SendAddrPackOptions();
|
||||
var opts = new SendAddrPackOptions()
|
||||
{
|
||||
BurstType = BurstType.FixedBurst,
|
||||
BurstLength = 0,
|
||||
CommandID = Convert.ToByte(taskID),
|
||||
Address = devAddr,
|
||||
IsWrite = true,
|
||||
};
|
||||
|
||||
opts.BurstType = BurstType.FixedBurst;
|
||||
opts.BurstLength = 0;
|
||||
opts.CommandID = Convert.ToByte(taskID);
|
||||
opts.Address = devAddr;
|
||||
|
||||
// Write Jtag State Register
|
||||
opts.IsWrite = true;
|
||||
// Write Register
|
||||
ret = await UDPClientPool.SendAddrPackAsync(endPoint, new SendAddrPackage(opts));
|
||||
if (!ret) return new(new Exception("Send 1st address package failed!"));
|
||||
// Send Data Package
|
||||
@@ -585,18 +593,21 @@ public class UDPClientPool
|
||||
IPEndPoint endPoint, int taskID, UInt32 devAddr, byte[] dataArray, int timeout = 1000)
|
||||
{
|
||||
var ret = false;
|
||||
var opts = new SendAddrPackOptions();
|
||||
var opts = new SendAddrPackOptions()
|
||||
{
|
||||
BurstType = BurstType.FixedBurst,
|
||||
CommandID = Convert.ToByte(taskID),
|
||||
Address = devAddr,
|
||||
BurstLength = 0,
|
||||
IsWrite = true,
|
||||
};
|
||||
|
||||
|
||||
opts.BurstType = BurstType.FixedBurst;
|
||||
opts.CommandID = Convert.ToByte(taskID);
|
||||
opts.Address = devAddr;
|
||||
|
||||
// Check Msg Bus
|
||||
if (!MsgBus.IsRunning)
|
||||
return new(new Exception("Message bus not working!"));
|
||||
|
||||
opts.IsWrite = true;
|
||||
var hasRest = dataArray.Length % (256 * (32 / 8)) != 0;
|
||||
var writeTimes = hasRest ?
|
||||
dataArray.Length / (256 * (32 / 8)) + 1 :
|
||||
|
||||
Reference in New Issue
Block a user