Reset controller from software?

In OptoControl there used to be a command that would reboot the controller from software.

I don’t find a command that does the same thing in PAC Control, but I did find the MMP address F038 0000 where I can write a 5 and it will supposedly do so… However, it doesn’t always seem to work even though I get a result from the write command of zero (success). Is there some other way to do this, or am I missing something?

CM_MMP_Result = WriteNumToIoUnitMemMap(LocalUnit, 0xF0380000, 0x00000005);

// Note: LocalUnit is set up as a Generic OptoMMP Device with loopback

It worked once, then not again, yet I can still do this from PAC Manager successfully…

from OPTO MMP Manual (1465), Page 127

0x00000005 Reset hardware, which is just like cycling power to the
device. If point configuration information has not been stored to flash or
flash has been cleared (op code 04), points are reset to defaults. After a
hardware reset, the device waits for a Powerup Clear before communicating with a master.

I am afraid that I can only comment on our experience.

We write to this MMP location on a PAC-R1 using php from a PC and get a reset every time.

writeQuad("F038 0000", "00000005");

Only question I can think to ask is ‘What are you writing to your Controller from?’

Looks like you might be writing to the controller from the strategy - I don’t know how the controller might react to being written to by itself.

Hi Guys,

Writing that 5 to F038 0000 should work the same whether the command is coming from some php code or PAC Manager or a bit of OptoScript running on the same device. Of course, you have to be careful when writing/running code that does a “reboot thyself” because that can be tricky to troubleshoot, and even wrap your mind or brain around.

For example, you’d only have a split second to see that CM_MMP_Result came back zero (I’m assuming you’re using the PAC Control debugger to see that?) since the device should be busy rebooting itself and no longer communicating for a few seconds. The strategy itself will then be blown away, at least out of RAM.

Are you stepping through this code to troubleshoot in PAC Control’s debugger? Can you see the device in question? I’m guessing that eventually you plan to have your strategy options configured to store the strategy to Flash Memory then autorun? (That way after the logic to reboot executes, and the reboot finishes, the strategy will be reloaded from flash and start running again at block 0 of the Powerup chart.)

Any more details you can provide about your bigger picture/situation would be interesting to know, and might shed more light on what could be happening there.

Don’t forget, our Product Support is FREE and very experienced/knowledgeable too.


I seem to be bumping a lot of older threads these days, but I’m trying to implement this functionality in the strategy I’m working on.

Could someone please clarify “LocalUnit is set up as a Generic OptoMMP Device with loopback”? I’ve created a pointer for a Generic OptoMMP Device, but I’m not sure how to refer that pointer to my controller (a SNAP-PAC-S2).

Essentially, I plan to connect a pushbutton to an unused input module on a SNAP-PAC-SB2 brain and have that button press initiate a “Stop charts, reset controller” function via OptoScript.

Hi JRiggles,

I don’t think you need a pointer for this use case, if I’m understanding you correctly.
However, to have the your SNAP-PAC-S2 be able to include some code, e.g. when that button press is detected, to essentially “reboot myself,” you’ll need an I/O unit configured. That’s the first parameter passed to the WriteNumToIoUnitMemMap command, shown in the first post of this thread.

In the I/O Units folder in your strategy tree, you’d just configured a I/O Unit that looks like this:

Make sense?

Thanks for the reply Mary! I did eventually realize that particular mistake. I’ve now got a Generic OptoMMP Device configured for loopback and I’m passing it to the ‘WriteNumTo…’ command. My button is connected to an input on an IDC5D on a SNAP-PAC-SB2 connected to the controller.

All That said, I also seem to be having the same problem as the OP wherein the ‘reset’ only appears to work once (if at all).

I’ll try to share my OptoScript later (it’s on a different computer), but the gist is that my Powerup chart has a block for ‘IF Button pressed THEN >> Turn on an LED (indicating reset has been ordered) >> Stop all charts other than Powerup (maybe unnecessary?) >> issue reset command via MemMap’

EDIT: Probably a stupid question, but does my ‘Generic OptoMMP Device’ have to be named “LocalUnit”? Or are we just using the names from the example above for consistency?

You can name your I/O Unit anything, I usually call one that’s a loopback/ “self” but for this reply I named it to match like you suspected.

With your digital inputs, don’t forget our built-in latch function (so you don’t have to worry about missing a button press).

Do share your OptoScript!