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

fix s7 sfb call parsing & index out of range errors #192

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,11 @@ public Block GetBlock(ProjectBlockInfo blkInfo, S7ConvertingOptions myConvOpt)
if (!newAwlCode.Contains(akRw))
newAwlCode.Add(akRw);
}
akRowInAwlCode++;

if (akRowInAwlCode < retVal.AWLCode.Count - 1)
{
akRowInAwlCode++;
}
}
((S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode]).NetworkName = tx1;
((S7FunctionBlockRow)retVal.AWLCode[akRowInAwlCode]).Comment = tx2;
Expand All @@ -713,7 +717,7 @@ public Block GetBlock(ProjectBlockInfo blkInfo, S7ConvertingOptions myConvOpt)
akRw.CombineDBAccess = false;

//Db Zugriff zusammenfügen...
if (akRw.CombineDBAccess)
if (akRowInAwlCode < retVal.AWLCode.Count - 1 && akRw.CombineDBAccess)
{
S7FunctionBlockRow nRw = (S7FunctionBlockRow) retVal.AWLCode[akRowInAwlCode + 1];
nRw.Parameter = akRw.Parameter + "." + nRw.Parameter;
Expand Down
6 changes: 3 additions & 3 deletions LibNoDaveConnectionLibrary/PLCs/S7_xxx/MC7/CallConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void ConvertUCToCall(S7FunctionBlock myFct, S7ProgrammFolder myFld
for (int n = 0; n < myFct.AWLCode.Count; n++)
{
S7FunctionBlockRow row = (S7FunctionBlockRow)myFct.AWLCode[n];
if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "1" || row.Parameter == "7" || row.Parameter == "3" || row.Parameter == "16" || row.Parameter == "14") && inBld == 0)
if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "1" || row.Parameter == "7" || row.Parameter == "3" || row.Parameter == "16" || row.Parameter == "14" || row.Parameter == "9") && inBld == 0)
{
retVal.AddRange(tempList);
tempList.Clear();
Expand Down Expand Up @@ -418,7 +418,7 @@ public static void ConvertUCToCall(S7FunctionBlock myFct, S7ProgrammFolder myFld
}
#endregion
}
else if (inBld == 3 || inBld == 16 || inBld == 14)
else if (inBld == 3 || inBld == 16 || inBld == 14 || inBld == 9)
{
#region FB Aufruf
tempList.Add(row);
Expand Down Expand Up @@ -542,7 +542,7 @@ public static void ConvertUCToCall(S7FunctionBlock myFct, S7ProgrammFolder myFld
callRow = row;
afterCall = true;
}
else if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "4" || row.Parameter == "17" || row.Parameter == "15"))
else if (row.Command == Mnemonic.opBLD[(int)myOpt.Mnemonic] && (row.Parameter == "4" || row.Parameter == "17" || row.Parameter == "15" || row.Parameter == "10"))
{
//Block Interface auslesen (von FC oder vom Programm)
S7DataRow para = myblkFld.GetInterface(callRow.Parameter);
Expand Down