SetBit Support (not test)
This commit is contained in:
@@ -124,7 +124,7 @@ namespace Modbus.Net.Modbus
|
||||
var translateAddress = addressTranslator.AddressTranslate(startAddress, false);
|
||||
FunctionCode = (byte)translateAddress.Area;
|
||||
StartAddress = (ushort)translateAddress.Address;
|
||||
WriteCount = (ushort)writeValue.Length;
|
||||
WriteCount = (ushort)Math.Ceiling(writeValue.Length / 2.0);
|
||||
WriteByteCount = 0;
|
||||
WriteValue = writeValue;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
class ModbusRtuProtocalLinker : ComProtocalLinker
|
||||
{
|
||||
public override bool CheckRight(byte[] content)
|
||||
public override bool? CheckRight(byte[] content)
|
||||
{
|
||||
if (!base.CheckRight(content)) return false;
|
||||
if (!base.CheckRight(content).Value) return false;
|
||||
//CRC校验失败
|
||||
if (!Crc16.GetInstance().CrcEfficacy(content))
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{
|
||||
public class ModbusTcpProtocalLinker : TcpProtocalLinker
|
||||
{
|
||||
public override bool CheckRight(byte[] content)
|
||||
public override bool? CheckRight(byte[] content)
|
||||
{
|
||||
if (!base.CheckRight(content)) return false;
|
||||
if (!base.CheckRight(content).Value) return false;
|
||||
//长度校验失败
|
||||
if (content[5] != content.Length - 6)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace Modbus.Net.Modbus
|
||||
{
|
||||
private ModbusType _modbusType;
|
||||
|
||||
public override bool GetLittleEndian => Wrapper[typeof (ReadDataModbusProtocal)].IsLittleEndian;
|
||||
public override bool SetLittleEndian => Wrapper[typeof (WriteDataModbusProtocal)].IsLittleEndian;
|
||||
|
||||
protected string ConnectionStringIp
|
||||
{
|
||||
get
|
||||
@@ -94,7 +97,7 @@ namespace Modbus.Net.Modbus
|
||||
ModbusType = (ModbusType) connectionType;
|
||||
}
|
||||
|
||||
public override async Task<GetDataReturnDef> GetDatasAsync(byte belongAddress, byte masterAddress, string startAddress, int getByteCount)
|
||||
public override async Task<byte[]> GetDatasAsync(byte belongAddress, byte masterAddress, string startAddress, int getByteCount)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -103,11 +106,7 @@ namespace Modbus.Net.Modbus
|
||||
var outputStruct = await
|
||||
Wrapper.SendReceiveAsync(Wrapper[typeof (ReadDataModbusProtocal)], inputStruct) as
|
||||
ReadDataModbusOutputStruct;
|
||||
return new GetDataReturnDef()
|
||||
{
|
||||
ReturnValue = outputStruct?.DataValue,
|
||||
IsLittleEndian = Wrapper[typeof(ReadDataModbusProtocal)].IsLittleEndian,
|
||||
};
|
||||
return outputStruct?.DataValue;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user