Beiträge anzeigen

Diese Sektion erlaubt es ihnen alle Beiträge dieses Mitglieds zu sehen. Beachten sie, dass sie nur solche Beiträge sehen können, zu denen sie auch Zugriffsrechte haben.


Nachrichten - vmolchanov

Seiten: [1]
1
BECKHOFF / Re: Funktionsbaustein MD5
« am: 07. September 2015, 06:23:03 »
Danke sehr!
Diese Erkenntnis wird mich sicher vor weiteren Fehlern schützen.
Danke noch mal!

Das funktioniert:
IF (bPerform) THEN
CASE iStep OF
0:
bDone := FALSE;
fbMD5_STR(RUN := FALSE,
STR := sInputString,
MD5 := abMD5Hash,
DONE => bDone);
sMD5Hash := '';
IF (bDone) THEN
bDone := FALSE;
iStep := iStep + 10;
END_IF
10:
fbMD5_STR(RUN := TRUE,
STR := sInputString,
MD5 := abMD5Hash,
DONE => bDone);
IF (bDone) THEN
iStep := iStep + 10;
END_IF
20:
sMD5Hash := MD5_TO_STRH(abMD5Hash);
iStep := iStep + 10;
30:
bPerform := FALSE;
iStep := 0;
END_CASE
END_IF

Noch weitere Erkenntnis ist, dass MD5_STR erst mit RUN:=FALSE aufgerufen werden soll. Sonst wird der gleiche Hash-Code für alle Eingaben zurückgeliefert.

2
BECKHOFF / Re: Funktionsbaustein MD5
« am: 04. September 2015, 14:17:02 »
Danke für die Antwort. Die Demos helfen mir leider nicht weiter. Alle 4 Variablen im MD5_STR-Baustein sind bei mir gleich deklariert und initialisiert. Ich sehe keine logische Unterschiede.

Der folgende Code bleibt mit iStep=20 und bDone=FALSE hängen, d.h. MD5_STR-Ausführung endet nicht. Können Sie mir bitte mit diesem Problem helfen? Es geht bloß um den Aufruf des einzigen Funktionsblockes! Irgendwo habe ich einen Denkfehler.

Danke im Voraus.

PROGRAM P_TEST
VAR
bPerform : BOOL := FALSE;
bDone : BOOL := FALSE;
sInputString : STRING(250) := 'OSCAT';
fbMD5_STR : MD5_STR;
abMD5Hash  : ARRAY [0..15] OF BYTE;
sMD5Hash : STRING(32) := '';
iStep : INT := 0;
END_VAR

(*MD5 testing*)
IF (bPerform) THEN
CASE iStep OF
0:
fbMD5_STR.RUN  := FALSE;
bDone := FALSE;
sMD5Hash := '';
iStep := iStep + 10;
10:
fbMD5_STR(RUN := bPerform,
STR := sInputString,
MD5 := abMD5Hash,
DONE => bDone);
iStep := iStep + 10;
20:
IF (bDone) THEN                (*hier steckt es und geht nicht weiter*)
iStep := iStep + 10;
END_IF
30:
sMD5Hash := MD5_TO_STRH(abMD5Hash);
iStep := iStep + 10;
40:
bPerform := FALSE;
iStep := 0;
END_CASE
END_IF

[gelöscht durch Administrator]

3
BECKHOFF / Funktionsbaustein MD5
« am: 02. September 2015, 11:45:31 »
Der letzte Satz in der Beschreibung vom Funktionsbaustein "MD5_STR" in oscat_netlib121_de.pdf lautet:
Zitat
Danach steht am Parameter HASH der aktuell berechnete HASH-Wert zur Verfügung. (Siehe Baustein MD5-STREAM).
  • Es  gibt keinen Parameter "HASH". Wahrscheinlich ist der Parameter "MD5" gemeint.
  • "Baustein MD5-STREAM" muss "Baustein MD5_STREAM" geschrieben werden.
