cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Failed to write Data Layer Node from python webserver

Failed to write Data Layer Node from python webserver

lukas1
New Poster

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.

2022-08-24_11h00_57.png

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.

2022-08-24_10h52_01.png

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 ....

2022-08-24_10h53_01.png

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

1 REPLY 1

nickH
Community Moderator
Community Moderator

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). 

2022-09-01_16h07_40.png

 

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

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist