Skip to content

Commit 19d88c3

Browse files
committed
PlcTag: Fix wrong bytenr calculation by adding explicit casts
1 parent fb4618e commit 19d88c3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/S7CommPlusDriver/ClientApi/PlcTag.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,7 @@ public override string ToString()
939939
int dbnr = Value[0] * 256 + Value[1];
940940
int area = Value[2];
941941
int bitnr = Value[5] & 0x7;
942-
int bytenr = Value[5] >> 3 + Value[4] * 32 + (Value[3] & 0x7) * 8192;
943-
942+
int bytenr = (int)(Value[5] >> 3) + ((int)Value[4]) * 32 + (int)(Value[3] & 0x7) * 8192;
944943
return ResultString(this, String.Format("DB={0} Area=0x{1:X02} Byte={2} Bit={3}", dbnr, area, bytenr, bitnr));
945944
}
946945
}
@@ -988,7 +987,7 @@ public override string ToString()
988987
int dbnr = Value[4] * 256 + Value[5];
989988
int area = Value[6];
990989
int bitnr = Value[9] & 0x7;
991-
int bytenr = Value[9] >> 3 + Value[8] * 32 + (Value[7] & 0x7) * 8192;
990+
int bytenr = (int)(Value[9] >> 3) + ((int)Value[8]) * 32 + (int)(Value[7] & 0x7) * 8192;
992991

993992
return ResultString(this, String.Format("HDR={0:X02} Type={1:X02} Factor={2} DB={3} Area=0x{4:X02} Byte={5} Bit={6}", hdr, datatype, factor, dbnr, area, bytenr, bitnr));
994993
}

0 commit comments

Comments
 (0)