S7NetPlus / s7netplus

S7.NET+ -- A .NET library to connect to Siemens Step7 devices
MIT License
1.29k stars 577 forks source link

Reading WORD at StartByteAdr 0 from DB seems to read 4 bytes #526

Closed apachler closed 5 months ago

apachler commented 5 months ago

I have a problem with reading a WORD at StartByteAdr 0 from a DB. I get an exception with following message "Value was either too large or too small for an Int16."

Following code outputs 48945 for the variable resultWord:

var resultWord = await connection.ReadAsync(S7.Net.DataType.DataBlock, 14, 0, S7.Net.VarType.Word, 1);
Console.WriteLine($"TEST {resultWord}");

Since my program is working for many other operations, i think there is something wrong when reading from StartByteAdr 0.

Do you have any advice for me?

apachler commented 5 months ago

Setting VarTyp to S7.Net.VarType.Int shows that the value in the PLC is <0 ... so no problem from the library.