Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how read the IP address for PLC from Hardware? #18

Closed
SevenMag opened this issue Sep 29, 2014 · 57 comments
Closed

how read the IP address for PLC from Hardware? #18

SevenMag opened this issue Sep 29, 2014 · 57 comments

Comments

@SevenMag
Copy link
Contributor

wie Sie die IP-Adresse der PLC von Hardware lesen?

@SevenMag
Copy link
Contributor Author

SevenMag commented Oct 7, 2014

I'm found number Rack and Slot for CP and CPU (3xx and 4xx)
in file HOBJECT1.DBF column SUBSTATN is number rack, column MODULN is slot.
checked in more S7 projects with H-system.
You can add to LibNoDaveConnectionLibrary ?

@jogibear9988
Copy link
Member

Have you also find out where the IP is stored?

@SevenMag
Copy link
Contributor Author

SevenMag commented Oct 7, 2014

I am looking for. But it's not easy.

Ich bin für. Aber es ist nicht einfach.

@jogibear9988
Copy link
Member

Ich glaube die sind eher im Ordner CONN... also nicht bei der Hardware!
Aber sicher bin Ich da nicht...

@jogibear9988
Copy link
Member

I've also tried again. I used Winmerge, and compared two projects after changeing a IP, but I had no success

@SevenMag
Copy link
Contributor Author

SevenMag commented Oct 8, 2014

Ich glaube die sind eher im Ordner CONN... also nicht bei der Hardware!

No.
IP address is in file \S7Netze\S7NONFGX.tab as hex to string.
exsample: ip = 192.168.2.200; string = "C0A802C8"; file S7NONFGX.tab has this string, but many times.
Where is the offset for each CPFolder I have not found.

@jogibear9988
Copy link
Member

The Byte before the IP Adress String is the Length of the String.

@SevenMag
Copy link
Contributor Author

The Byte before the IP Adress String is the Length of the String.

Pascal?
This file also has mask and MAC-address.
When save hardware without changing the file changes.

@jogibear9988
Copy link
Member

Pascal? what do you mean?

@SevenMag
Copy link
Contributor Author

Pascal has string as: first byte is length, the rest up to 255 bytes is text.
it simply washed.
I have a few ideas on this file, I will try

@SevenMag
Copy link
Contributor Author

I'm disassembled file S7NONFGX.DLL, but that does not found.

@jogibear9988
Copy link
Member

What do you mean?

@SevenMag
Copy link
Contributor Author

File S7NONFGX.DLL is the only file that has a string of "S7Netze", then it reads the file "\S7Netze\S7NONFGX.tab", but in this file I could not find how to read this structure with IP, mask and MAC.

@jogibear9988
Copy link
Member

@SevenMag
Copy link
Contributor Author

so einfach? bravo!

@SevenMag
Copy link
Contributor Author

I found for the CP: IP address, MAC, mask and router, but only for simple CP.
For 6GK7443-1EX20-0XE0 ( which has 2 Ethernet ) compliance can not find.

@SevenMag
Copy link
Contributor Author

I'm a little confused.
made changes in two pull Requests.

@jogibear9988
Copy link
Member

I will modifie your changes a little bit, because for Example a CPU or PG can have more than one Network Interface...

@SevenMag
Copy link
Contributor Author

Good.
CP 6GK7443-1EX20-0XE0 has two network interface, but not fill this code.

@jogibear9988
Copy link
Member

I need the code of "IndexOfByteArray"

@SevenMag
Copy link
Contributor Author

ups. sorry.
something like this:

    public int IndexOfByteArray(byte[] array, byte[] pattern, int offset, int maxLen)
    {
        int success = 0;
        int length = array.Length;
        for (int i = offset; i < length; i++)
        {
            if (array[i] == pattern[success])
                success++;
            else if ( success > 0 )
            {
                ii--;
                success = 0;
            }
            if (pattern.Length == success)
                return i - pattern.Length + 1;
             if ( --maxLen == 0 ) return -1;
        }
        return -1;
    }

@SevenMag
Copy link
Contributor Author

more:

      if (cp.IP != ip) 

always is TRUE.
need change to

     if (cp.IP.ToString() != ip.ToString() )

@SevenMag
Copy link
Contributor Author

  1. why CP is added only when TobjTyp == 1314972?
    I have project with row["TOBJTYP"] is 1314972 and 11314865, so the draft CPFolder was empty.
  2. file \s7wb53ax\HRELATI1.DBF: row["TOBJID"] need to remember when row["RELID"] is equal to 64, otherwise TobjId is not valid.

@jogibear9988
Copy link
Member

in my test project every cp is added twice (lean 340) so i looked in the hrelatio file and se, i have two entrys for every cp. but i will overwoek it, i also see in the hobject dbf in this folder also the ports seem to be in that file...
i will look to repair it, maybe today, or tomorrow....

@SevenMag
Copy link
Contributor Author

Today I downloaded the new version, in my project, he showed the CPFolder.Count = 0, I removed the condition "if (x.TobjTyp == 1314972)", the CP appeared, but without Network. Corrected as I sent yesterday, appeared Network. Add "pull Requests" with my changes?

@SevenMag
Copy link
Contributor Author

I can send the project on which I am trying to

@jogibear9988
Copy link
Member

why is your network info missing? i changed nothing on your reading code!

@jogibear9988
Copy link
Member

i mean nothing functional!

@SevenMag
Copy link
Contributor Author

