Creating a simple WEB App - Beginners Troubles

Applications, development tools, FPGA, C, WEB
Post Reply
lhochstetter
Posts: 55
Joined: Tue Mar 01, 2016 1:43 pm

Creating a simple WEB App - Beginners Troubles

Post by lhochstetter » Mon Jun 13, 2016 7:06 pm

Hello everyone,

I'm trying to create a simple as can be WEB App. It should only return a fixed set of values which then should be displayed by my browser in JSON. No FPGA, no html+css+js to display, just a plain print of the data.

From what I understood from other app's source code is that

Code: Select all

int rp_app_init(void);
int rp_app_exit(void);
int rp_set_params(rp_app_params_t *p, int len);
int rp_get_params(rp_app_params_t **p);
int rp_get_signals(float ***s, int *sig_num, int *sig_len);
are the functions which need to be implemented, so the NGINX RP modul can talk to my app.

The first four functions are only

Code: Select all

return 0;
at the moment, as I am only interessted in getting the predefined data using

Code: Select all

int rp_get_signals(float ***s, int *sig_num, int *sig_len);
From what I have read from other threads the app needs to be build as .so (shared object).

Assuming I managed to build a .so I would have to copy it to the RP at

Code: Select all

/opt/red_pitaya/www/apps/APP_NAME
, wouldn't I?

Do I need to do anything else to have my app
* appear as a clickable link in the main view when you connect to your RP using your browser?
* return my predefined data for my browser to display as a plain JSON object?

Any ideas / pointers are appreciated!

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Creating a simple WEB App - Beginners Troubles

Post by Nils Roos » Mon Jun 13, 2016 9:01 pm

If your Red Pitaya runs ecosystem 0.94 or newer, you also need to provide the function "const char *rp_app_desc(void)" and compile a controllerhf.so, using the arm-linux-gnueabihf- toolchain.

You must have the files
  • controllerhf.so
  • fpga.conf (may be empty)
  • info/icon.png
  • info/info.json
in the APPNAME directory, the info/info.json must have valid content, and the controllerhf.so must export the functions
  • const char *rp_app_desc(void)
  • int rp_app_init(void)
  • int rp_app_exit(void)
  • int rp_set_params(rp_app_params_t *p, int len)
  • int rp_get_params(rp_app_params_t **p)
  • int rp_get_signals(float ***s, int *sig_num, int *sig_len)
If any of these conditions is not met, the bazaar framework will not list your app on the apps page (or at least you won't be able to run it, not sure which).

To make the app return the data from rp_get_signals when you select it, you must provide an index.html in APPNAME that redirects to /data . Http GET requests to /data trigger the call to rp_get_signals() of the loaded app in nginx and return the json output.

lhochstetter
Posts: 55
Joined: Tue Mar 01, 2016 1:43 pm

Re: Creating a simple WEB App - Beginners Troubles

Post by lhochstetter » Mon Jun 13, 2016 9:22 pm

A friend helped me and we managed to get to a point which closely resembles my original intentions just before you posted your answer ...

Thanks again, Nils!

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Creating a simple WEB App - Beginners Troubles

Post by Nils Roos » Mon Jun 13, 2016 9:55 pm

Glad I could almost help you :mrgreen:

wilodiaz
Posts: 2
Joined: Tue Feb 16, 2016 5:39 pm

Re: Creating a simple WEB App - Beginners Troubles

Post by wilodiaz » Wed Jun 29, 2016 7:26 pm

Hello !
I'm new in the red piyata world. (excuse me if I'm asking crap)
I'm trying to use an application than can show the generator and give more information as peaks, max gain and others. I builded the index and is perfect but, not works as i wanna, and i can see that the problem is on the file "controllerhf.so" , because i change it with other and some functions are activated.
Can I modify it file? and how can i do it?

Thanks!

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Creating a simple WEB App - Beginners Troubles

Post by Nils Roos » Fri Jul 01, 2016 10:08 am

Hi,

the controllerhf.so is compiled from a bunch of C source files. You can modify the code and compile a new controllerhf.so .

For all web-apps that use the oscilloscope functions, the sources are in apps-free/scope/src. Follow the guidelines for setting up a build environment (here and here, with some additional hints here) for Red Pitaya binaries, then you can change the code and create a new controllerhf.so for your app.

irain04
Posts: 12
Joined: Wed Jul 22, 2015 1:33 pm

Re: Creating a simple WEB App - Beginners Troubles

Post by irain04 » Sat Aug 19, 2017 11:34 am

Dear Nils Roos,

I found this topic related to the issue that I'm facing so I would like to post my question here.

I downloaded the scope+pid application from http://bazaar.redpitaya.com/archives/ap ... -13014.zip
I tried to rebuild controller.so by using the Makefile in that zip file.
I think I built the controller.so successfully. Here is the log file.

Code: Select all

trungnguyen@trungnguyen:~/RedPitaya/build/www/apps/scope+pid$ make CROSS_COMPILE=arm-linux-gnueabi- clean all
make -C src clean
make[1]: Entering directory '/home/trungnguyen/RedPitaya/build/www/apps/scope+pid/src'
rm -f ../controller.so main.o fpga.o worker.o calib.o fpga_awg.o generate.o fpga_pid.o pid.o
make[1]: Leaving directory '/home/trungnguyen/RedPitaya/build/www/apps/scope+pid/src'
rm -f target -rf
rm -f *.zip
make -C src
make[1]: Entering directory '/home/trungnguyen/RedPitaya/build/www/apps/scope+pid/src'
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o main.o main.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o fpga.o fpga.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o worker.o worker.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o calib.o calib.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o fpga_awg.o fpga_awg.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o generate.o generate.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o fpga_pid.o fpga_pid.c
arm-linux-gnueabi-gcc -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC    -c -o pid.o pid.c
arm-linux-gnueabi-gcc -o ../controller.so main.o fpga.o worker.o calib.o fpga_awg.o generate.o fpga_pid.o pid.o -DVERSION=0.91-0 -DREVISION=devbuild -Wall -Werror -g -fPIC  -shared
make[1]: Leaving directory '/home/trungnguyen/RedPitaya/build/www/apps/scope+pid/src'
However, the controller.so file doesn't work. I got the following message when I clicked on the application.
Image
The original controller file works well. I don't know what I have done wrong. Do you have any ideas?

With the latest OS, I also tried to build controllerhf.so as your instruction but it has the same problem with this.
I attached here the controller_failed.so which doesn't work. Thank you for your help.
https://drive.google.com/open?id=0ByMfU ... VZGdFU5bDA

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 63 guests