S7NetPlus / s7netplus

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

Unable to read PLC DB data #252

Closed 05749 closed 3 years ago

05749 commented 4 years ago

Hi, I am using the S7-1200 and TIA portal V1.4. I am running Readbytes from the S7.net library, but I get the following error: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." I can do plc.open () and plc.close () without any problems. Is there any solution? Any advice is welcome. thank you in advance. plc program

FalcoGoodbody commented 4 years ago

Did you check that the DB is not optimized?

05749 commented 4 years ago

Thank you for your comment. Yes, I unchecked DB optimization according to the documentation. image Do I need other settings on the PLC besides the contents of this document? Thank you.

allatrue commented 4 years ago

Did you enabled PUT/GET communication for the CPU?

05749 commented 4 years ago

Yes, I have enabled PUT / GET communication for the CPU .

mycroes commented 4 years ago

Try to remove the Plc.Isconnected check, it's broken.

05749 commented 4 years ago

I thought Plc.Isconnected was a way to verify communication with the PLC, but does it affect Plc.ReadBytes?

mycroes commented 4 years ago

I believe it accidentally terminates the connection. I'm way behind on fixing issues like this, because obviously this shouldn't be the case. Let me know if it works without the IsConnected check.

05749 commented 4 years ago

Thank you for your comment. I was able to read the DB by removing the IsConnected check. Improved PLC program thank you very much.

FalcoGoodbody commented 4 years ago

Well...that´s strange. I am using the PLC.IsConnected to read data from several S7-1500 at there it works fine so far. Maybe it is a problem depending to the PLC used?

mycroes commented 4 years ago

Maybe one of you isn't using the latest version?

FalcoGoodbody commented 4 years ago

I´m using Version 0.4.0 from the last year. Via NuGet there is no newer one available. For me everything works fine and I am absolutely happy with this library.

05749 commented 4 years ago

I using the same S7.Net version 0.4.0. However, the PLC I'm using is S7-1200 and the CPU firmware version is V4.1. Do these conditions affect anything?

mycroes commented 4 years ago

0.7.0 has some major improvements and better exception message on errors, so please retest.

mycroes commented 3 years ago

Closing, feel free to reopen if the issue persists.