Loading parameters with WEB applications

Applications, development tools, FPGA, C, WEB
Post Reply
PA7T_Clemens
Posts: 1
Joined: Fri Mar 10, 2017 7:49 pm

Loading parameters with WEB applications

Post by PA7T_Clemens » Fri Mar 10, 2017 8:07 pm

Dear all,

I followed the tutorial:

http://redpitaya.readthedocs.io/en/late ... bApps.html

and made an application that stores parameters in a file via js/app.js:

Code: Select all

// sends configuration to backend
var local = {};
local['CALL'] = { value: $('#call').val() };
APP.ws.send(JSON.stringify({ parameters: local }));
This works great and now I would like to read the parameter back to the web app on application load.

To that end I call the method APP.processParamters(receive.parameters) every time a message is received.

Code: Select all

if (receive.parameters) {
    //console.log('received params')
    APP.processParameters(receive.parameters);
}
Interestingly, there are permanently parameters send by the cpp controller, which I did not configure.

The main.cpp looks like that:

Code: Select all

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysinfo.h>

#include <sstream>

#include "main.h"

/* --------------------------------  OUT PARAMETERS  ------------------------------ */

CStringParameter call("CALL", CBaseParameter::RWSA, "", 10000);
CStringParameter grid("GRID", CBaseParameter::RWSA, "", 10000);
CStringParameter comment("COMMENT", CBaseParameter::RWSA, "", 10000);
CStringParameter wlid("WLID", CBaseParameter::RWSA, "", 10000);
CStringParameter wlpw("WLPW", CBaseParameter::RWSA, "", 10000);
/*
CFloatParameter ppm("PPM", CBaseParameter::RW, 0.0, 0, -100.0, 100.0);
CStringParameter wlid("WSPRLIVE-ID", CBaseParameter::RWSA, "", 10000);
CStringParameter wlpw("WSPRLIVE-PW", CBaseParameter::RWSA, "", 10000);
CStringParameter bands("BANDS", CBaseParameter::RWSA, "", 10000);
*/
const char *rp_app_desc(void)
{
    return (const char *)"Red Pitaya SDR WSPR 8-channel receiver.\n";
}


int rp_app_init(void)
{
    fprintf(stderr, "Loading sdr_wspr application\n");
//    CDataManager::GetInstance()->SetParamInterval(1000);
    system("/opt/redpitaya/www/apps/sdr_wspr/start.sh");
    return 0;
}


int rp_app_exit(void)
{
    fprintf(stderr, "Unloading sdr_wspr application\n");
    system("/opt/redpitaya/www/apps/sdr_wspr/stop.sh");
    return 0;
}

int rp_set_params(rp_app_params_t *p, int len)
{
    return 0;
}


int rp_get_params(rp_app_params_t **p)
{
    return 0;
}

int rp_get_signals(float ***s, int *sig_num, int *sig_len)
{
    return 0;
}

void UpdateSignals(void){}


void UpdateParams(void){
}


void OnNewParams(void) {
    call.Update();
    grid.Update();
    comment.Update();
    wlid.Update();
    wlpw.Update();

    std::stringstream wsprvars;
    wsprvars << "CALL=\"" << call.Value() << "\"" << '\n';
    wsprvars << "GRID=\"" << grid.Value() << "\"" << '\n';
    wsprvars << "COMMENT=\"" << comment.Value() << "\"" << '\n';
    wsprvars << "WLID=\"" << wlid.Value() << "\"" << '\n';
    wsprvars << "WLPW=\"" << wlpw.Value() << "\"" << '\n';

    system("mount -o rw,remount /opt/redpitaya");
    std::string command1 = "echo '" + wsprvars.str() + "' > /opt/redpitaya/www/apps/sdr_wspr/wspr-vars.sh";
    system(command1.c_str());
}
To my understanding there should only be a message with a parameter send, in case I call something like

Code: Select all

call.Value() = 'PA7T';
Do I misunderstand the concept of transferring parameters from the c++ controller for the js web app?

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 34 guests