Commit e65f13e1 authored by frtabu's avatar frtabu

review fixes

parent 93a6d408
......@@ -523,7 +523,7 @@ int process_command(char *buf, int iteration)
int rt;
memset(modulename,0,sizeof(modulename));
memset(cmd,0,sizeof(cmd));
extern char **environ;
if (strncasecmp(buf,"ex",2) == 0)
return CMDSTATUS_EXIT;
......@@ -953,7 +953,8 @@ int telnetsrv_checkbuildver(char *mainexec_buildversion, char **shlib_buildvers
}
int telnetsrv_getfarray(loader_shlibfunc_t **farray) {
*farray = malloc(sizeof(loader_shlibfunc_t) * 3);
int const num_func_tln_srv = 3;
*farray = malloc(sizeof(loader_shlibfunc_t) * num_func_tln_srv);
(*farray)[0].fname=TELNET_ADDCMD_FNAME;
(*farray)[0].fptr=(int (*)(void) )add_telnetcmd;
(*farray)[1].fname=TELNET_POLLCMDQ_FNAME;
......
......@@ -194,58 +194,60 @@ int nullprnt(char *fmt, ...)
{
return 0;
}
void proccmd_get_threaddata(char *buf, int debug, telnet_printfunc_t fprnt, webdatadef_t *tdata)
{
char aname[256];
DIR *proc_dir;
struct dirent *entry;
telnet_printfunc_t prnt = (fprnt != NULL) ? fprnt : (telnet_printfunc_t)nullprnt;
if (tdata != NULL) {
tdata->numcols = 7;
snprintf(tdata->columns[0].coltitle, sizeof(tdata->columns[0].coltitle), "thread id");
tdata->columns[0].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[1].coltitle, sizeof(tdata->columns[1].coltitle), "thread name");
tdata->columns[1].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[2].coltitle, sizeof(tdata->columns[2].coltitle), "priority");
tdata->columns[2].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[3].coltitle, sizeof(tdata->columns[3].coltitle), "nice");
tdata->columns[3].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[4].coltitle, sizeof(tdata->columns[4].coltitle), "core");
tdata->columns[4].coltype = TELNET_VARTYPE_STRING | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[5].coltitle, sizeof(tdata->columns[5].coltitle), "sched policy");
tdata->columns[5].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[5].coltitle, sizeof(tdata->columns[5].coltitle), "sched policy");
tdata->columns[6].coltype = TELNET_VARTYPE_STRING | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[6].coltitle, sizeof(tdata->columns[6].coltitle), "oai priority");
tdata->numlines = 0;
}
DIR *proc_dir;
struct dirent *entry;
telnet_printfunc_t prnt = (fprnt != NULL) ? fprnt : (telnet_printfunc_t)nullprnt;
if (tdata != NULL) {
tdata->numcols = 7;
snprintf(tdata->columns[0].coltitle, sizeof(tdata->columns[0].coltitle), "thread id");
tdata->columns[0].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[1].coltitle, sizeof(tdata->columns[1].coltitle), "thread name");
tdata->columns[1].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[2].coltitle, sizeof(tdata->columns[2].coltitle), "priority");
tdata->columns[2].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[3].coltitle, sizeof(tdata->columns[3].coltitle), "nice");
tdata->columns[3].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[4].coltitle, sizeof(tdata->columns[4].coltitle), "core");
tdata->columns[4].coltype = TELNET_VARTYPE_STRING | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[5].coltitle, sizeof(tdata->columns[5].coltitle), "sched policy");
tdata->columns[5].coltype = TELNET_VARTYPE_STRING | TELNET_CHECKVAL_RDONLY | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[5].coltitle, sizeof(tdata->columns[5].coltitle), "sched policy");
tdata->columns[6].coltype = TELNET_VARTYPE_STRING | TELNET_VAR_NEEDFREE;
snprintf(tdata->columns[6].coltitle, sizeof(tdata->columns[6].coltitle), "oai priority");
tdata->numlines = 0;
}
unsigned int eax = 11, ebx = 0, ecx = 1, edx = 0;
unsigned int eax = 11, ebx = 0, ecx = 1, edx = 0;
asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(eax), "2"(ecx) :);
asm volatile("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(eax), "2"(ecx) :);
prnt("System has %d cores %d threads %d Actual threads", eax, ebx, edx);
prnt("System has %d cores %d threads %d Actual threads", eax, ebx, edx);
prnt("\n id name state USRmod KRNmod prio nice vsize proc pol \n\n");
snprintf(aname, sizeof(aname), "/proc/%d/stat", getpid());
read_statfile(aname, debug, prnt, NULL);
prnt("\n");
snprintf(aname, sizeof(aname), "/proc/%d/task", getpid());
proc_dir = opendir(aname);
if (proc_dir == NULL) {
prnt("Error: Couldn't open %s %i %s\n", aname, errno, strerror(errno));
return;
}
while ((entry = readdir(proc_dir)) != NULL) {
if (entry->d_name[0] != '.') {
snprintf(aname, sizeof(aname), "/proc/%d/task/%.*s/stat", getpid(), (int)(sizeof(aname) - 24), entry->d_name);
read_statfile(aname, debug, prnt, tdata);
prnt("\n id name state USRmod KRNmod prio nice vsize proc pol \n\n");
snprintf(aname, sizeof(aname), "/proc/%d/stat", getpid());
read_statfile(aname, debug, prnt, NULL);
prnt("\n");
snprintf(aname, sizeof(aname), "/proc/%d/task", getpid());
proc_dir = opendir(aname);
if (proc_dir == NULL) {
prnt("Error: Couldn't open %s %i %s\n", aname, errno, strerror(errno));
return;
}
} /* while entry != NULL */
closedir(proc_dir);
} /* print_threads */
while ((entry = readdir(proc_dir)) != NULL) {
if (entry->d_name[0] != '.') {
snprintf(aname, sizeof(aname), "/proc/%d/task/%.*s/stat", getpid(), (int)(sizeof(aname) - 24), entry->d_name);
read_statfile(aname, debug, prnt, tdata);
}
} /* while entry != NULL */
closedir(proc_dir);
} /* proccmd_get_threaddata */
void print_threads(char *buf, int debug, telnet_printfunc_t prnt)
{
proccmd_get_threaddata(buf, debug, prnt, NULL);
......
......@@ -26,18 +26,21 @@
#include <stdlib.h>
#include "executables/softmodem-common.h"
#include "executables/nr-softmodem-common.h"
#ifndef WEBSRVSCOPE
#include <forms.h>
#define STATICFORXSCOPE static
static const int scope_enb_num_ue = 1;
#else
#ifdef WEBSRVSCOPE
#include <ulfius.h>
#include "common/utils/websrv/websrv.h"
#include "common/utils/websrv/websrv_noforms.h"
/* STATICFORXSCOPE will be used to make function being called from websrv code non static when we compile
* with WEBSRVSCOPE mocro defined, but static when we compile for Xforms scope
*/
#define STATICFORXSCOPE
#define fl_add_canvas websrv_fl_add_canvas
#define fl_add_xyplot websrv_fl_add_xyplot
#define fl_get_xyplot_data_pointer websrv_fl_get_xyplot_data_pointer
#else
#include <forms.h>
#define STATICFORXSCOPE static
static const int scope_enb_num_ue = 1;
#endif
#include "nr_phy_scope.h"
#include "phy_scope.h"
......@@ -379,7 +382,12 @@ static void genericWaterFall (OAIgraph_t *graph, scopeSample_t *values, const in
#endif
}
#ifndef WEBSRVSCOPE
#ifdef WEBSRVSCOPE
for (int i = 0; i < sizeof(water_colors) / sizeof(FL_COLOR); i++) {
msgp[i]->header.msgseg = graph->iteration % displayPart;
websrv_scope_senddata(msgp[i]->data_xy[0], 2, msgp[i]);
}
#else
if (graph->initDone==false) {
for ( int i=0; i < graph->waterFallh; i++ )
for ( int j = 0 ; j < graph->w ; j++ )
......@@ -393,23 +401,18 @@ static void genericWaterFall (OAIgraph_t *graph, scopeSample_t *values, const in
}
fl_set_object_label_f(graph->text, "%s, avg I/Q pow: %4.1f", label, 0/*sqrt(avg)*/);
#else
for (int i = 0; i < sizeof(water_colors) / sizeof(FL_COLOR); i++) {
msgp[i]->header.msgseg = graph->iteration % displayPart;
websrv_scope_senddata(msgp[i]->data_xy[0], 2, msgp[i]);
}
#endif
graph->iteration++;
}
static void genericPowerPerAntena(OAIgraph_t *graph, const int nb_ant, const scopeSample_t **data, const int len) {
#ifndef WEBSRVSCOPE
float *values, *time;
oai_xygraph_getbuff(graph, &time, &values, len, 0);
#else
#ifdef WEBSRVSCOPE
websrv_scopedata_msg_t *msg = NULL;
websrv_nf_getdata(graph->graph, 0, &msg);
float *values = (float *)msg->data_xy;
#else
float *values, *time;
oai_xygraph_getbuff(graph, &time, &values, len, 0);
#endif
for (int ant=0; ant<nb_ant; ant++) {
......@@ -417,15 +420,15 @@ static void genericPowerPerAntena(OAIgraph_t *graph, const int nb_ant, const sc
for (int i=0; i<len; i++) {
values[i] = SquaredNorm(data[ant][i]);
}
#ifndef WEBSRVSCOPE
oai_xygraph(graph,time,values, len, ant, 10);
#else
#ifdef WEBSRVSCOPE
msg->header.msgtype = SCOPEMSG_TYPE_DATA;
msg->header.chartid = graph->chartid;
msg->header.datasetid = graph->datasetid;
msg->header.msgseg = 0;
msg->header.update = (ant == (nb_ant - 1)) ? 1 : 0;
websrv_scope_senddata(len, 4, msg);
#else
oai_xygraph(graph,time,values, len, ant, 10);
#endif
}
}
......@@ -454,13 +457,13 @@ static void timeSignal (OAIgraph_t *graph, PHY_VARS_gNB *phy_vars_gnb, RU_t *phy
static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
const int len = p->gNB->frame_parms.ofdm_symbol_size;
#ifndef WEBSRVSCOPE
float *values, *time;
oai_xygraph_getbuff(graph, &time, &values, len, 0);
#else
#ifdef WEBSRVSCOPE
websrv_scopedata_msg_t *msg = NULL;
websrv_nf_getdata(graph->graph, 0, &msg);
float *values = (float *)msg->data_xy;
#else
float *values, *time;
oai_xygraph_getbuff(graph, &time, &values, len, 0);
#endif
const int ant = 0; // display antenna 0 for each UE
......@@ -479,15 +482,15 @@ static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
for (int i=0; i<len; i++) {
values[i] = SquaredNorm(data[i]);
}
#ifndef WEBSRVSCOPE
oai_xygraph(graph,time,values, len, ue, 10);
#else
#ifdef WEBSRVSCOPE
msg->header.msgtype = SCOPEMSG_TYPE_DATA;
msg->header.chartid = graph->chartid;
msg->header.datasetid = graph->datasetid;
msg->header.msgseg = 0;
msg->header.update = 1;
websrv_scope_senddata(len, 4, msg);
#else
oai_xygraph(graph,time,values, len, ue, 10);
#endif
}
}
......
......@@ -1999,7 +1999,7 @@ int get_channel_params(char *buf, int debug, void *vdata, telnet_printfunc_t prn
sprintf(cmdbuf, "channelmod modify %i %s %s", chanidx, pnames[pidx], tdata->lines[0].val[1]);
}
channelmod_modify_cmd(cmdbuf, debug, prnt);
return 200;
return CMDSTATUS_FOUND;
} else {
prnt(" channel index not found in cannelmod command\n");
}
......@@ -2007,7 +2007,7 @@ int get_channel_params(char *buf, int debug, void *vdata, telnet_printfunc_t prn
prnt("%s not implemented\n", buf);
}
return 500;
return CMDSTATUS_NOTFOUND;
} /* get_currentchannel_type */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment