FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
04-02-2024 08:54 PM
Hello,
I would like to know if it has to be always with datalayer.register.node when I create my own App? Can i try with hello world App?
Solved! Go to Solution.
04-02-2024 09:21 PM
Hi @Josaphat_Aviles ,
I'm not following your question. What do you mean, does it always have to be with datalayer.register.node?
What are you trying to accomplish with your custom application? Apps can be installed in ctrlX OS with no datalayer integration at all.
There are tons of examples in the SDK Github.
04-02-2024 10:49 PM
In the video ( LINK), you create your own app, using the example creating pythagoras App. And the templaste that you use is datalayer.register.node.
My question is.. What is your recommendation.. Do i have to to the same?? or it doesnt matter if I what sample i use?
04-02-2024 11:03 PM
It is entirely up to you. First of all, what language would you prefer? You can look through the Github examples I linked above.
I prefer c++, so here is the example I'd start with for providing nodes to the datalayer.
04-03-2024 01:53 AM
Thank you @Sgilk for your promt reply,
Yes is exactly what I mean, great example that you mention.
I am using C++ too. However the configurations of snapcraft.yaml and CmakLists.txt there are not the same like Hello.World proyect. for obvously reason.
However... what happend when I tried to use another libraries like: curl, cpprest, nlohman, etc.
When I tried to build the snap to arm64, collapse and I dont know why, even the output the terminal show something like *EXPERIMENTAL* --target-arch for core20 enabled.
I already try to force to build in arm, but it doesnt work.
And perhaps your question is... What do you whant to do???
Well.. basically I just whant that when Ctrlx 3 and Ctrlx 7 turn on.... detect the memory SD (with rest api) and then dectect the free capacity...
If free capacity is lower than 90% of Total capacity then:
Start to recording Data (millions of data) during aprox 1 minute, then Save data in csv in that specific SD memory. After finish to save the data... return to start again the cycle... and detect the free capacity...
When the free capacity is lower than 10% of Total capacity then: stop to save data.
All of this has to be plug and play with memory SD.. I mean the C++ code has to recognize the name of SD memory in order save it in a specific path.
The final user.. just plug and play the memory SD after each month and thats all.. The final user... just plug and play the SD memory in his laptop and start to play with data. Not more..
So with this information... what do you recommend? With all your expertise.. what do you think that will be the more efective way to do that?
Currently I am using Ctrlx Works to open a SSH.. then open it with Visual studio code and then select the app hello.world .. erase all in the main.cpp and start to code in that file.. then after many libraries like curl... and so on.. start to fail when I build snap with buil snap arm64. So I can not download to upload in the Ctrlx Core 3 and install it.
04-04-2024 02:25 AM - edited 04-04-2024 03:27 PM
There is a lot to unpack here. Unfortunately, I can't write the app for you.
I'd suggest learning more about cmake and snapcraft. Some of the other cpp examples have more complex cmake and snapcraft files. For instance, the simple datalayer client example. Also, when building for arm64 architecture on an amd system, it is important to understand cross compiling and snapcraft package staging.
Here are a couple code snippets that might help in building your app. I just integrated libcurl into a c++ application and built on amd for arm.
In CMakeLists.txt, it is necessary to locate and link your additional libraries. You can install libraries on Ubuntu amd for arm, but it is a bit complicated and will likely require some troubleshooting.
# Locate libcurl based on architecture
IF( ${CMAKE_BUILD_KIT} MATCHES "aarch64")
find_library(CURL NAMES curl PATHS /usr/lib/aarch64-linux-gnu NO_DEFAULT_PATH)
ELSE()
find_library(CURL NAMES curl)
ENDIF()
#
# Set target link libraries
#
target_link_libraries(${TARGET_PROJECT_NAME} -Wl,--no-undefined)
target_link_libraries(${TARGET_PROJECT_NAME}
libcomm_datalayer.so
pthread
systemd
zmq
ssl
crypto
${CURL}
)
In your snapcraft.yaml, it is necessary to stage the additional packages so they can be utilized by the snap at runtime.
parts:
datalayerclient:
plugin: dump
source: ./generated/build
stage-packages:
- libzmq5
- ctrlx-datalayer
- libcurl4
If you can provide some more specific questions, I can give you some better answers.
04-04-2024 06:35 PM
@Sgilk,
Thank you for your reply,
I will try with this information.
Another question that came to my mind with your comment is...
How do you do when you program for a Ctrlx3(arm) and a Ctrlx7(amd)?
You avoid the use of Ctrlx works to generate the SSH and use virtual box, you have two virtual machines, one for arm and one for amd?
04-04-2024 06:49 PM
You can do this however you prefer. Ideally you have a hardware device for each architecture you intend to develop on. That just makes things easier.
In my case, I only use an amd machine and I'm using the app build environment generated from ctrlX Works. I try my best to use cross architecture building techniques to build for arm (ie. snapcraft remote build), but it is definitely more complicated.
If you look at the samples I provided, there is configuration and scripts that are architecture specific. For example, build_snap_amd64.sh vs build_snap_arm64.sh