/// <summary> /// 获取MODBUS读命令 /// </summary> /// <param name="meterAddress">表地址</param> /// <param name="functionCode">功能码</param> /// <param name="address">线圈/寄存器地址</param> /// <param name="quantity">地址连续量</param> /// <returns>返回带校验码的MODBUS读命令</returns> public static string GetReadCommand(byte meterAddress, FunctionCode functionCode, ushort address, ushort quantity) { string command = string.Format("{0} {1} {2} {3} {4} {5}", meterAddress.ToString("X2"), ((byte)functionCode).ToString("X2"), (address / 256).ToString("X2"), (address % 256).ToString("X2"), (quantity / 256).ToString("X2"), (quantity % 256).ToString("X2")); return(command + " " + HexHelper.GetCRC16_String(command)); }