RSLogix500 Compare through Command Line?

bjh

Member
Join Date
Jul 2010
Location
Madison, WI
Posts
257
I've been using Git and Microsoft's VSTS for software versioning, source control and work tracking lately for all of my projects, PLC and C# to great success - except for one thing.

Because RS500 .RSS files are compiled binaries (and ladder logic) they cannot be compared easily. The RSLogix500 Compare tool is great for this and I'd like to be able to launch it automatically as my "diff" tool in git for these files but I haven't had any success in figuring out how!

I'm looking for something command line based, like this:
Code:
rs500.exe /compare "oldProgram.RSS" "newProgram.RSS"
 
Well, I couldn't find a way to make RSLogix 500 open in the "Compare" mode through the command line, so I made an ugly hack instead. It's made even more complicated for me because I keep my git tools on my host and my PLC Programming in a VMWare image and use unity mode which makes things even more worse.

So, that being said, here's what I did.

I made a .bat that opens my VM, enters unity mode and opens a custom RSLogix 500 Launcher with arguments as the source/compare project:

Code:
REM Compare500RSS.bat
REM @echo off
C:
cd C:\Program Files (x86)\VMware\VMware Workstation

REM Start VM
vmrun -T ws start "C:\Users\xxxx\Virtual Machines\RSLogix 500\RSLogix 500.vmx" nogui

REM Now run application 
vmware-unity-helper.exe -r -G:6 -V:1
vmrun -T ws -gu xxxx -gp xxxx runProgramInGuest "C:\Users\xxxx\Virtual Machines\RSLogix 500\RSLogix 500.vmx" -activeWindow -interactive -nowait "C:\Utilities\RSlogix 500 Compare.exe " %1 %2

exit

I then used this Compare500RSS.bat as my external "git difftool" in my git config

Code:
[diff]
[difftool "Compare500File"]
	cmd = "\"C:/Compare500RSS.bat\" \"$LOCAL\" \"$REMOTE\""
[diff]
	tool = Compare500File

The "RSLogix 500 Compare.exe" I made in c# - the launcher translates the path to what the VM sees in the shared folder to my host hard drive, loads up RSLogix, then (disgusting hack alert!!!) uses a series of keystokes to call up the compare utility and enter in all the info (base project path, compare project path etc), maximize and rearrange windows etc. Again, this was whipped up on the fly and is not pretty or perfect but it does work.

Code:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RSlogix_500_Compare
{
    class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]

        [DllImport("user32.dll")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        [DllImport("user32.dll")]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        static void Main(string[] args)
        {
            //Start RSLogix
            ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
            si.CreateNoWindow = true;
            si.FileName = "C:\\Program Files (x86)\\Rockwell Software\\RSLogix 500 English\\rs500.exe";          
            si.UseShellExecute = false;
            System.Diagnostics.Process.Start(si);

            //Wait for it to boot
            System.Threading.Thread.Sleep(3000);

            //Get the handle of the RSLogix window
            System.IntPtr iHandle = FindWindow(null, "RSLogix 500");
            if (iHandle != IntPtr.Zero)
            {
                //Maximize the window
                ShowWindow(iHandle, 3);
                //Alt-t then c for compare
                SendKeys.SendWait("%t");
                SendKeys.SendWait("c");
                //Send the paths
                SendKeys.SendWait(convertFilePath(args[0]));
                SendKeys.SendWait("{TAB}{TAB}{TAB}");
                SendKeys.SendWait(convertFilePath(args[1]));
                SendKeys.SendWait("{ENTER}");
                //Wait for window and say OK
                System.Threading.Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                //Scroll down to first ladder file and open it
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}");
                SendKeys.SendWait("{ENTER}");
                //enter the passcode
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("passcodehere{ENTER}");
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("passcodehere{ENTER}");
                //Arrange the windows to default project
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("%w");
                SendKeys.SendWait("a");
                SendKeys.SendWait("{ENTER}");

                Application.Exit();
            }
        }
        private static string convertFilePath(string path)
        {
            //Convert file path for VMware image from C:\ to Z:\C\
            StringBuilder newPathSourceProject = new StringBuilder(path);
            newPathSourceProject.Replace("C:\\", "Z:\\C\\");

            return newPathSourceProject.ToString();
 
        }

    }
}

I hope someone can use this in the future because I sure was frustrated looking for the easy way with a command line switch. If you don't have a VM you can use the launcher program directly as your git difftool or maybe an AutoHotKey script to do the same thing.
 
Last edited:
Lol

I laughed so hard at Disgusting Hack Alert i nearly choked on my beer lol. I'm just about to start looking at a proper solution for this and was doing the rounds quickly on the net to see what anyone else had come up with so far. I really like git hub and want to make it work for me the same in PLC and HMI the same as it does for .net, python etc. Wish me luck.
 
I laughed so hard at Disgusting Hack Alert i nearly choked on my beer lol. I'm just about to start looking at a proper solution for this and was doing the rounds quickly on the net to see what anyone else had come up with so far. I really like git hub and want to make it work for me the same in PLC and HMI the same as it does for .net, python etc. Wish me luck.

I'll give you a head start on working with RSS files and python, use the module olefile

https://pypi.org/project/olefile/

I have recently come to find that rss files are essentially OLE encoded files. After you install oelfile, try something like this:

Code:
import olefile

with olefile.OleFileIO('my_program.RSS') as ole:
    # list the directory structure of the file
    ld = ole.listdir()
    for x in ld:
        print(x)
 
Sounds good

I’ll definitely take a look into that. Been a while since I used ole but as usual python to the rescue, for every problem an import and for every import an example. Which kind of files did you find were Ole masquerading as RSS? I’ve been looking for the file formats for .acd files (Allen Bradley plc project) and also for the HMI graphics files to decode them into text or similar to get a diffable Tool Output. Haven’t tried that hard yet but any help would be appreciated.
 
The only two I've noticed that are OLE encoded are RSS and MER. Not sure how far you will get with the files within the MER, I'd be curious to hear how far you get. The ACD is a mystery, I've spent a bit of time trying to understand it with no luck. It is most likely a proprietary encoding. I'd love to be wrong.
 
Interesting

The compiled mer file is of less interest to me, more the binary files for each of the types of HMI content (gfx,ggfx etc). With Rockwell’s reputation of buying competitors products and rebadging them I doubt they would go to the bother of inventing their own format but who knows? I suppose I do have the luxury of viewing the files as xml output which could give me a head start on the file format. All the information is encoded in there somewhere. With the ACD I’m not overly concerned, they have a top notch compare tool and i have it already set up and working as a diff tool for a logic test project. What’s lacking is the same ability to objectively view hmi project content...

Hell I even have the executable that translates the files into xml output and could trace the call stack for an entry point. As if I needed another project to get cooking on.
 

Similar Topics

Hello experts, I am just starting with AB programing, I have a questions regarding a compare done in an old RSlogix500 and causing me issues when...
Replies
5
Views
1,913
So here's my situation, I have been tasked with modifying the logic to mimic a button press in the PLC. I have two identical machines however one...
Replies
6
Views
513
Hello, I'm new to programming. I'm using RSLogix500 to modify an existing program for a SLC500. My plan was to use one of the existing inputs...
Replies
26
Views
1,906
So i have an allen bradley rack (2080-LC50-24QWB), i have it connected through ethernet. I dont have an offline program so im trying to upload...
Replies
6
Views
622
Hi Everyone, I am supporting a system which runs on a SLC 500 (1747-L532). A fault has developed whereby the output state of some digital outputs...
Replies
10
Views
957
Back
Top Bottom