Dasselbe gilt für die englische Version oscat_netlib121_en.pdf. Außerdem wird der Parameter "MD5" in oscat_netlib121_en.pdf als Output-Parameter bezeichnet, was falsch ist (deutsche Version des Manuals ist in Ordnung).



Ich bitte Sie, mir mit der Anwendung des Bausteins "MD5_STR" zu helfen. Mein Code ist:

PROGRAM TEST
VAR
   bPerform : BOOL := FALSE;
   bDone : BOOL := FALSE;
   sInputString    : STRING(STRING_LENGTH) := 'some string';
   fbMD5_STR     : MD5_STR;
   abMD5Hash    : ARRAY [0..15] OF BYTE;
   sMD5Hash      : STRING(STRING_LENGTH) := '';
END_VAR

(*MD5 testing*)
IF (bPerform) THEN
   bDone := FALSE;
   fbMD5_STR(RUN := TRUE, STR := sInputString, MD5 := abMD5Hash, DONE => bDone);
   bPerform := FALSE;
END_IF
IF (bDone) THEN
   sMD5Hash := MD5_TO_STRH(abMD5Hash);
   bDone := FALSE;
END_IF

Meine Fragen:
- warum sind "STR" und "MD5" als "VAR_IN_OUT" deklariert? Logisch wäre für mich "STR" als Input und "MD5" als Output zu haben.
- wie soll der Parameter "MD5" initialisiert werden (denn er gilt als Input-Variable)?
- der oben angegebene Code liefert gleiche Verschlusselung unabhängig vom Wert der STR-Variable. Woran kann es liegen?

Mit freundlichen Grüßen

4
Here is my solution for those who need detailed instructions. (NOTE: I am using TwinCAT 2)

The first way: it is possible to open network lib as a project end export the POU you need (right click on POU, Export object...) and then import it in your project (Project->Import). Most probably, you will get some compilation errors as the imported POU will require other POU(s) missing. If not, you are lucky: mission complete. If it is the case, continue exporting and importing missing POUs. I gave up here because I did not know, how many POUs I needed to export/import. Now a hint: check dependencies using "Project->Show Call Tree".

The second way is to include network_lib and oscat_basic as they are. Here I got an error saying that the number of POUs in the project had become over some max (2048 in my case). This can be fixed by specifying a higher limit in the file "" (contained in my case in the folder: "C:/TwinCAT/Plc") like that: "MaxNumOfPOUs=4096". I think it is not nice but it does the job. Then, , I got a conflict with "TcMath.lib", where the function "FLOOR" (same name as in oscat_basic) is defined. Fortunately, only two functions (FLOOR and MODABS) from TcMath.lib were used in my project. Thus, it was enough to exclude TcMath library from my project, export MODABS from it, and import it back to my project (FLOOR is already defined in oscat_basic and does the same thing, I hope).

Conclusion: I do not think that I've done it correctly, when including libraries with thousands POUs into my project in order to use a single small POU from the whole set. It would be a nice new tool, which would allow for exporting a selected POU together with all its dependencies...

5
We need to encrypt strings using MD5 algorithm. The functional block 'MD5_STR' in folder 'CONVERT' of the OSCAT network library seems to do the job.

After adding the library 'beckhoff_network_121.lib' to the project, many errors appear of type:
Error 3747: (...): Unknown string length 'STRING_LENGTH'

Our guess was that the basic library is needed either. However, after adding 'oscat_basic_333.lib' to the project, the following problem appeared:
Error 3700: FLOOR (...): A POU with name 'FLOOR' is already in library '...oscat_basic_333.lib'

The function 'FLOOR' is contained in TcMath.lib. This library can not be excluded from the project as it has other functions, which are extensively used.

Please, help us to overcome the problem. If possible and appropriate, give an educational answer.

System info:
PLC Control Version v2.11.0 (Build 2220)
TwinCAT v2.11.2249
PC operating system: Windows 7 Home Basic N

Seiten: [1]