ssross
There is another report similar to this one so maybe this will add a little more info for debugging.   I trimmed the ladder to the single rung that still causes the error.
 
[203128%2F8651928%2Fmceclip0]
 
Adding the shunt 'Manual1' triggers the error.  After hitting the error the run button is unresponsive. 
 
File "/home/scott/opt/openplc/OpenPLC_Editor/editor/PLCGenerator.py", line 1085, in FactorizePaths
factorized_paths.sort()
<class 'TypeError'>: '<' not supported between instances of 'list' and 'str'
 
Reply 0 0
Write a reply...
thiagoralves
Update your editor and you will be good
Reply 0 0
ssross
I did that before reporting this.  It says that I am up to date but still doesn't seem to run.   I can give it some time, maybe things are held up in caches. ??
 
[203128%2F8652475%2Fmceclip0]
[203128%2F8652477%2Fmceclip0]
 
Or maybe I am not really running the latest?  The Linux install pulled an older version of python (3.9) and several libraries and maybe I have something crossed.   I'll try a clean reinstall.
Reply 0 0
thiagoralves
Latest release is 2024-02-28. Delete your release file at the OpenPLC folder and try checking for updates again
Reply 0 0
ssross
Re-download, rebuild, update and it doesn't work yet.  I did re-download the wxWidgets 4.1.1 but it seems to pickup 4.2.0 from somewhere. I doubt that has anything to do with this problem.
 
[203128%2F8652575%2Fmceclip0]
 
Updating reports success.  I looked at the code and it is trying to sort an array.  The array contents are (with indentation added):
[
 "[('Manual1', ('P::program0', 'contact', 53, 'reference'))]",
 "[('NOT(', ('P::program0', 'contact', 5, 'negated')), ('Stop1', ('P::program0', 'contact', 5, 'reference')), (')', ())]",
 [(
   "[('StartCycle', ('P::program0', 'contact', 3, 'reference'))]",
   "[('Zone1', ('P::program0', 'contact', 4, 'reference'))]"
  ),
  "[('RUN', ('P::program0', 'contact', 43, 'reference'))]"
 ]
]
 
Which at the top level has two strings and an array. It does give the error when sorted.
 
- - -
 
There is an update.sh in the directory that clones the repository and copies everything into new_editor/new_lib, but doesn't do anything with that data.  After the update (from the menu in the editor) and a restart, the file editor/ PLCGenerator.py is not the same as the one in new_editor.  If I copy new_editor/ PLCGenerator.py to editor, the program works.  Maybe I missed a step in the update?
 
The last steps in update.sh after cloning
    mv "./OpenPLC_Editor/editor" ./new_editor
    mv "./OpenPLC_Editor/matiec/lib" ./new_lib
    cp ./OpenPLC_Editor/revision ./
    rm -Rf OpenPLC_Editor
    echo "Update applied successfully"
Thanks,
Reply 0 0
ssross
Further, I did this starting from the download retrieved from the download page followed by an update.  I just tried starting from a clone of the repo.  The bug did not show in the stripped down program above, but still persists in the larger diagram that I took that from.   When I get back home I'll look into this. I'll try to set aside some time to look into PLCGenerator.py and maybe I can give a more complete description of the problem. (Or figure out what I am doing wrong.)
Reply 0 0
thiagoralves
Maybe the update is broken on Linux then. I’ll have to check this. If you just replace editor with new_editor you will be on the newer version. I just need to know if this bug also happens on the new version
Reply 0 0
Pedro Coimbra
A few days ago I reported a similar error, "Compilation error after updating OpenPlc" ('<' not supported between instances of 'str' and 'tuple').
Although it is not exactly the same error, perhaps they are related. If we compare the bug reports, the traceback section is very similar. Both errors occur in ladder logic code with multiple branches.
Reply 0 0
thiagoralves
Do they occur in the latest version of the editor (release 2024-02-29)?
Reply 0 0
Pedro Coimbra
Yes, they do. 
Queimador_1_2_Bug.png
Reply 0 0
Pedro Coimbra
Although the image shows SFC code, the error occurs in a transition written in Ladder logic.
Queimador_1_2_Bug_ladder.png
Reply 0 0
thiagoralves
Perfect. I'll take a look at that then
Reply 0 0
Paolo
I don't know if this will help but I have the same problem
 
the bug appears when I add a timer (TON in my case)
Reply 0 0
ssross
I have another project file that cause a similar problem attached.  I looks like
[203128%2F8657754%2Fmceclip0]
 
This one causes a crash in the same place (factorized_paths.sort()) except this time it is between a string and a tuple.
 
I've been trying to debug the problem a bit and what I found is that the result of a recursive call to the FactorizePaths() function builds a list containing a tuple and a string. Since I don't actually know that FactorizePaths is suppose to return, take the rest of this post as entertainment only.
 
The input from the net above is
[
    [
        "[('StartCycle', ('P::program0', 'contact', 3, 'reference'))]",
        "[('RUN', ('P::program0', 'contact', 43, 'reference'))]"
    ], [
        "[('Zone1', ('P::program0', 'contact', 4, 'reference'))]",
        "[('RUN', ('P::program0', 'contact', 43, 'reference'))]"
    ],
    "[('Manual1', ('P::program0', 'contact', 53, 'reference'))]"
]
And the output (just before the crash) is
 
[
    [
        "[('Manual1', ('P::program0', 'contact', 53, 'reference'))]"
    ], [
        ([
            "[('StartCycle', ('P::program0', 'contact', 3, 'reference'))]"
        ], [
            "[('Zone1', ('P::program0', 'contact', 4, 'reference'))]"
        ]),
        "[('RUN', ('P::program0', 'contact', 43, 'reference'))]"
    ]
]
Sort is trying to compare the string (with 'Manual1') with the tuple ('StartCycle' / 'Zone1'). and failing.
 
I doubt that this is a robust fix but swapping the list concatenation in FactorizePath lines 1075 and 1076 to be 
if len(elements_paths) > 1:
factorized_paths.append(eval(same_path) + [tuple(elements_paths)])
else:
factorized_paths.append(eval(same_path) + elements_paths)
Puts the string (same_path) first and the error doesn't happen in this one case.  This would probably break something else, for example if there were more parallel paths to 'Run'.
 
I also found that simply removing the sort works.
 
Reply 0 0
thiagoralves
Reply 1 0
Write a reply...
Reply