refresh settings live in DIA or programmatically reboot ConnectPort

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

  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!

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:

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!

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.

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

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:

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