Menu

S7-200 connection

2017-10-02
2017-10-02
  • Elia Rivadossi

    Elia Rivadossi - 2017-10-02

    Hi all,

    I hope that someone can help me to resolve this issue.
    I've an S7-200 PLC and have to collect some data.
    The connection is configured in this way:
    1) This is a server Connections: Server respond to connection request from remote clients.
    2) Local Properties (Server) TSAP 10.04
    3) Remote Properties (Cienti) TSAP 10.02
    4) accept all connection requests.
    5) IP Address: 192.168.101.178

    If I use ClientDemo.exe
    IP 192.168.101.178
    Local TSAP 10 . 02
    Rem TSAP 10.04

    the connection is made with no problem

    If I try to connect with a VB.net software I receive a TCP Error

    the code is this

    dim plc as New S7Client

    Dim par1 As New Uint16
    Dim par2 As New Uint16

    par1 = 1002
    par2 = 1004

    Dim ok_conf as integer
    Dim ok_conn as integer

    ok_conf = plc.SetConnectionParams("192.168.101.178", par2, par1)
    ok_conn = plc.Connect()

    ok_conn is always <> 0 and Timeout error is displayed
    I've tried some values for par1 and par2 but with no result. I think that the problem is in the parameter values but I don't know how to calculate the correct value.

    Thanks in advance,

    Input

     
  • Davide Nardella

    Davide Nardella - 2017-10-02

    TSAPs are Hexadecimal.
    Try &H1002 and &H1004

     
  • Elia Rivadossi

    Elia Rivadossi - 2017-10-02

    With &H1002... works fine. But, before you give me this solution, I have tried also with 4098 and 4100 (hex 1002 and hex 1004) and didn't work.
    Now if I use &H1002... or 4098... all works fine!! Apparently I've no answer about this strage behavior...but thanks, you got it, problem solved.

     

Log in to post a comment.

MongoDB Logo MongoDB