in "//Get The CP Folders" i'm add code:

            int sobjid;
            foreach (DataRow row in dbfTbl.Rows)
            {
                if (!(bool)row["DELETED_FLAG"] || _showDeleted)
                {
                    if ((int)row["RELID"] == 64)
                    {
                        sobjid = (int)row["SOBJID"];
                        var cp = CPFolders.FirstOrDefault(x => x.ID == sobjid);
                        if (cp != null)
                            cp.TobjId = (int)row["TOBJID"];
                    }
                }
            }

you do not have this

@SevenMag
Copy link
Contributor Author

I sent the file Step7ProjectV5.cs
it has 3 lines:

                    byte[] bbb = new byte[1960];
                    Array.Copy(completeBuffer, position, bbb, 0, 1960);
                    File.WriteAllBytes(@"d:\Temp\Temp\" + number + ".txt", bbb);

they help to find small changes, but in the release are not needed.

@SevenMag
Copy link
Contributor Author

hello
received a project Test2.
looked. Very strange situation, in my project was simple.
If you look in the reverse order, then:
S7NONFGX.tab file has 5 structures beginning with 0x03, 0x52, 0x14, 0x00, ie 5 addresses.
these structures number: 3.4, 6, 7, 8.
file \s7wb53ax\HRELATI1.DBF with row["RELID"] == 64 only 4 addresses: 4, 6, 7, 8;
file \s7hssiox\HRELATI1.DBF(for multi-Interface) with row ["RELID"] == 64 has address 3.
but how to compare the values ​​of CP and it is hard to find.
and more: project Test2 has 8 CP, may be 3 CP is profibus.

I hope these thoughts as they will help.
Ich hoffe, dass diese Gedanken, wie sie helfen

@SevenMag
Copy link
Contributor Author

I now checked my code for 30 different projects, always determine the correct IP address.
For project Test2 I had an idea how to compare, but to test this idea a little project.

@impoetk
Copy link
Contributor

impoetk commented Oct 19, 2014

Which code you use for reading the IP address?? I get the cpufolder but the property NetworkInterfaces is always null. Should I run some code before to parse the addresses?

@jogibear9988
Copy link
Member

Yes SvenMag, can you create a Git Pull Request, with the changes yu have to the current Master Branch? I've now reverted my changes to reading from the hrelatio.dbf. I will add your Code that works for your Projects, still I've no time at the moment to look into this.

@SevenMag
Copy link
Contributor Author

I'm change my project (https://github.com/SevenMag/DotNetSiemensPLCToolBoxLibrary) for read IP.
now read IP for CPU with ethernet, for CP with 2 Ethernet and another CP.
Please testing.

@jogibear9988
Copy link
Member

I send you a Project wich does not work. There are read now 4 CP's (it only has two), in my Tree in the Toolbox, only the two are shon, but the other two get the IPs. I think we have two combine this two CP entrys in any way!
And the IP of the CPU is also not read!

@SevenMag
Copy link
Contributor Author

I'm add to CPFolder one more CPFolder as SubModul, see it.
CPU in project Test2 (sent me an e-mail) I read IP normal.
maybe it's the other project?

@SevenMag
Copy link
Contributor Author

may be a little to alter the reading of the DB-files. In each folder, you first need to read HOBJECT1.DBF and then HRELATI1.DBF.
UNITID in HRELATI1 is ID in the HOBJECT1.DBF

@SevenMag SevenMag reopened this Oct 21, 2014
@SevenMag
Copy link
Contributor Author

When HW Config shows two CP, but raed 4 this is may be because the 2 Ethernet CP and 2 CP Profibus.
We must unite and do 2 NetworkInterfaces for each CP

@jogibear9988
Copy link
Member

Can I send you a Example Project? (I thought I did, but I don't find your EMail adress, i replied to github...)

@SevenMag
Copy link
Contributor Author

Yes. send to berlyakov.ev@npoa.mmk.ru

@SevenMag
Copy link
Contributor Author

I have not received anything.

@SevenMag
Copy link
Contributor Author

We have found for the networkInterface: IP, MAC, Router, Name;
I have found a property useIP, useISO, useROUTER;
There are many options, I found 32.
But I think others do not want, or something you want?

@jogibear9988
Copy link
Member

I send it to you now...

@jogibear9988
Copy link
Member

If there are more options you read out, feel free to create Properties and fill them...

@SevenMag
Copy link
Contributor Author

I know that there are so many options (I found the tags difference), but I do not know what it is.

@SevenMag
Copy link
Contributor Author

Project Test1 has 54 IP address, but only 3 for controller (1 in CPU and 2 CP), right?
I change code, before I was looking for code only for the CPU 3xx, now added and 4xx.
as I remove the sub-module and add it to the parent NetworkInterface.

Need to create interfaces for profibas and MPI, which would seek options for them.. Make them please: as you know, that would not alter my.

@jogibear9988
Copy link
Member

I don't understand what you are trying to say?

@SevenMag
Copy link
Contributor Author

OK.
I will create an class ProfiBusInterface and MPIInterface

@jogibear9988
Copy link
Member

I think they Both could be nearly the same, since it's physicaly the same Bus and maybe have the same Properties...

@SevenMag
Copy link
Contributor Author

It's already read?
What property can be found?

@jogibear9988
Copy link
Member

No, it's not read. I only wnated to say you can maybe use the same class for both...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants