get_attribute_config
|
|
---|---|
Hi, I am trying to change the format and unit of my PyTangoDS attributes dynamically. For that I want to use the get_attribute_config() method within the DS. I got it working in Python2 but now with Python3 and PyTango9.2.5 I get the following error:
Any ideas what might have changes? |
|
|
---|---|
Hi, Generally the segfault indicates something is going wrong on a low level, i.e. nothing wrong with your code but the PyTango library. If you were using your own threads etc., I would say it might be related to thread safety, but here you seem to be using only PyTango provided stuff, right?, so it should work (and actually also in your own threads it should be thread safe). On Windows, this would point toward a compilation error for the PyTango package, not sure what can go wrong on Linux. How did you install it? (Pip, Conda tango channel, self compiled, other?) As a quick first step I recommend trying a different version of PyTango, e.g. pip install PyTango==9.3.1 (Note that on Windows the 9.3.2 has it's own install problems right now, but 9.3.1 seems to be OK, and on Linux probably both are fine) What OS are you on, what is the hardware (Raspberry Pi)? Regards, Lenny PS: Seeing your class is called PhytronMCC, we are also using Phytron (here several phymotion controllers and PyTango device servers), so if you have any troubles there I'm happy to discuss. |
|
|
---|---|
Hi Leonard, thanks for the quick reply. I just updated from PyTango 9.2.0 to 9.2.5 for Py3 compatibility. With PyTango 9.2.0 and Py2 it was working fine. I actually installed PyTango and Tango all via apt from the official channels for the Raspi. I use Raspberian Buster, the latest release 32bit. I actually want/learned that the Tango and PyTango versions should only differ at the last digit. So in order to get Tango 9.3.x and PyTango 9.3.x installed on the Raspi I would need to compile a lot myself, which I wanted to avoid, since they are not available in the official software channels so far. P.S.: thanks for offering help with the Phytron. Actually we are only using the MCC2 controller for now and we are pretty happy with that. Our TangoDS can be found here: https://github.com/dschick/pytango-PhytronMCC2 I was wondering if it might be worth to list it also in the official DS list? However, I am not very familiar with SVN - only git. |
|
|
---|---|
dschick I'm having the same problem :
Have you solved your problem ? |
|
|
---|---|
Hi dschick I tried it out with a simple test case in Pytango 9.3.2 and get the same kind of failure. It looks like a problem in the conversion of the string parameter from a Python object to a C++ string. The failure is specifically for Unicode strings (so native Python 3 strings). Changing the parameter to a byte string works in Python 3 (and is probably why it was working in Python 2). So as a workaround:
Another note, unrelated to this issue: Looking at the code in the repo you linked, and I suggest you call the super class's `init_device` instead of `get_device_properties` directly. The high level API automatically gets the device properties, if you call its `init_device` or don't override it.
Regards, Anton |
|
|
---|---|
Hi Anton, many thanks for the help. So both suggestions are working perfectly fine. However, it seems, that there is no set_attribute_config anymore available for the Device class. This method is only available for the DeviceProxy. So what would be the correct way for setting/changing AttributeConfigs like the unit of an Attribute from within the actual TangoDS class? I tried already with self.get_device_attr() but it seems that I cannot change the unit of the returned WAttribute. Of course I could do a workaround to open a DeviceProxy within the class to change the Attribute Config, but I do not think that this a really elegant way of doing this. Best Daniel |
|
|
---|---|
I also opened an issue at Github: https://github.com/tango-controls/pytango/issues/361 |
|
|
---|---|
Hi Daniel Yes, I see the set_attribute_config method is not exposed in Python. On closer inspection, I notice that PyTango is missing quite a few methods from the C++ layer. The get_attribute_config we are calling above is the implementation for the original device version 1 of the IDL. PyTango is also exposing get_attribute_config_2 and get_attribute_config_3 methods which provide the newer implementations. The latest, get_attribute_config_5 is missing. As for setting, PyTango exposes set_attribute_config_2 and set_attribute_config_3, but not set_attribute_config_5. You could try something like this:
We'll need to add the missing methods in PyTango. Anton |
|
|
---|---|
okay I see. that is also why it is a bit hard to find some things in the PyTango Documenation, that are available in C++. Anyhow, many thanks. it is working now as expected and as before in PyTango9.2.0 in Py3. I just want to mention, that the inputs for the unit and format, etc., also need to be byte strings. So here is the working snippet:
|