TurpoUrpo
Lifetime Supporting Member
Peter, you can use
Code:
L P##RECV_BUFFER
LAR2
L P##RECV_BUFFER
LAR2
That is flattering - thank you. Personally, I have long since left the narrow STL-path, and wissed off via the SCL-highway. I dont know everything about STL, and am definitely not an ANY pointer wizard. LD seems to have chosen another path. People are different.Actually JesperMP and L D [AR2,p#0.0] know much more that what find in the books. [...] There are techniques shown that I haven't found in the books. However, I still am not convinced that they know the S7 inside out, forwards and backwards but they know how to use the S7 well
Peter, you can use
Code:L P##RECV_BUFFER LAR2
I am not writing this for myself and not everybody has SCL. This is an example program so that people can use FB500 RMC__UDP_READ and FB501 RMC_UDP_WRITE. to read and write anywhere any length.For some reasons you have ditched SCL during your 'journey' into S7-land. I think that it would be a lot easier to write in SCL, since you are manipulating various DBs + indexing etc.
Actually, if I don't get an answer to my question I was going to write a SCL program that accesses an array in a structure like I want to do in STL. I would then look at the code SCL generates but it wouldn't do me any good if it just loads a constant offset into AR2.I could be persuaded to port what you have got until now into SCL, if you are interested.
I have found that if I create an error I can get the compiler to show me the true code that is generated. Only when the true code is examined and understood will one truly understand what is going on. Siemens hides too much and there are too many arbitrary restrictions.That is flattering - thank you. Personally, I have long since left the narrow STL-path, and wissed off via the SCL-highway. I dont know everything about STL, and am definitely not an ANY pointer wizard. LD seems to have chosen another path. People are different.
So far I have seen that AR2 is set to 0 on entry to a FB. The DI register points to the IDB. However, Siemens must play some more unseen tricks because DI has the IDB number not the true address of the IDB in memory. This means the Siemens must be using the DI register as an index register into a DB_ARRAY that holds the true IDB address. This makes sense if you think about it because as I down load different DB500 the S7 only needs to change the address in this hidden DB_ARRAY for the program to work. If the S7 didn't have this indirect DB array then the actual addresses of the DB500 would need to change everywhere in the program where DB500 is accessed. This is one of the few things I would do the same as Siemens does. When accessing variables in the DB from within the DB, the S7 should only need to use the DI register to lookup the true IDB address in memory and then add the offset of the variable in the IDB and load it. I am not sure why AR2 is needed. Looking at the FB500 code in STL shows that AR2 is not used anywhere until I try to use it.So there is a good possibility that the code is pointing somewhere wrong scince AR2 is pointing to the instance of a FB.
But why not make an FB that has an IDB plus parameters going in and out. In that case people do not have to access the SCL source code.I am not writing this for myself and not everybody has SCL. This is an example program so that people can use FB500 RMC__UDP_READ and FB501 RMC_UDP_WRITE. to read and write anywhere any length.
If the code is an FB block, and external access to data is via INPUT and OUTPUS (f.ex. I guess DST is an OUTPUT that contains an ARRAY of DINTs), then the generated STL code manipulates its own IDB only. As it knows the position of all the STATs, including the INPUTs and the OUTPUTs, it loads AR1 with constants based on the position in the declaration table.Actually, if I don't get an answer to my question I was going to write a SCL program that accesses an array in a structure like I want to do in STL. I would then look at the code SCL generates but it wouldn't do me any good if it just loads a constant offset into AR2.
I don't know if i understand you sentense correct do you mean you don't know what AR2 is doing in a FB or do you mean something else ?Looking at the FB500 code in STL shows that AR2 is not used anywhere until I try to use it.
I mean that AR2 is set to 0 on entry and I see no instructions like L D [AR2,P#0.0] that require AR2 to do addressing. I see nothing that changes AR2 within FB500.I don't know if i understand you sentense correct do you mean you don't know what AR2 is doing in a FB or do you mean something else ?
I am not sure why AR2 is needed. Looking at the FB500 code in STL shows that AR2 is not used anywhere until I try to use it.
L 5
T #Test1
OPN DI 1
L DID [AR2,P#0.0]
L DIW [AR2,P#0.0]
L 5
T #Test1
OPN DI 1
L DID [AR2,P#0.0]
L #Test1
L DID[AR2,P#0.0]
Becomes
L D[AR2,P#0.0] // the Adressregister allready points to the instance see pictur DI4.0
That is interesting. Now I know why I don't need the DID and DIW. Back in the late 90s everything was hard coded so I have old examples with lots of DIW and DBD instructions.Now, I save my changes, and what do I see?
That is interesting. Now I know why I don't need the DID and DIW. Back in the late 90s everything was hard coded so I have old examples with lots of DIW and DBD instructions.
The point is that the error is false, yet again.When it says OB not loaded, it means that you have not loaded OB to cpu that handles given error and prevents cpu from going stop mode when that error happens.
OK, S7Guy made the point that when we see L #temp it is really doing L DIW[AR2,P#.0]. You see, this is what has been ****ing me off from the beginning. This has been hidden from me. It also explains why the AR2 must be reset back to the way it was at the beginning of the FB execution.You need to restore AR2 after using it before accessing any variable wich uses AR2 to know where it is.
The point is that AR2 is ALWAYS being used to access IDB variables it is just hidden most of the time.