FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
08-24-2022 11:37 AM - edited 08-24-2022 11:40 AM
Hey all,
I have got the following issue when trying my self on realizing a python webserver.
For a sample project I try to pack a C++ program for the main program logic and a python webserver for the user interface together in one snap and let both parts interact with each other. Therefore I am trying to read / write data layer nodes from both programs. For I am quit familiar with C++ programming, the C++ side is not the problem and is working perfectly fine. For the python part I took the python-webserver-example from the SDK and adjusted it to my requirements. The webserver itself starts up and is reachable via the corrosponding sidebar entry, but fails when trying to submit values to the ctrlX Data Layer.
To demonstrate the problem I created a minimal example I attached to this post. It includes a very simple C++ snap that provides some Data Layer Nodes as well as a not less simple version of a python webserver. The server is supposed to write a value, entered by a textfield, to one of the nodes provided by the C++ application. The datalayer path is set hard coded in the python script.
What happens is that the webserver reacts to the button press and internaly stores the right values, but failes when writing to the datalayer (line 156 in webserver.py) and is not reachable for some seconds.
The programs seems to run on an exception in that line, shuts down and restarts due to the restart condition given in the snapcraft.yaml.
The write method for the Data Layer client is directly taken from the SDK sample python webserver - at least I did not change anything on purpose appart from the implementation of my logger, wich is tested and runs perfectly fine ....
Probably I am just to confused to see something realy obvious....
To run the sample project you need the following prerequisites:
- a qemu setup for python development
- sdk version 16 installed on your qemu
- a virtual or real ctrlX to test
- the minimal exaple project I attached (just extract all three directories to the same location within your build environment, then all dependencies will by satisfied.)
Hope, the problem got clear and you are able to help me.
Thanks a lot and Best Regards
Solved! Go to Solution.
09-01-2022 04:15 PM
Hi Lukas,
I just installed your Data Layer provider (nodeprovider) and also installed the SDK sample sdk-py-webserver. I was able to write with the python webserver of the SDK to all the values your sample provides in the Data Layer (bool, double, int, string).
So your provider works totally fine and your problems come form your webserver sample. The webserver sample in the SDK also works fine. So I would recommend to compare these tow in detail and see where the differences are.
Best regards,
Nick