visa
This commit is contained in:
@@ -13,14 +13,14 @@ namespace DeviceCommand.Devices
|
||||
/// 低压电源 一拖三
|
||||
/// </summary>
|
||||
[ACPCommand]
|
||||
public class IT6720: Serial_Port // 直接继承您提供的 Serial_Port 基类
|
||||
public class IT6720 : Visa // 继承 VISA 基类(USB VISA 资源字符串寻址,如 USB0::VID::PID::SN::INSTR)
|
||||
{
|
||||
// 帧格式:同步头 AA + 地址 + 命令字 + 数据[4-25] + 校验和,共 26 字节
|
||||
private const byte FrameSyncByte = 0xAA;
|
||||
private const int FrameLength = 26;
|
||||
private readonly byte _deviceAddress = 0x00; // 电源地址
|
||||
|
||||
public IT6720(SerialPortConfig config) : base(config)
|
||||
public IT6720(VisaConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -109,12 +109,12 @@ namespace DeviceCommand.Devices
|
||||
{
|
||||
byte[] sendFrame = BuildFrame(command, dataBytes);
|
||||
|
||||
// 使用基类提供的 WriteBytesAsync 发送二进制数据
|
||||
await WriteBytesAsync(sendFrame, ct).ConfigureAwait(false);
|
||||
// 使用基类提供的 SendAsync(byte[]) 通过 VISA 会话发送二进制数据帧
|
||||
await SendAsync(sendFrame, ct).ConfigureAwait(false);
|
||||
|
||||
// 使用基类提供的 ReadBytesAsync 读取定长 26 字节二进制数据
|
||||
// 注意:这里的 ReadTimeout 由基类统一控制
|
||||
return await ReadBytesAsync(FrameLength, ct).ConfigureAwait(false);
|
||||
// 使用基类提供的 ReadAsync(int) 读取定长 26 字节二进制数据帧
|
||||
// 注意:读写超时(IOTimeout)与终止符处理均由 VISA 基类统一控制
|
||||
return await ReadAsync(FrameLength, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user