s7netplus: TPKT error trying reading/writing merker value

Hi all,

I’m trying the c# library on visual studio 2017, I have installed it via nuget packages. I’m getting this error when I run my application:

TPKT is incomplete / invalid

The cpu is S7-300.

This is my code:

using S7.Net;

Plc plc = new Plc(CpuType.S7300,"192.168.1.1",0,2)
plc.Open();

if(plc.isConnected && plc.isAvailable){
    plc.Write("M20.0",true);
    bool testRead = (bool)plc.Read("M20.1");
}

plc.Close();

I’m getting the error on: plc.Write(“M20.0”,true)

If I comment the line I get the error on the reading command.

On the PLC I have only the OB1 with one segment.

|-----|M20.0| -------(M20.1)—

Thanks for help!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

@aetasoul @jerko1979 Thanks to both of you. The IsAvailable method has been broken in recent versions, I’ll make sure a separate issue covers this.

Well Done ! 👍

Maybe you should use sharp7 , library here is the link how to . I have never uset s7net to be honest! https://www.mesta-automation.com/how-to-write-a-siemens-s7-plc-driver-with-c-and-sharp7/

@jerko1979 I don’t think you’re really helping @aetasoul by pointing him to another library (where I’m afraid the support will be far worse than here, since the developer is a C programmer that ported his code to C# following C conventions). You provided some good advice with regards to the settings, we should be able to get this problem solved by diagnosing what’s going on.