# refresh settings live in DIA or programmatically reboot ConnectPort

**URL:** https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768
**Category:** Python
**Created:** [January 24, 2011, 10:19pm UTC](https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768 "2011-01-24T22:19:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![avoinemt](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@avoinemt](https://forums.digi.com/u/avoinemt)
#### Post date: [January 24, 2011, 10:19pm UTC](https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768/1 "2011-01-24T22:19:33Z")

</div>

Hi,

I’m using a ConnectPort X4 to run a DIA application using Python. My settings (stored in a Yaml file) changes over time, in reaction to some commands or state changes of the system. I would like to force the DIA framework to take these changes into consideration.

I thought of 2 ways of doing this (#1 being the most elegant way, if possible):

1. Make a call in my python module that will inform the running DIA instance that it should re-read the dia.yml file, apply changes and restart the appropriate services/devices/etc.

2. Make a call in my python module that will reboot the ConnectPort unit, hence restarting my program through an auto-start setting.

Is this possible?  
Thanks

---

<div class="post-metadata">

### Author: ![DenzChoe](https://avatars.discourse-cdn.com/v4/letter/d/53a042/32.png) [@DenzChoe](https://forums.digi.com/u/DenzChoe)
#### Post date: [January 25, 2011, 1:53am UTC](https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768/2 "2011-01-25T01:53:20Z")

</div>

> 1. Make a call in my python module that will reboot the ConnectPort unit, hence restarting my program through an auto-start setting.  
> There’s some function inside the CPX4 firmware called the “watch dog”. Haven’t mess around with it yet, but I presume [do correct me if I’m wrong] that it triggers a system reset if the main program, due to some fault condition is detected. Perhaps it detects service errors too. Skimmed through the forums and read about it before. Haven’t done it though. [Look under Service Folder inside the iDigi Dia Package 1.3.18 folder]  
> Do let us know how your discovery goes!

---

<div class="post-metadata">

### Author: ![avoinemt](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@avoinemt](https://forums.digi.com/u/avoinemt)
#### Post date: [January 25, 2011, 2:46pm UTC](https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768/3 "2011-01-25T14:46:49Z")

</div>

DenzChoe, thanks for your insightful comment. I looked into the code of the watchdog service and it uses a (local) RCI request using rci.process\_request to reboot the unit. Here’s the code:

```auto
from rci import process_request
process_request('')

```

That works, and it opened a whole new world of possibilities using RCI (I initially had overlooked the RCI when I first read the documentation).

Now, I wish my first option worked too, so if anyone has some ideas, I’m all ears!

---

<div class="post-metadata">

### Author: ![DigiGuy42](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@DigiGuy42](https://forums.digi.com/u/DigiGuy42)
#### Post date: [January 25, 2011, 3:10pm UTC](https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768/4 "2011-01-25T15:10:02Z")

</div>

Right now, #1 is possible in the core features, but in practice all the pieces are not there. If you change and apply new settings with something like the ‘settings\_device’ or internally, the ‘apply\_settings’ method of the driver class will be called and should be able to detect and dynamically implement those changes. However, most of the drivers don’t have the intelligence implemented to do that.

If you run a known, limited configuration, you could consider augmenting the drivers that you use with dynamic setting awareness. Doing that for all supported drivers is something that is on the roadmap as a possible update in a future release of Dia.

---

<div class="post-metadata">

### Author: ![avoinemt](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@avoinemt](https://forums.digi.com/u/avoinemt)
#### Post date: [January 28, 2011, 3:28pm UTC](https://forums.digi.com/t/refresh-settings-live-in-dia-or-programmatically-reboot-connectport/2768/5 "2011-01-28T15:28:43Z")

</div>

DigiGuy42, thanks for the reply. Following your advice I attempted to reload the yaml file using this piece of code:

```auto
fd = open(os.path.join("WEB/python", "dia.yml"), "r")
SettingsBase.load(self, fd, "yaml")

```

This indeed calls the ‘apply\_settings’ method of each driver, and it appears to work fine. However, the driver I’m using for my zigbee device (Massa M3) sets its configuration at startup in the xbee device configuration blocks and so it ignores my changes, meaning that it does not reconfigure the device to use the new ‘reading interval’.

I thought of restarting the driver, so I tried to call stop() and start() on the device driver like so:

```auto
deviceDriverManager = self._coreServices.get_service("device_driver_manager")
deviceDriver = deviceDriverManager.instance_get("1-1-1023") #1-1-1023 is the instance name
deviceDriver.stop()
deviceDriver.start()

```

But it doesn’t work, there seems to be some bugs in there. This is what I get:

Exception in thread Thread-3:  
Traceback (most recent call last):  
File “./threading.py”, line 442, in \_\_bootstrap  
File “./threading.py”, line 607, in run  
File “C:\dev\digi\itraxDigi\custom\_services\itrax\_comm\_service.py”, line 192, in run  
File “C:\Program Files\Digi\DigiPython\Dia\Dia\_1.3.18\src\devices\vendors\massa\massa\_m3.py”, line 418, in stop  
File “C:\Program Files\Digi\DigiPython\Dia\Dia\_1.3.18\src\devices\xbee\xbee\_device\_manager\xbee\_device\_manager.py”, line 588, in xbee\_device\_unregister  
File “C:\dev\digi\itraxDigi\custom\_devices\itrax\_xbee\_device\_manager.py”, line 7, in xbee\_device\_instance\_event\_spec\_remove  
File “C:\Program Files\Digi\DigiPython\Dia\Dia\_1.3.18\src\devices\xbee\xbee\_device\_manager\xbee\_device\_manager.py”, line 685, in xbee\_device\_event\_spec\_remove  
XBeeDeviceManagerEventSpecNotFound: event specification not found

So I have 2 questions:

1. Is it supposed to work in the first place?
2. If I want to submit patches to the Digi python dev team, how do I proceed (I did my homework and fixed some of the issues, though now I’m stuck)?

Thanks.

Edit: forgot to mention, I use DIA 1.3.18
