From 0533c8bebce479298ce991d29e0dc64a153f2fc2 Mon Sep 17 00:00:00 2001 From: "parallelbgls@outlook.com" Date: Mon, 29 Sep 2014 11:06:20 +0800 Subject: [PATCH] 2014-09-29 update 1 --- Modbus.Net/ModBus.Net/ValueHelper.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modbus.Net/ModBus.Net/ValueHelper.cs b/Modbus.Net/ModBus.Net/ValueHelper.cs index 2a92313..0d06988 100644 --- a/Modbus.Net/ModBus.Net/ValueHelper.cs +++ b/Modbus.Net/ModBus.Net/ValueHelper.cs @@ -167,6 +167,7 @@ namespace ModBus.Net t[i] = temp%2 > 0; temp /= 2; } + pos += 1; return t; } @@ -378,7 +379,7 @@ namespace ModBus.Net return translation.ToArray(); } - public bool GetBit(ushort number, int pos) + public bool GetBit(ushort number, ref int pos) { if (pos < 0 && pos > 15) throw new IndexOutOfRangeException(); int ans = number % 2; @@ -389,6 +390,7 @@ namespace ModBus.Net number /= 2; i--; } + pos += 1; return ans > 0; } @@ -531,6 +533,7 @@ namespace ModBus.Net t[8 - i] = temp%2 > 0; temp /= 2; } + pos += 1; return t; }