Download to a controller from a DOS prompt

I like to try and document any ‘slightly unusual’ customer requests in these forums… I figure if one person asks about it, there are bound to be more.
Besides, sharing is caring, right?

My coworker Selam took a call from a customer (who was also an integrator) and came up with the solution. I just fleshed it out and stuck it here.

The integrator needed to be able to email strategies to the customer and have them download them, but he did not want to give them full debug ability. (For lots of reasons).
He also did not want to use the microSD card option that our controllers have (mostly for the reason that he could not be sure that the customer would not put the wrong card in the wrong controller).
So, what options are left then?

PAC Terminal to the rescue.

I love PAC Terminal. I think it misses out on a lot of love that other parts of PAC Project get… That said, in this case, PAC Terminal, in the hands of the wrong customer, can still do some damage. For example, right there on the top line under, ‘File’ are the commands… well, just take a look at them…

So, yeah, the customer could wipe out the controller pretty quick and easy.

The answer to this integrator’s question then lies in the fact that there is a command line version of PAC Terminal kicking around on his hard disk, so he just needs to give that to the customer and with a simple process that could become a DOS batch file, you can download the strategy after emailing it to the customer.

Let’s look at how you do this.

To start with, you are going to need to collect a few dll’s and the actual .exe.
You can find all these in your ‘c:/program files/Opto 22/PAC Project’ directory.
Here is a list of what you will need:

  • iocom.dll
  • ioerr.dll
  • iocdb.dll
  • iosnif.dll
  • termcl.exe
All these can reside in a single directory on the customer's computer. They don't have to go back into the c:/Program Files directory. They just have to all be in the same directory, no matter what it's called or where it's located.

Right, so now that you have all those (you did remember to copy them, not move them, right?.. wouldn’t want to break your copy of PAC Terminal…), we can move on to the strategy.

Rather than give the customer the whole strategy, which they could then download PAC Control Basic off our web site and have a snoop around in, we can give them just the compiled version of the strategy.
To do this, go into PAC Control, and click on ‘Compile’:

It will put the compiled file into the same directory as the rest of the strategy.
It will have a name that reflects the name of the strategy and the control engine.
So in the case of the example here, it’s called ‘dyndns lookup.learning center.cdf’
Nice name, totally useless for what we need to do with it.
We need the name to be trimmed down to the old 8.3 standard. That is, 8 characters in the file name, no spaces, and a three-letter extension (which we do have here).
We could rename it, but we also need the control engine to have no spaces in it. (Which you should be doing from the get-go).

You can see here I went into PAC Terminal and renamed my ‘learning center’ to ‘pac-lc’. Much better.
But remember, it needs to be called the same thing on the customer’s computer as well.

So rename your long file, and then copy it into the same directory as the other files…
(If you had just called the strategy and the control engine shorter, spaceless names, Ben, none of this renaming stuff would have been necessary… right, note to self…)

Let’s see what we have in that directory now:

Ok, that’s nice and neat.

Now for the OptoMagic©

To get us warmed up, open a command prompt, change directory to where you put all those files, and pull up the help by issuing ‘termcl.exe -h’
That will show you the help options as shown below;

As you can see, we can do a few different things.
However, the one our integrator is interested in is the download.
So here then, is a screen shot of me doing just that;

After the download, we just need to run the strategy. You can see that as the last command issued in that screen shot.

That’s it. The ‘stat’ light on the controller will go from orange to green indicating that the strategy is running and we are all done.

Fantastic. The customer has minimal files on their computer, they can’t do a lot of ‘damage’ to the controller with those files.
You can email the .cdf file to them easy, and either talk them through the download/run process, or make a batch file for them.
Remember, the customer needs to have the control engine configured with the same name on their computer (which you can do through termcl.exe as well). The IP address matters not; it’s the name that must match between the integrator’s computer and the customers.

Not exactly code, so I will spare you my usual sign off.

Great!! Thanks

I had personal need to use this method this weekend and followed my own instructions… and yeah, it did not work.
I guess the software has been tweaked sometime over the past 9 years.

The good news is, you just need to ALSO add ControllerDefs.dll to the list shown in the thread.

Also the source directory for these .dlls has changed.
C:\Program Files (x86)\Opto22\PAC Project 10.3

Here is a screenshot of the files you need (and I just zipped up this directory with the .cdf included and sent to the customer).


Just a slight clarification on the process. If the customer does not have ANY PAC Project files loaded, you will need to add the controller name/IP to their computer before doing the download.
Here is an example of that command;
.\TermCL.exe -a ContName tcp 22001 2 2000

Then you do the download;
.\TermCL.exe -d ContName StraName.cdf

Then you tell the controller to run;
.\TermCL.exe -r ContName

Other than that, everything worked exactly as it should.