satip-axe/patches/minisatip7-axe.patch

2128 lines
74 KiB
Diff
Raw Permalink Normal View History

2017-05-07 09:05:04 +02:00
diff --git a/.gitignore b/.gitignore
index 8e8a5b9..ad34b81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
/minisatip
*.o
+*.d
config.log
config.status
Makefile
diff --git a/Makefile.in b/Makefile.in
index ed8b1e5..f41b772 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -14,7 +14,7 @@ LINUXDVB=@LINUXDVB@
AXE=@AXE@
-CFLAGS?=-ggdb -fPIC $(EXTRA_CFLAGS) @CFLAGS@
+CFLAGS?=-Wall -Wno-switch -ggdb -fPIC $(EXTRA_CFLAGS) @CFLAGS@
LDFLAGS?=-lpthread -lrt @LDFLAGS@
OBJS=minisatip.o socketworks.o stream.o adapter.o utils.o
@@ -78,7 +78,7 @@ CFLAGS+=-DDISABLE_LINUXDVB
OBJS+=dvb.o
endif
-OBJS-$(AXE) += axe.c
+OBJS-$(AXE) += axe.o
CFLAGS-$(AXE) += -DAXE
@@ -96,14 +96,23 @@ OBJS+=$(OBJS-1)
CFLAGS+=$(CFLAGS-1)
LDFLAGS+=$(LDFLAGS-1)
+DEPS=$(OBJS:.o=.d)
-minisatip: $(OBJS)
+minisatip: $(DEPS) $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
+%.d : %.c
+ @$(CC) $(CFLAGS) -MM $(basename $*).c | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
+
%.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
+ $(CC) $(CFLAGS) -c $*.c -o $@
all: minisatip
clean:
- rm *.o minisatip >> /dev/null
+ rm *.o *.d minisatip >> /dev/null
+
+# pull in dependency info for *existing* .o files
+ifneq "$(MAKECMDGOALS)" "clean"
+-include $(DEPS)
+endif
diff --git a/adapter.c b/adapter.c
index cfb742d..7b8814a 100644
--- a/adapter.c
+++ b/adapter.c
2017-05-12 09:56:52 +02:00
@@ -65,6 +65,7 @@ adapter *adapter_alloc()
{
adapter *ad = malloc1(sizeof(adapter));
memset(ad, 0, sizeof(adapter));
+
/* diseqc setup */
ad->diseqc_param.fast = opts.diseqc_fast;
ad->diseqc_param.committed_no = opts.diseqc_committed_no;
@@ -84,14 +85,14 @@ adapter *adapter_alloc()
ad->old_pol = -1;
ad->dmx_source = -1;
ad->slow_dev = opts.nopm;
- /* LOF setup */
+ ad->diseqc_multi = opts.diseqc_multi;
+ /* LOF setup */
ad->diseqc_param.lnb_low = opts.lnb_low;
ad->diseqc_param.lnb_high = opts.lnb_high;
ad->diseqc_param.lnb_circular = opts.lnb_circular;
ad->diseqc_param.lnb_switch = opts.lnb_switch;
-
return ad;
}
@@ -119,8 +120,7 @@ void find_adapters()
2017-05-07 09:05:04 +02:00
// avoid adapter close unless all the adapters can be closed
int adapter_timeout(sockets *s)
{
- int do_close = 1, i;
- int64_t rtime = getTick(), max_close = 0;
+ int do_close = 1;
adapter *ad = get_adapter(s->sid);
if (!ad)
return 1;
2017-05-12 09:56:52 +02:00
@@ -187,7 +187,6 @@ int num_adapters = 0;
2017-05-07 09:05:04 +02:00
int init_hw(int i)
{
- char name[100];
int64_t st, et;
adapter *ad;
if (i < 0 || i >= MAX_ADAPTERS)
2017-05-12 09:56:52 +02:00
@@ -291,7 +290,6 @@ int init_hw(int i)
2017-05-07 09:05:04 +02:00
get_delsys(ad->sys[0]), get_delsys(ad->sys[1]),
get_delsys(ad->sys[2]), get_delsys(ad->sys[3]));
-OK:
mutex_unlock(&ad->mutex);
return 0;
2017-05-12 09:56:52 +02:00
@@ -303,7 +301,6 @@ NOK:
2017-05-07 09:05:04 +02:00
int init_all_hw()
{
int i, rv;
- char name[50];
LOG("starting init_all_hw %d", init_complete);
if (init_complete)
2017-05-12 09:56:52 +02:00
@@ -385,11 +382,10 @@ int close_adapter(int na)
2017-05-07 09:05:04 +02:00
int getAdaptersCount()
{
- int i, j, k;
- char sys;
+ int i, j, k, sys;
adapter *ad;
- char fes[20][MAX_ADAPTERS];
- char ifes[20];
+ int fes[20][MAX_ADAPTERS];
+ int ifes[20];
char order[] =
{ SYS_DVBS2, SYS_DVBT, SYS_DVBC_ANNEX_A, SYS_DVBT2, SYS_DVBC2 };
2017-05-12 09:56:52 +02:00
@@ -701,7 +697,6 @@ int tune(int aid, int sid)
2017-05-07 09:05:04 +02:00
{
adapter *ad = get_adapter(aid);
int rv = 0, flush_data = 0;
- SPid *p;
if (!ad)
return -400;
@@ -939,7 +934,6 @@ int mark_pids_add(int sid, int aid, char *pids)
2017-05-07 09:05:04 +02:00
int compare_tunning_parameters(int aid, transponder * tp)
{
- int same = 0;
adapter *ad = get_adapter(aid);
if (!ad)
return -1;
@@ -1075,7 +1069,7 @@ char* get_stream_pids(int s_id, char *dest, int max_size);
2017-05-07 09:05:04 +02:00
char *
describe_adapter(int sid, int aid, char *dad, int ld)
{
- int i = 0, ts, j, use_ad, len;
+ int use_ad, len;
transponder *t;
adapter *ad;
streams *ss;
@@ -1095,7 +1089,7 @@ describe_adapter(int sid, int aid, char *dad, int ld)
2017-05-07 09:05:04 +02:00
}
else
t = &ad->tp;
- memset(dad, 0, sizeof(dad));
+ memset(dad, 0, ld);
if (use_ad)
{
@@ -1336,6 +1330,51 @@ void set_diseqc_adapters(char *o)
2017-05-12 09:56:52 +02:00
}
}
+void set_diseqc_multi(char *o)
+{
+ int i, la, a_id, position;
+ char buf[100], *arg[20], *sep1;
+ adapter *ad;
+ strncpy(buf, o, sizeof(buf));
+ la = split(arg, buf, sizeof(arg), ',');
+ for (i = 0; i < la; i++)
+ {
+ if (arg[i] && arg[i][0] == '*')
+ {
+ ad = NULL;
+ a_id = -1;
+ }
+ else
+ {
+ a_id = map_intd(arg[i], NULL, -1);
+ if (a_id < 0 || a_id >= MAX_ADAPTERS)
+ continue;
+
+ if (!a[a_id])
+ a[a_id] = adapter_alloc();
+ ad = a[a_id];
+ }
+
+ sep1 = strchr(arg[i], ':');
+
+ if (!sep1)
+ continue;
+ position = map_intd(sep1 + 1, NULL, -1);
+ if (position < 0)
+ continue;
+ if (ad)
+ {
+ ad->diseqc_multi = position;
+ }
+ else
+ {
+ opts.diseqc_multi = position;
+ }
+ LOGL(0,
+ "Setting diseqc multi adapter %d position %d",
+ a_id, position);
+ }
+}
void set_lnb_adapters(char *o)
{
@@ -1407,7 +1446,7 @@ void set_diseqc_timing(char *o)
2017-05-07 09:05:04 +02:00
int before_cmd, after_cmd, after_repeated_cmd;
int after_switch, after_burst, after_tone;
char buf[2000], *arg[20];
- char *sep1, *sep2, *sep3, *sep4, *sep5, *sep6, *sep7;
+ char *sep1, *sep2, *sep3, *sep4, *sep5, *sep6;
adapter *ad;
strncpy(buf, o, sizeof(buf));
la = split(arg, buf, sizeof(arg), ',');
@@ -1553,7 +1592,7 @@ void set_nopm_adapters(char *o)
2017-05-07 09:05:04 +02:00
extern char *fe_delsys[];
void set_adapters_delsys(char *o)
{
- int i, j, la, a_id, ds;
+ int i, la, a_id, ds;
char buf[100], *arg[20], *sep;
adapter *ad;
strncpy(buf, o, sizeof(buf));
@@ -1655,7 +1694,6 @@ int signal_thread(sockets *s)
2017-05-07 09:05:04 +02:00
int i;
int64_t ts, ctime;
adapter *ad;
- int status;
for (i = 0; i < MAX_ADAPTERS; i++)
if ((ad = get_adapter_nw(i)) && ad->get_signal && ad->tp.freq
&& (ad->status_cnt++ > 2) // make sure the kernel has updated the status
@@ -1876,9 +1914,9 @@ _symbols adapters_sym[] =
2017-05-03 17:04:12 +02:00
{ "ad_sys", VAR_AARRAY_INT, a, 1, MAX_ADAPTERS, offsetof(
adapter, tp.sys) },
{ "ad_allsys", VAR_FUNCTION_STRING, (void *) &get_all_delsys, 0,
- 0, 0 },
+ MAX_ADAPTERS, 0 },
{ "ad_pids", VAR_FUNCTION_STRING, (void *) &get_adapter_pids, 0,
- 0, 0 },
+ MAX_ADAPTERS, 0 },
{ "tuner_s2", VAR_INT, &tuner_s2, 1, 0, 0 },
{ "tuner_t2", VAR_INT, &tuner_t2, 1, 0, 0 },
{ "tuner_c2", VAR_INT, &tuner_c2, 1, 0, 0 },
2017-05-07 09:05:04 +02:00
diff --git a/adapter.h b/adapter.h
index 375a820..0445820 100755
2017-05-07 09:05:04 +02:00
--- a/adapter.h
+++ b/adapter.h
@@ -53,6 +53,7 @@ typedef int (*Del_filters)(int fd, int pid);
typedef int (*Adapter_commit)(void *ad);
typedef int (*Open_device)(void *ad);
typedef int (*Device_signal)(void *ad);
+typedef int (*Device_wakeup)(void *ad, int fd, int voltage);
typedef int (*Tune)(int aid, transponder * tp);
typedef fe_delivery_system_t (*Dvb_delsys)(int aid, int fd,
fe_delivery_system_t *sys);
2017-05-12 09:56:52 +02:00
@@ -99,6 +100,7 @@ typedef struct struct_adapter
uint16_t strength, snr, max_strength, max_snr;
uint32_t pid_err, dec_err; // detect pids received but not part of any stream, decrypt errors
diseqc diseqc_param;
+ int diseqc_multi;
int old_diseqc;
int old_hiband;
int old_pol;
@@ -115,6 +117,7 @@ typedef struct struct_adapter
2017-05-07 09:05:04 +02:00
Tune tune;
Dvb_delsys delsys;
Device_signal get_signal;
+ Device_wakeup wakeup;
Adapter_commit post_init, close;
} adapter;
2017-05-12 09:56:52 +02:00
@@ -147,6 +150,7 @@ void enable_adapters(char *o);
void set_unicable_adapters(char *o, int type);
void set_diseqc_adapters(char *o);
void set_diseqc_timing(char *o);
+void set_diseqc_multi(char *o);
void set_slave_adapters(char *o);
void set_nopm_adapters(char *o);
void set_adapter_dmxsource(char *o);
diff --git a/axe.c b/axe.c
2018-03-05 21:37:06 +01:00
index 486b2f8..b77b62d 100755
--- a/axe.c
+++ b/axe.c
2017-05-07 09:05:04 +02:00
@@ -47,10 +47,7 @@
#ifndef DISABLE_LINUXDVB
extern struct struct_opts opts;
-int dvb_tune(int aid, transponder * tp);
-int setup_switch(adapter *ad);
-void get_signal(int fd, int * status, uint32_t * ber, uint16_t * strength,
- uint16_t * snr);
+void get_signal(int fd, uint32_t * status, uint32_t * ber, uint16_t * strength, uint16_t * snr);
int send_jess(adapter *ad, int fd, int freq, int pos, int pol, int hiband, diseqc *d);
int send_unicable(adapter *ad, int fd, int freq, int pos, int pol, int hiband, diseqc *d);
int send_diseqc(adapter *ad, int fd, int pos, int pos_change, int pol, int hiband, diseqc *d);
@@ -107,6 +104,8 @@ void axe_set_network_led(int on)
int axe_read(int socket, void *buf, int len, sockets *ss, int *rv)
{
*rv = read(socket, buf, len);
+ if (len == *rv)
+ LOGL(3, "AXE: MAX READ %d", len);
// if(*rv < 0 || *rv == 0 || errno == -EAGAIN)
if(*rv < 0 || *rv == 0 || errno == -EAGAIN)
{
2017-05-07 09:05:04 +02:00
@@ -155,7 +154,7 @@ void axe_post_init(adapter *ad)
}
-void axe_wakeup(int fe_fd, int voltage)
+void axe_wakeup(void *_ad, int fe_fd, int voltage)
{
int i, mask;
adapter *a;
@@ -270,7 +269,7 @@ int axe_setup_switch(adapter *ad)
}
adapter *ad2, *adm;
- int input = 0, src, aid, pos = 0, equattro = 0, master = -1;
+ int input = 0, aid, pos = 0, equattro = 0, master = -1;
if (tp->diseqc_param.switch_type != SWITCH_UNICABLE &&
tp->diseqc_param.switch_type != SWITCH_JESS) {
2017-05-12 09:56:52 +02:00
@@ -341,7 +340,7 @@ int axe_setup_switch(adapter *ad)
input = master;
if (!tune_check(adm, pol, hiband, diseqc)) {
send_diseqc(adm, adm->fe2, diseqc, adm->old_diseqc != diseqc,
- pol, hiband, &tp->diseqc_param);
+ pol, hiband, &tp->diseqc_param);
adm->old_pol = pol;
adm->old_hiband = hiband;
adm->old_diseqc = diseqc;
2017-05-07 09:05:04 +02:00
@@ -385,18 +384,35 @@ int axe_setup_switch(adapter *ad)
}else
ad->axe_used |= (1 << aid);
- LOG("adapter %d: using source %d, fe %d fe2 %d", ad->id, input, ad->fe, ad->fe2);
+ LOG("adapter %d: using source %d, fe %d fe2 %d",
+ ad->id, input, ad->fe, ad->fe2);
}
if (tp->diseqc_param.switch_type == SWITCH_UNICABLE)
{
freq = send_unicable(ad, ad->fe2, freq / 1000, diseqc,
- pol, hiband, &tp->diseqc_param);
+ pol, hiband, &tp->diseqc_param);
}
else if (tp->diseqc_param.switch_type == SWITCH_JESS)
{
freq = send_jess(ad, ad->fe2, freq / 1000, diseqc,
- pol, hiband, &tp->diseqc_param);
+ pol, hiband, &tp->diseqc_param);
+ }
+ else if (tp->diseqc_param.switch_type == SWITCH_SLAVE)
+ {
+ LOGL(2, "FD %d (%d) is a slave adapter", frontend_fd);
+ }
+ else
+ {
+ if (ad->old_pol != pol || ad->old_hiband != hiband
+ || ad->old_diseqc != diseqc)
+ send_diseqc(ad, frontend_fd, diseqc, ad->old_diseqc != diseqc, pol,
+ hiband, &tp->diseqc_param);
+ else
+ LOGL(3, "Skip sending diseqc commands since "
+ "the switch position doesn't need to be changed: "
+ "pol %d, hiband %d, switch position %d",
+ pol, hiband, diseqc);
}
ad->old_pol = pol;
@@ -415,30 +431,154 @@ axe:
LOG("axe_fe: RESET failed for fd %d: %s", frontend_fd, strerror(errno));
if (axe_fe_input(frontend_fd, input))
LOG("axe_fe: INPUT failed for fd %d input %d: %s", frontend_fd, input, strerror(errno));
- if (opts.quattro)
- return freq;
return freq;
}
+#define ADD_PROP(c, d) { \
+ p_cmd[iProp].cmd = (c); \
+ p_cmd[iProp].u.data = (d); \
+ iProp++; \
+}
int axe_tune(int aid, transponder * tp)
{
adapter *ad = get_adapter(aid);
-
ssize_t drv;
char buf[1316];
+
+ int64_t bclear, bpol;
+ int iProp = 0;
+ int fd_frontend = ad->fe;
+
+ int freq = tp->freq;
+ struct dtv_property p_cmd[20];
+ struct dtv_properties p =
+ { .num = 0, .props = p_cmd };
+ struct dvb_frontend_event ev;
+
+ struct dtv_property p_clear[] =
+ {
+ { .cmd = DTV_CLEAR },
+ };
+
+ struct dtv_properties cmdseq_clear =
+ { .num = 1, .props = p_clear };
+
axe_set_tuner_led(aid + 1, 1);
axe_dmxts_stop(ad->dvr);
axe_fe_reset(ad->fe);
//probably can be removed
-
do { drv = read(ad->dvr, buf, sizeof(buf)); } while (drv > 0);
- return dvb_tune(aid, tp);
+ memset(p_cmd, 0, sizeof(p_cmd));
+ bclear = getTick();
+ if ((ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq_clear)) == -1)
+ {
+ LOG("FE_SET_PROPERTY DTV_CLEAR failed for fd %d: %s", fd_frontend,
+ strerror(errno));
+ // return -1;
+ }
+
+ switch (tp->sys)
+ {
+ case SYS_DVBS:
+ case SYS_DVBS2:
+
+ bpol = getTick();
+ freq = axe_setup_switch(ad);
+ if (freq < MIN_FRQ_DVBS || freq > MAX_FRQ_DVBS)
+ LOG_AND_RETURN(-404, "Frequency %d is not within range ", freq)
+
+ ADD_PROP(DTV_SYMBOL_RATE, tp->sr)
+ ADD_PROP(DTV_INNER_FEC, tp->fec)
+#if DVBAPIVERSION >= 0x0502
+ ADD_PROP(DTV_STREAM_ID, tp->plp)
+#endif
+
+ LOG("tuning to %d(%d) pol: %s (%d) sr:%d fec:%s delsys:%s mod:%s rolloff:%s pilot:%s, ts clear=%jd, ts pol=%jd",
+ tp->freq, freq, get_pol(tp->pol), tp->pol, tp->sr,
+ fe_fec[tp->fec], fe_delsys[tp->sys], fe_modulation[tp->mtype],
+ "auto", "auto",
+ bclear, bpol)
+ break;
+
+ case SYS_DVBT:
+ case SYS_DVBT2:
+
+ if (tp->freq < MIN_FRQ_DVBT || tp->freq > MAX_FRQ_DVBT)
+ LOG_AND_RETURN(-404, "Frequency %d is not within range ", tp->freq)
+
+ freq = freq * 1000;
+ ADD_PROP(DTV_BANDWIDTH_HZ, tp->bw)
+ ADD_PROP(DTV_CODE_RATE_HP, tp->fec)
+ ADD_PROP(DTV_CODE_RATE_LP, tp->fec)
+ ADD_PROP(DTV_GUARD_INTERVAL, tp->gi)
+ ADD_PROP(DTV_TRANSMISSION_MODE, tp->tmode)
+ ADD_PROP(DTV_HIERARCHY, HIERARCHY_AUTO)
+#if DVBAPIVERSION >= 0x0502
+ ADD_PROP(DTV_STREAM_ID, tp->plp & 0xFF)
+#endif
+
+ LOG(
+ "tuning to %d delsys: %s bw:%d inversion:%s mod:%s fec:%s guard:%s transmission: %s, ts clear = %jd",
+ freq, fe_delsys[tp->sys], tp->bw, fe_specinv[tp->inversion],
+ fe_modulation[tp->mtype], fe_fec[tp->fec], fe_gi[tp->gi],
+ fe_tmode[tp->tmode], bclear)
+ break;
+
+ case SYS_DVBC2:
+ case SYS_DVBC_ANNEX_A:
+
+ if (tp->freq < MIN_FRQ_DVBC || tp->freq > MAX_FRQ_DVBC)
+ LOG_AND_RETURN(-404, "Frequency %d is not within range ", tp->freq)
+
+ freq = freq * 1000;
+ ADD_PROP(DTV_SYMBOL_RATE, tp->sr)
+#if DVBAPIVERSION >= 0x0502
+ ADD_PROP(DTV_STREAM_ID, ((tp->ds & 0xFF) << 8) | (tp->plp & 0xFF))
+#endif
+ // valid for DD DVB-C2 devices
+
+ LOG("tuning to %d sr:%d specinv:%s delsys:%s mod:%s ts clear = %jd",
+ freq, tp->sr, fe_specinv[tp->inversion], fe_delsys[tp->sys],
+ fe_modulation[tp->mtype], bclear)
+ break;
+
+ default:
+ LOG("tuning to unknown delsys: %s freq %s ts clear = %jd", freq,
+ fe_delsys[tp->sys], bclear)
+ break;
+ }
+
+ ADD_PROP(DTV_FREQUENCY, freq)
+ ADD_PROP(DTV_INVERSION, tp->inversion)
+ ADD_PROP(DTV_MODULATION, tp->mtype);
+ ADD_PROP(DTV_DELIVERY_SYSTEM, tp->sys);
+ ADD_PROP(DTV_TUNE, 0)
+
+ p.num = iProp;
+ /* discard stale QPSK events */
+ while (1)
+ {
+ if (ioctl(fd_frontend, FE_GET_EVENT, &ev) == -1)
+ break;
+ }
+
+ if ((ioctl(fd_frontend, FE_SET_PROPERTY, &p)) == -1)
+ if (ioctl(fd_frontend, FE_SET_PROPERTY, &p) == -1)
+ {
+ LOG("dvb_tune: set property failed %d %s", errno, strerror(errno));
+ axe_set_tuner_led(aid + 1, 0);
+ return -404;
+ }
+
+ axe_dmxts_start(ad->dvr);
+ return 0;
}
+
int axe_set_pid(adapter *a, uint16_t i_pid)
{
if (i_pid > 8192 || a == NULL)
@@ -597,6 +737,7 @@ void find_axe_adapter(adapter **a)
ad->post_init = (Adapter_commit) axe_post_init;
ad->close = (Adapter_commit) axe_close;
ad->get_signal = (Device_signal) axe_get_signal;
+ ad->wakeup = (Device_wakeup) axe_wakeup;
ad->type = ADAPTER_DVB;
close(fd);
na++;
2018-03-05 21:37:06 +01:00
@@ -622,7 +763,7 @@ void free_axe_input(adapter *ad)
adapter *ad2;
for (aid = 0; aid < 4; aid++) {
- ad2 = get_adapter(aid);
+ ad2 = get_configured_adapter(aid);
if(ad2)
ad2->axe_used &= ~(1 << ad->id);
}
2017-05-07 09:05:04 +02:00
@@ -715,7 +856,6 @@ adapter *axe_vdevice_sync(int aid)
char buf[1024], *p;
int64_t t;
uint32_t addr, pktc, syncerrc, tperrc, ccerr;
- int fd;
if (!ad)
return NULL;
@@ -770,9 +910,9 @@ char *get_axe_coax(int aid, char *dest, int max_size)
2017-05-03 17:04:12 +02:00
_symbols axe_sym[] =
{
2017-05-03 17:04:12 +02:00
- { "ad_axe_pktc", VAR_FUNCTION_INT64, (void *) &get_axe_pktc, 0, 0, 0 },
- { "ad_axe_ccerr", VAR_FUNCTION_INT64, (void *) &get_axe_ccerr, 0, 0, 0 },
- { "ad_axe_coax", VAR_FUNCTION_STRING, (void *) &get_axe_coax, 0, 0, 0 },
+ { "ad_axe_pktc", VAR_FUNCTION_INT64, (void *) &get_axe_pktc, 0, MAX_ADAPTERS, 0 },
+ { "ad_axe_ccerr", VAR_FUNCTION_INT64, (void *) &get_axe_ccerr, 0, MAX_ADAPTERS, 0 },
+ { "ad_axe_coax", VAR_FUNCTION_STRING, (void *) &get_axe_coax, 0, MAX_ADAPTERS, 0 },
{ NULL, 0, NULL, 0, 0 }
};
2017-05-07 09:05:04 +02:00
diff --git a/axe.h b/axe.h
index af35a61..46ce50c 100644
--- a/axe.h
+++ b/axe.h
@@ -97,7 +97,7 @@ static inline int axe_dmxts_stop(int fd)
void axe_set_tuner_led(int tuner, int on);
void axe_set_network_led(int on);
void axe_status(char *buf, size_t buflen);
-void axe_wakeup(int fe_fd, int voltage);
+void axe_wakeup(void *ad, int fe_fd, int voltage);
void find_axe_adapter(adapter **a);
int axe_setup_switch(adapter *ad);
void free_axe_input(adapter *ad);
diff --git a/dvb.c b/dvb.c
2017-05-12 09:56:52 +02:00
index 15f59c8..a38e5ef 100644
2017-05-07 09:05:04 +02:00
--- a/dvb.c
+++ b/dvb.c
@@ -42,10 +42,6 @@
#include "ca.h"
#include "utils.h"
-#ifdef AXE
-#include "axe.h"
-#endif
-
char *fe_pilot[] =
{ "on", "off", " ", //auto
NULL };
2017-05-12 09:56:52 +02:00
@@ -417,6 +413,11 @@ int send_diseqc(adapter *ad, int fd, int pos, int pos_change, int pol, int hiban
{ 0xe0, 0x10, 0x39, 0xf0, 0x00, 0x00 }, 4
};
+ if (pos_change && ad->diseqc_multi >= 0 && pos != ad->diseqc_multi) {
+ send_diseqc(ad, fd, ad->diseqc_multi, 1, pol, hiband, d);
+ pos_change = 1;
+ }
+
if (uncommitted_no > committed_no)
uncommitted_first = 1;
@@ -436,9 +437,8 @@ int send_diseqc(adapter *ad, int fd, int pos, int pos_change, int pol, int hiban
2017-05-07 09:05:04 +02:00
LOGL(3, "send_diseqc fd %d, pos = %d (c %d u %d), pol = %d, hiband = %d",
fd, pos, posc, posu, pol, hiband);
-#ifdef AXE
- axe_wakeup(fd, pol ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13);
-#endif
+ if (ad->wakeup)
+ ad->wakeup(ad, fd, pol ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13);
if (ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1)
LOG("send_diseqc: FE_SET_TONE failed for fd %d: %s", fd,
2017-05-12 09:56:52 +02:00
@@ -504,9 +504,8 @@ int send_unicable(adapter *ad, int fd, int freq, int pos, int pol, int hiband, d
2017-05-07 09:05:04 +02:00
"send_unicable fd %d, freq %d, ufreq %d, pos = %d, pol = %d, hiband = %d, slot %d, diseqc => %02x %02x %02x %02x %02x",
fd, freq, d->ufreq, pos, pol, hiband, d->uslot, cmd.msg[0],
cmd.msg[1], cmd.msg[2], cmd.msg[3], cmd.msg[4]);
-#ifdef AXE
- axe_wakeup(fd, SEC_VOLTAGE_13);
-#endif
+ if (ad->wakeup)
+ ad->wakeup(ad, fd, SEC_VOLTAGE_13);
if(!ad->tune_time)
{
if (ioctl(fd, FE_SET_VOLTAGE, SEC_VOLTAGE_13) == -1)
2017-05-12 09:56:52 +02:00
@@ -551,14 +550,12 @@ int send_jess(adapter *ad, int fd, int freq, int pos, int pol, int hiband, diseq
2017-05-07 09:05:04 +02:00
cmd.msg[4] = d->pin;
}
- LOGL(3,
- "send_jess fd %d, freq %d, ufreq %d, pos = %d, pol = %d, hiband = %d, slot %d, diseqc => %02x %02x %02x %02x %02x",
- fd, freq, d->ufreq, pos, pol, hiband, d->uslot, cmd.msg[0],
- cmd.msg[1], cmd.msg[2], cmd.msg[3], cmd.msg[4]);
+ LOGL(3, "send_jess fd %d, freq %d, ufreq %d, pos = %d, pol = %d, hiband = %d, slot %d, diseqc => %02x %02x %02x %02x %02x",
+ fd, freq, d->ufreq, pos, pol, hiband, d->uslot, cmd.msg[0],
+ cmd.msg[1], cmd.msg[2], cmd.msg[3], cmd.msg[4]);
-#ifdef AXE
- axe_wakeup(fd, SEC_VOLTAGE_13);
-#endif
+ if (ad->wakeup)
+ ad->wakeup(ad, fd, SEC_VOLTAGE_13);
if(!ad->tune_time)
{
2017-05-12 09:56:52 +02:00
@@ -609,23 +606,13 @@ int setup_switch(adapter *ad)
2017-05-07 09:05:04 +02:00
if (tp->diseqc_param.switch_type == SWITCH_UNICABLE)
{
-#ifdef AXE
- freq = send_unicable(ad, ad->fe2, freq / 1000, diseqc, pol, hiband,
- &tp->diseqc_param);
-#else
- freq = send_unicable(ad, frontend_fd, freq / 1000, diseqc, pol, hiband,
- &tp->diseqc_param);
-#endif
+ freq = send_unicable(ad, frontend_fd, freq / 1000, diseqc,
+ pol, hiband, &tp->diseqc_param);
}
else if (tp->diseqc_param.switch_type == SWITCH_JESS)
{
-#ifdef AXE
- freq = send_jess(ad, ad->fe2, freq / 1000, diseqc, pol, hiband,
- &tp->diseqc_param);
-#else
- freq = send_jess(ad, frontend_fd, freq / 1000, diseqc, pol, hiband,
- &tp->diseqc_param);
-#endif
+ freq = send_jess(ad, frontend_fd, freq / 1000, diseqc,
+ pol, hiband, &tp->diseqc_param);
}
else if (tp->diseqc_param.switch_type == SWITCH_SLAVE)
{
2017-05-12 09:56:52 +02:00
@@ -639,9 +626,9 @@ int setup_switch(adapter *ad)
2017-05-07 09:05:04 +02:00
hiband, &tp->diseqc_param);
else
LOGL(3, "Skip sending diseqc commands since "
- "the switch position doesn't need to be changed: "
- "pol %d, hiband %d, switch position %d", pol, hiband,
- diseqc);
+ "the switch position doesn't need to be changed: "
+ "pol %d, hiband %d, switch position %d",
+ pol, hiband, diseqc);
}
ad->old_pol = pol;
2017-05-12 09:56:52 +02:00
@@ -694,35 +681,24 @@ int dvb_tune(int aid, transponder * tp)
2017-05-07 09:05:04 +02:00
case SYS_DVBS2:
bpol = getTick();
-#ifndef AXE
freq = setup_switch(ad);
-#else
- freq = axe_setup_switch(ad);
-#endif
if (freq < MIN_FRQ_DVBS || freq > MAX_FRQ_DVBS)
LOG_AND_RETURN(-404, "Frequency %d is not within range ", freq)
- ADD_PROP(DTV_SYMBOL_RATE, tp->sr)
+ ADD_PROP(DTV_SYMBOL_RATE, tp->sr)
ADD_PROP(DTV_INNER_FEC, tp->fec)
-#ifndef AXE
- ADD_PROP(DTV_PILOT, tp->plts)
- ADD_PROP(DTV_ROLLOFF, tp->ro)
-#endif
+ ADD_PROP(DTV_PILOT, tp->plts)
+ ADD_PROP(DTV_ROLLOFF, tp->ro)
#if DVBAPIVERSION >= 0x0502
- ADD_PROP(DTV_STREAM_ID, tp->plp)
+ ADD_PROP(DTV_STREAM_ID, tp->plp)
#endif
- LOG(
- "tuning to %d(%d) pol: %s (%d) sr:%d fec:%s delsys:%s mod:%s rolloff:%s pilot:%s, ts clear=%jd, ts pol=%jd",
- tp->freq, freq, get_pol(tp->pol), tp->pol, tp->sr,
- fe_fec[tp->fec], fe_delsys[tp->sys], fe_modulation[tp->mtype],
-#ifdef AXE
- "auto", "auto",
-#else
- fe_rolloff[tp->ro], fe_pilot[tp->plts],
-#endif
- bclear, bpol)
- break;
+ LOG("tuning to %d(%d) pol: %s (%d) sr:%d fec:%s delsys:%s mod:%s rolloff:%s pilot:%s, ts clear=%jd, ts pol=%jd",
+ tp->freq, freq, get_pol(tp->pol), tp->pol, tp->sr,
+ fe_fec[tp->fec], fe_delsys[tp->sys], fe_modulation[tp->mtype],
+ fe_rolloff[tp->ro], fe_pilot[tp->plts],
+ bclear, bpol)
+ break;
case SYS_DVBT:
case SYS_DVBT2:
2017-05-12 09:56:52 +02:00
@@ -799,7 +775,7 @@ int dvb_tune(int aid, transponder * tp)
2017-05-07 09:05:04 +02:00
break;
default:
- LOG("tuninng to unknown delsys: %s freq %s ts clear = %jd", freq,
+ LOG("tuning to unknown delsys: %s freq %s ts clear = %jd", freq,
fe_delsys[tp->sys], bclear)
break;
}
2017-05-12 09:56:52 +02:00
@@ -822,14 +798,8 @@ int dvb_tune(int aid, transponder * tp)
2017-05-07 09:05:04 +02:00
if (ioctl(fd_frontend, FE_SET_PROPERTY, &p) == -1)
{
LOG("dvb_tune: set property failed %d %s", errno, strerror(errno));
-#ifdef AXE
- axe_set_tuner_led(aid + 1, 0);
-#endif
return -404;
}
-#ifdef AXE
- axe_dmxts_start(ad->dvr);
-#endif
return 0;
}
2017-05-12 09:56:52 +02:00
@@ -984,7 +954,7 @@ fe_delivery_system_t dvb_delsys(int aid, int fd, fe_delivery_system_t *sys)
2017-05-07 09:05:04 +02:00
}
-void get_signal(int fd, int * status, uint32_t * ber, uint16_t * strength,
+void get_signal(int fd, uint32_t * status, uint32_t * ber, uint16_t * strength,
uint16_t * snr)
{
*status = *ber = *snr = *strength = 0;
2017-05-12 09:56:52 +02:00
@@ -1009,7 +979,7 @@ void get_signal(int fd, int * status, uint32_t * ber, uint16_t * strength,
2017-05-07 09:05:04 +02:00
}
}
-int get_signal_new(int fd, int * status, uint32_t * ber, uint16_t * strength,
+int get_signal_new(int fd, uint32_t * status, uint32_t * ber, uint16_t * strength,
uint16_t * snr)
{
diff --git a/dvb.h b/dvb.h
index ae3991e..26a67d2 100644
--- a/dvb.h
+++ b/dvb.h
@@ -241,4 +241,11 @@ char *get_gi(int i);
char *get_specinv(int i);
char *get_pol(int i);
+extern char *fe_delsys[];
+extern char *fe_fec[];
+extern char *fe_tmode[];
+extern char *fe_modulation[];
+extern char *fe_specinv[];
+extern char *fe_gi[];
+
#endif /* */
2017-05-03 17:04:12 +02:00
diff --git a/html/sort_desc.png b/html/sort_desc.png
new file mode 100644
index 0000000..0e156de
Binary files /dev/null and b/html/sort_desc.png differ
diff --git a/html/status.html b/html/status.html
index 8d2f6e5..812a13d 100755
--- a/html/status.html
+++ b/html/status.html
@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8"/>
- <title>Minisatip/$version$ on $http_host$</title>
+ <title>Minisatip status</title>
<link rel="stylesheet" type="text/css" href="jquery.dataTables.min.css">
<style>
body {
@@ -47,9 +47,17 @@
margin: 0 4px;
padding: 0;
}
- .polling {
+ .upperbar {
padding-bottom: 4px;
}
+ .separator {
+ padding-left: 16px;
+ }
+ .dstate {
+ text-valign: center;
+ text-size: 1.5em;
+ font-family: "Lucida Console", Monaco, monospace;
+ }
</style>
<script type="text/javascript" language="javascript" src="jquery-1.12.0.min.js"></script>
@@ -58,201 +66,204 @@
</head>
<body>
-<div class="polling">Refresh:
+<table class='display cell-border compact'><tbody><tr>
+<td class="upperbar">Refresh:
<input type="text" id="pintervall" value="" readonly /> sec.
<button id="pdec">&minus;</button>
<button id="pstatus">PAUSE</button>
<button id="pinc">+</button>
-</div>
+</td>
+<td class="separator" />
+<td class="upperbar">
+<button id="stats">Stats ON</button>
+</td>
+<td class="separator" />
+<td id="statsarea" class="upperbar"/>
+</tr></tbody></table>
+
+<div id="table"/>
<script type="text/javascript">
-var ad_type = [ $ad_type0$, $ad_type1$, $ad_type2$, $ad_type3$, $ad_type4$, $ad_type5$, $ad_type6$, $ad_type7$, $ad_type8$, $ad_type9$, $ad_type10$, $ad_type11$, $ad_type12$, $ad_type13$, $ad_type14$, $ad_type15$, $ad_type16$, $ad_type17$, $ad_type18$, $ad_type19$, $ad_type20$, $ad_type21$, $ad_type22$, $ad_type23$, $ad_type24$, $ad_type25$, $ad_type26$, $ad_type27$, $ad_type28$, $ad_type29$, $ad_type30$, $ad_type31$ ];
-var ad_enabled = [ $ad_enabled0$, $ad_enabled1$, $ad_enabled2$, $ad_enabled3$, $ad_enabled4$, $ad_enabled5$, $ad_enabled6$, $ad_enabled7$, $ad_enabled8$, $ad_enabled9$, $ad_enabled10$, $ad_enabled11$, $ad_enabled12$, $ad_enabled13$, $ad_enabled14$, $ad_enabled15$, $ad_enabled16$, $ad_enabled17$, $ad_enabled18$, $ad_enabled19$, $ad_enabled20$, $ad_enabled21$, $ad_enabled22$, $ad_enabled23$, $ad_enabled24$, $ad_enabled25$, $ad_enabled26$, $ad_enabled27$, $ad_enabled28$, $ad_enabled29$, $ad_enabled30$, $ad_enabled31$ ];
-var ad_sys = [ $ad_sys0$, $ad_sys1$, $ad_sys2$, $ad_sys3$, $ad_sys4$, $ad_sys5$, $ad_sys6$, $ad_sys7$, $ad_sys8$, $ad_sys9$, $ad_sys10$, $ad_sys11$, $ad_sys12$, $ad_sys13$, $ad_sys14$, $ad_sys15$, $ad_sys16$, $ad_sys17$, $ad_sys18$, $ad_sys19$, $ad_sys20$, $ad_sys21$, $ad_sys22$, $ad_sys23$, $ad_sys24$, $ad_sys25$, $ad_sys26$, $ad_sys27$, $ad_sys28$, $ad_sys29$, $ad_sys30$, $ad_sys31$ ];
-var ad_strength = [ $ad_strength0$, $ad_strength1$, $ad_strength2$, $ad_strength3$, $ad_strength4$, $ad_strength5$, $ad_strength6$, $ad_strength7$, $ad_strength8$, $ad_strength9$, $ad_strength10$, $ad_strength11$, $ad_strength12$, $ad_strength13$, $ad_strength14$, $ad_strength15$, $ad_strength16$, $ad_strength17$, $ad_strength18$, $ad_strength19$, $ad_strength20$, $ad_strength21$, $ad_strength22$, $ad_strength23$, $ad_strength24$, $ad_strength25$, $ad_strength26$, $ad_strength27$, $ad_strength28$, $ad_strength29$, $ad_strength30$, $ad_strength31$ ];
-var ad_ber = [ $ad_ber0$, $ad_ber1$, $ad_ber2$, $ad_ber3$, $ad_ber4$, $ad_ber5$, $ad_ber6$, $ad_ber7$, $ad_ber8$, $ad_ber9$, $ad_ber10$, $ad_ber11$, $ad_ber12$, $ad_ber13$, $ad_ber14$, $ad_ber15$, $ad_ber16$, $ad_ber17$, $ad_ber18$, $ad_ber19$, $ad_ber20$, $ad_ber21$, $ad_ber22$, $ad_ber23$, $ad_ber24$, $ad_ber25$, $ad_ber26$, $ad_ber27$, $ad_ber28$, $ad_ber29$, $ad_ber30$, $ad_ber31$ ];
-var ad_master = [ $ad_master0$, $ad_master1$, $ad_master2$, $ad_master3$, $ad_master4$, $ad_master5$, $ad_master6$, $ad_master7$, $ad_master8$, $ad_master9$, $ad_master10$, $ad_master11$, $ad_master12$, $ad_master13$, $ad_master14$, $ad_master15$, $ad_master16$, $ad_master17$, $ad_master18$, $ad_master19$, $ad_master20$, $ad_master21$, $ad_master22$, $ad_master23$, $ad_master24$, $ad_master25$, $ad_master26$, $ad_master27$, $ad_master28$, $ad_master29$, $ad_master30$, $ad_master31$ ];
-var ad_pos = [ $ad_pos0$, $ad_pos1$, $ad_pos2$, $ad_pos3$, $ad_pos4$, $ad_pos5$, $ad_pos6$, $ad_pos7$, $ad_pos8$, $ad_pos9$, $ad_pos10$, $ad_pos11$, $ad_pos12$, $ad_pos13$, $ad_pos14$, $ad_pos15$, $ad_pos16$, $ad_pos17$, $ad_pos18$, $ad_pos19$, $ad_pos20$, $ad_pos21$, $ad_pos22$, $ad_pos23$, $ad_pos24$, $ad_pos25$, $ad_pos26$, $ad_pos27$, $ad_pos28$, $ad_pos29$, $ad_pos30$, $ad_pos31$ ];
-var ad_freq = [ $ad_freq0$, $ad_freq1$, $ad_freq2$, $ad_freq3$, $ad_freq4$, $ad_freq5$, $ad_freq6$, $ad_freq7$, $ad_freq8$, $ad_freq9$, $ad_freq10$, $ad_freq11$, $ad_freq12$, $ad_freq13$, $ad_freq14$, $ad_freq15$, $ad_freq16$, $ad_freq17$, $ad_freq18$, $ad_freq19$, $ad_freq20$, $ad_freq21$, $ad_freq22$, $ad_freq23$, $ad_freq24$, $ad_freq25$, $ad_freq26$, $ad_freq27$, $ad_freq28$, $ad_freq29$, $ad_freq30$, $ad_freq31$ ];
-var ad_pol = [ $ad_pol0$, $ad_pol1$, $ad_pol2$, $ad_pol3$, $ad_pol4$, $ad_pol5$, $ad_pol6$, $ad_pol7$, $ad_pol8$, $ad_pol9$, $ad_pol10$, $ad_pol11$, $ad_pol12$, $ad_pol13$, $ad_pol14$, $ad_pol15$, $ad_pol16$, $ad_pol17$, $ad_pol18$, $ad_pol19$, $ad_pol20$, $ad_pol21$, $ad_pol22$, $ad_pol23$, $ad_pol24$, $ad_pol25$, $ad_pol26$, $ad_pol27$, $ad_pol28$, $ad_pol29$, $ad_pol30$, $ad_pol31$ ];
-var ad_sr = [ $ad_sr0$, $ad_sr1$, $ad_sr2$, $ad_sr3$, $ad_sr4$, $ad_sr5$, $ad_sr6$, $ad_sr7$, $ad_sr8$, $ad_sr9$, $ad_sr10$, $ad_sr11$, $ad_sr12$, $ad_sr13$, $ad_sr14$, $ad_sr15$, $ad_sr16$, $ad_sr17$, $ad_sr18$, $ad_sr19$, $ad_sr20$, $ad_sr21$, $ad_sr22$, $ad_sr23$, $ad_sr24$, $ad_sr25$, $ad_sr26$, $ad_sr27$, $ad_sr28$, $ad_sr29$, $ad_sr30$, $ad_sr31$ ];
-var ad_bw = [ $ad_bw0$, $ad_bw1$, $ad_bw2$, $ad_bw3$, $ad_bw4$, $ad_bw5$, $ad_bw6$, $ad_bw7$, $ad_bw8$, $ad_bw9$, $ad_bw10$, $ad_bw11$, $ad_bw12$, $ad_bw13$, $ad_bw14$, $ad_bw15$, $ad_bw16$, $ad_bw17$, $ad_bw18$, $ad_bw19$, $ad_bw20$, $ad_bw21$, $ad_bw22$, $ad_bw23$, $ad_bw24$, $ad_bw25$, $ad_bw26$, $ad_bw27$, $ad_bw28$, $ad_bw29$, $ad_bw30$, $ad_bw31$ ];
-var ad_diseqc = [ $ad_diseqc0$, $ad_diseqc1$, $ad_diseqc2$, $ad_diseqc3$, $ad_diseqc4$, $ad_diseqc5$, $ad_diseqc6$, $ad_diseqc7$, $ad_diseqc8$, $ad_diseqc9$, $ad_diseqc10$, $ad_diseqc11$, $ad_diseqc12$, $ad_diseqc13$, $ad_diseqc14$, $ad_diseqc15$, $ad_diseqc16$, $ad_diseqc17$, $ad_diseqc18$, $ad_diseqc19$, $ad_diseqc20$, $ad_diseqc21$, $ad_diseqc22$, $ad_diseqc23$, $ad_diseqc24$, $ad_diseqc25$, $ad_diseqc26$, $ad_diseqc27$, $ad_diseqc28$, $ad_diseqc29$, $ad_diseqc30$, $ad_diseqc31$ ];
-var ad_snr = [ $ad_snr0$, $ad_snr1$, $ad_snr2$, $ad_snr3$, $ad_snr4$, $ad_snr5$, $ad_snr6$, $ad_snr7$, $ad_snr8$, $ad_snr9$, $ad_snr10$, $ad_snr11$, $ad_snr12$, $ad_snr13$, $ad_snr14$, $ad_snr15$, $ad_snr16$, $ad_snr17$, $ad_snr18$, $ad_snr19$, $ad_snr20$, $ad_snr21$, $ad_snr22$, $ad_snr23$, $ad_snr24$, $ad_snr25$, $ad_snr26$, $ad_snr27$, $ad_snr28$, $ad_snr29$, $ad_snr30$, $ad_snr31$ ];
-var ad_phyad = [ $ad_phyad0$, $ad_phyad1$, $ad_phyad2$, $ad_phyad3$, $ad_phyad4$, $ad_phyad5$, $ad_phyad6$, $ad_phyad7$, $ad_phyad8$, $ad_phyad9$, $ad_phyad10$, $ad_phyad11$, $ad_phyad12$, $ad_phyad13$, $ad_phyad14$, $ad_phyad15$, $ad_phyad16$, $ad_phyad17$, $ad_phyad18$, $ad_phyad19$, $ad_phyad20$, $ad_phyad21$, $ad_phyad22$, $ad_phyad23$, $ad_phyad24$, $ad_phyad25$, $ad_phyad26$, $ad_phyad27$, $ad_phyad28$, $ad_phyad29$, $ad_phyad30$, $ad_phyad31$ ];
-var ad_phyfd = [ $ad_phyfd0$, $ad_phyfd1$, $ad_phyfd2$, $ad_phyfd3$, $ad_phyfd4$, $ad_phyfd5$, $ad_phyfd6$, $ad_phyfd7$, $ad_phyfd8$, $ad_phyfd9$, $ad_phyfd10$, $ad_phyfd11$, $ad_phyfd12$, $ad_phyfd13$, $ad_phyfd14$, $ad_phyfd15$, $ad_phyfd16$, $ad_phyfd17$, $ad_phyfd18$, $ad_phyfd19$, $ad_phyfd20$, $ad_phyfd21$, $ad_phyfd22$, $ad_phyfd23$, $ad_phyfd24$, $ad_phyfd25$, $ad_phyfd26$, $ad_phyfd27$, $ad_phyfd28$, $ad_phyfd29$, $ad_phyfd30$, $ad_phyfd31$ ];
-var ad_allsys = [ "$ad_allsys0$", "$ad_allsys1$", "$ad_allsys2$", "$ad_allsys3$", "$ad_allsys4$", "$ad_allsys5$", "$ad_allsys6$", "$ad_allsys7$", "$ad_allsys8$", "$ad_allsys9$", "$ad_allsys10$", "$ad_allsys11$", "$ad_allsys12$", "$ad_allsys13$", "$ad_allsys14$", "$ad_allsys15$", "$ad_allsys16$", "$ad_allsys17$", "$ad_allsys18$", "$ad_allsys19$", "$ad_allsys20$", "$ad_allsys21$", "$ad_allsys22$", "$ad_allsys23$", "$ad_allsys24$", "$ad_allsys25$", "$ad_allsys26$", "$ad_allsys27$", "$ad_allsys28$", "$ad_allsys29$", "$ad_allsys30$", "$ad_allsys31$" ];
-var ad_pids = [ "$ad_pids0$", "$ad_pids1$", "$ad_pids2$", "$ad_pids3$", "$ad_pids4$", "$ad_pids5$", "$ad_pids6$", "$ad_pids7$", "$ad_pids8$", "$ad_pids9$", "$ad_pids10$", "$ad_pids11$", "$ad_pids12$", "$ad_pids13$", "$ad_pids14$", "$ad_pids15$", "$ad_pids16$", "$ad_pids17$", "$ad_pids18$", "$ad_pids19$", "$ad_pids20$", "$ad_pids21$", "$ad_pids22$", "$ad_pids23$", "$ad_pids24$", "$ad_pids25$", "$ad_pids26$", "$ad_pids27$", "$ad_pids28$", "$ad_pids29$", "$ad_pids30$", "$ad_pids31$" ];
-var ad_satip = [ "$ad_satip0$", "$ad_satip1$", "$ad_satip2$", "$ad_satip3$", "$ad_satip4$", "$ad_satip5$", "$ad_satip6$", "$ad_satip7$", "$ad_satip8$", "$ad_satip9$", "$ad_satip10$", "$ad_satip11$", "$ad_satip12$", "$ad_satip13$", "$ad_satip14$", "$ad_satip15$", "$ad_satip16$", "$ad_satip17$", "$ad_satip18$", "$ad_satip19$", "$ad_satip20$", "$ad_satip21$", "$ad_satip22$", "$ad_satip23$", "$ad_satip24$", "$ad_satip25$", "$ad_satip26$", "$ad_satip27$", "$ad_satip28$", "$ad_satip29$", "$ad_satip30$", "$ad_satip31$" ];
-var ad_axe_pktc = [$ad_axe_pktc0$, $ad_axe_pktc1$, $ad_axe_pktc2$, $ad_axe_pktc3$];
-var ad_axe_ccerr = [$ad_axe_ccerr0$, $ad_axe_ccerr1$, $ad_axe_ccerr2$, $ad_axe_ccerr3$];
-var ad_axe_coax = ["$ad_axe_coax0$", "$ad_axe_coax1$", "$ad_axe_coax2$", "$ad_axe_coax3$"];
-var st_enabled = [$st_enabled0$, $st_enabled1$, $st_enabled2$, $st_enabled3$, $st_enabled4$, $st_enabled5$, $st_enabled6$, $st_enabled7$, $st_enabled8$, $st_enabled9$, $st_enabled10$, $st_enabled11$, $st_enabled12$, $st_enabled13$, $st_enabled14$, $st_enabled15$ ];
-var st_adapter = [$st_adapter0$, $st_adapter1$, $st_adapter2$, $st_adapter3$, $st_adapter4$, $st_adapter5$, $st_adapter6$, $st_adapter7$, $st_adapter8$, $st_adapter9$, $st_adapter10$, $st_adapter11$, $st_adapter12$, $st_adapter13$, $st_adapter14$, $st_adapter15$ ];
-var st_rport = [$st_rport0$, $st_rport1$, $st_rport2$, $st_rport3$, $st_rport4$, $st_rport5$, $st_rport6$, $st_rport7$, $st_rport8$, $st_rport9$, $st_rport10$, $st_rport11$, $st_rport12$, $st_rport13$, $st_rport14$, $st_rport15$ ];
-var st_rhost = ["$st_rhost0$", "$st_rhost1$", "$st_rhost2$", "$st_rhost3$", "$st_rhost4$", "$st_rhost5$", "$st_rhost6$", "$st_rhost7$", "$st_rhost8$", "$st_rhost9$", "$st_rhost10$", "$st_rhost11$", "$st_rhost12$", "$st_rhost13$", "$st_rhost14$", "$st_rhost15$" ];
-var st_pids = ["$st_pids0$", "$st_pids1$", "$st_pids2$", "$st_pids3$", "$st_pids4$", "$st_pids5$", "$st_pids6$", "$st_pids7$", "$st_pids8$", "$st_pids9$", "$st_pids10$", "$st_pids11$", "$st_pids12$", "$st_pids13$", "$st_pids14$", "$st_pids15$" ];
-var st_useragent = ["$st_useragent0$", "$st_useragent1$", "$st_useragent2$", "$st_useragent3$", "$st_useragent4$", "$st_useragent5$", "$st_useragent6$", "$st_useragent7$", "$st_useragent8$", "$st_useragent9$", "$st_useragent10$", "$st_useragent11$", "$st_useragent12$", "$st_useragent13$", "$st_useragent14$", "$st_useragent15$" ];
-var st_play = [$st_play0$, $st_play1$, $st_play2$, $st_play3$, $st_play4$, $st_play5$, $st_play6$, $st_play7$, $st_play8$, $st_play9$, $st_play10$, $st_play11$, $st_play12$, $st_play13$, $st_play14$, $st_play15$ ];
-var key_enabled = [$key_enabled0$, $key_enabled1$, $key_enabled2$, $key_enabled3$, $key_enabled4$, $key_enabled5$, $key_enabled6$, $key_enabled7$, $key_enabled8$, $key_enabled9$, $key_enabled10$, $key_enabled11$, $key_enabled12$, $key_enabled13$, $key_enabled14$, $key_enabled15$ ];
-var key_hops = [$key_hops0$, $key_hops1$, $key_hops2$, $key_hops3$, $key_hops4$, $key_hops5$, $key_hops6$, $key_hops7$, $key_hops8$, $key_hops9$, $key_hops10$, $key_hops11$, $key_hops12$, $key_hops13$, $key_hops14$, $key_hops15$ ];
-var key_adapter = [$key_adapter0$, $key_adapter1$, $key_adapter2$, $key_adapter3$, $key_adapter4$, $key_adapter5$, $key_adapter6$, $key_adapter7$, $key_adapter8$, $key_adapter9$, $key_adapter10$, $key_adapter11$, $key_adapter12$, $key_adapter13$, $key_adapter14$, $key_adapter15$ ];
-var key_pmt = [$key_pmt0$, $key_pmt1$, $key_pmt2$, $key_pmt3$, $key_pmt4$, $key_pmt5$, $key_pmt6$, $key_pmt7$, $key_pmt8$, $key_pmt9$, $key_pmt10$, $key_pmt11$, $key_pmt12$, $key_pmt13$, $key_pmt14$, $key_pmt15$ ];
-var key_ecmtime = [$key_ecmtime0$, $key_ecmtime1$, $key_ecmtime2$, $key_ecmtime3$, $key_ecmtime4$, $key_ecmtime5$, $key_ecmtime6$, $key_ecmtime7$, $key_ecmtime8$, $key_ecmtime9$, $key_ecmtime10$, $key_ecmtime11$, $key_ecmtime12$, $key_ecmtime13$, $key_ecmtime14$, $key_ecmtime15$ ];
-var key_cardsystem = ["$key_cardsystem0$", "$key_cardsystem1$", "$key_cardsystem2$", "$key_cardsystem3$", "$key_cardsystem4$", "$key_cardsystem5$", "$key_cardsystem6$", "$key_cardsystem7$", "$key_cardsystem8$", "$key_cardsystem9$", "$key_cardsystem10$", "$key_cardsystem11$", "$key_cardsystem12$", "$key_cardsystem13$", "$key_cardsystem14$", "$key_cardsystem15$" ];
-var key_reader = ["$key_reader0$", "$key_reader1$", "$key_reader2$", "$key_reader3$", "$key_reader4$", "$key_reader5$", "$key_reader6$", "$key_reader7$", "$key_reader8$", "$key_reader9$", "$key_reader10$", "$key_reader11$", "$key_reader12$", "$key_reader13$", "$key_reader14$", "$key_reader15$" ];
-var key_from = ["$key_from0$", "$key_from1$", "$key_from2$", "$key_from3$", "$key_from4$", "$key_from5$", "$key_from6$", "$key_from7$", "$key_from8$", "$key_from9$", "$key_from10$", "$key_from11$", "$key_from12$", "$key_from13$", "$key_from14$", "$key_from15$" ];
-var key_protocol = ["$key_protocol0$", "$key_protocol1$", "$key_protocol2$", "$key_protocol3$", "$key_protocol4$", "$key_protocol5$", "$key_protocol6$", "$key_protocol7$", "$key_protocol8$", "$key_protocol9$", "$key_protocol10$", "$key_protocol11$", "$key_protocol12$", "$key_protocol13$", "$key_protocol14$", "$key_protocol15$" ];
-
-var max_adapters = 32;
-var max_streams = 64;
-var max_keys = 255;
-var pol = ["", "(V)", "(H)", "(R)", "(L)"];
-var sys = [ "", "dvbc", "dvbcb", "dvbt", "dss", "dvbs", "dvbs2", "dvbh", "isdbt", "isdbs", "isdbc", "atsc", "atscmh", "dmbth", "cmmb", "dab", "dvbt2", "turbo", "dvbcc", "dvbc2" ];
-
-var has_axe = $has_axe$;
-
-var myTable = "<table id='myTable' class='display cell-border compact' cellspacing='0' width='100%'>";
-myTable += "<thead><tr><th>Tuner</th>";
-myTable += "<th class=''>Status</th>";
-myTable += "<th class='dt-right'>Pos.</th>";
-myTable += "<th class='dt-right'>Frequency</th>";
-myTable += "<th class='dt-right'>SR/BW</th>";
-myTable += "<th class='dt-right'>Signal</th>";
-if(has_axe)
-{
-myTable += "<th class='dt-right'>Packets</th>";
-myTable += "<th class='dt-right'>CC Errors</th>";
-myTable += "<th class='dt-right'>Coax Cable</th>";
+
+function getDebug(data) {
+ var s = "BW <strong>" + data.bw + "</strong>KB/s | " +
+ "Total BW <strong>" + data.tbw + "</strong>MiB | " +
+ "ns/read " + data.ns_read + " | " +
+ "reads " + data.reads + " | " +
+ "writes " + data.writes + " | ";
+ if (data.fwrites)
+ s += "failed writes " + data.fwrites + " | ";
+ s += "tt <strong>" + data.tt + "</strong>ms";
+ return "<div class='dstate'>" + s + "</div>";
}
-myTable += "<th class='dt-left'>Streams</th>";
-myTable += "<th class='dt-left'>Cryptinfo</th>";
-myTable += "</tr></thead><tbody>";
-
-for (var i = 0; i < max_adapters; i++) {
- if (ad_type[i] == 0)
- continue;
-
- if (ad_enabled[i] == 1)
- myTable += "<tr valign='top'>";
- else
- myTable += "<tr style='opacity: 0.5;'>";
-
- // TUNER
- myTable += "<td class='dt-right'>" + i + "</td>";
-
- // STATUS
- var csys = "";
- if (ad_sys[i] == 0)
- csys = ad_allsys[i];
- else
- csys = sys[ad_sys[i]];
-
- var tmpimg = csys.split(',');
- var sysimg = csys;
- if(tmpimg.length > 0)
- sysimg = tmpimg[0];
-
- if (ad_enabled[i] == 1)
- myTable += "<td class='dt-right enabled'><img src='" + sysimg + ".png' title='" + csys + "' /><br />";
- else
- myTable += "<td class='dt-right disabled'>" + ad_allsys[i];
-
- if (ad_type[i] == 1 || ad_type[i] == 3) {
- // myTable += "<small>(" + ad_phyad[i] + "," + ad_phyfd[i] +")</small>";
- } else {
- myTable += "<small>(" + ad_satip[i] + ")</small>";
+
+var pol = ["", "(V)", "(H)", "(R)", "(L)"];
+var sys = ["", "dvbc", "dvbcb", "dvbt", "dss", "dvbs", "dvbs2", "dvbh", "isdbt", "isdbs", "isdbc", "atsc", "atscmh", "dmbth", "cmmb", "dab", "dvbt2", "turbo", "dvbcc", "dvbc2"];
+
+function getTable(state) {
+
+ if (!state)
+ return '';
+
+ var myTable = '';
+ var max_adapters = state['ad_enabled'].length;
+ var max_streams = state['st_enabled'].length;
+ var max_keys = 'key_enabled' in state ? state['key_enabled'].length : 0;
+ var has_axe = state['has_axe'];
+
+ var myTable = "<table id='myTable' class='display cell-border compact' cellspacing='0' width='100%'>";
+ myTable += "<thead><tr><th>Tuner</th>";
+ myTable += "<th class=''>Status</th>";
+ myTable += "<th class='dt-right'>Pos.</th>";
+ myTable += "<th class='dt-right'>Frequency</th>";
+ myTable += "<th class='dt-right'>SR/BW</th>";
+ myTable += "<th class='dt-right'>Signal</th>";
+ if(state['has_axe'])
+ {
+ myTable += "<th class='dt-right'>Packets</th>";
+ myTable += "<th class='dt-right'>CC Errors</th>";
+ myTable += "<th class='dt-right'>Coax Cable</th>";
}
- myTable += "</td>";
-
- // POSITION
- if ((ad_sys[i] == 5 || ad_sys[i] == 6) && ad_enabled[i])
- myTable += "<td class='dt-right'>" + ad_pos[i] + "</td>";
- else
- myTable += "<td class='dt-right'></td>";
-
- // FREQUENCY
- if (ad_enabled[i])
- myTable += "<td class='dt-right'>" + ad_freq[i] + " "+pol[ad_pol[i]]+"</td>";
- else
- myTable += "<td class='dt-right'></td>";
-
- if (ad_enabled[i] && (ad_sys[i] == 0 || ad_sys[i] == 1 || ad_sys[i] == 2 || ad_sys[i] == 5 || ad_sys[i] == 6 || ad_sys[i] == 18 || ad_sys[i] == 19))
- myTable += "<td class='dt-right'>" + ad_sr[i] + "</td>";
- else if (ad_enabled[i])
- myTable += "<td class='dt-right'>" + ad_bw[i]/1000 + "MHZ</td>";
- else
- myTable += "<td class='dt-right'></td>";
-
- // SIGNAL
- var signal = "";
- if (ad_enabled[i] == 0) {
- signal = "<small>OFFLINE</small>";
- } else {
- var s1 = parseInt(ad_strength[i] / 2.55);
- signal = "<div class='level'>STR <div class='pBar' data-from='"+ s1 + "' data-to='" + s1 + "'></div> " + s1 + "%</div><br />";
-
- if (ad_type[i] == 1 || ad_type[i] == 3)
- var s2 = parseInt(ad_snr[i] / 2.55);
+ myTable += "<th class='dt-left'>Streams</th>";
+ myTable += "<th class='dt-left'>Cryptinfo</th>";
+ myTable += "</tr></thead><tbody>";
+
+ for (var i = 0; i < max_adapters; i++) {
+ if (state['ad_type'][i] == 0)
+ continue;
+
+ if (state['ad_enabled'][i] == 1)
+ myTable += "<tr valign='top'>";
else
- var s2 = parseInt(ad_snr[i] / 0.15);
- signal += "<div class='level'>SNR <div class='pBar' data-from='"+ s2 + "' data-to='" + s2 + "'></div> " + s2 + "%</div><br />";
+ myTable += "<tr style='opacity: 0.5;'>";
- if (ad_ber[i] > 0)
- signal += "<div class='level'>BER <div class='pBar' data-from='"+ ad_ber[i] + "' data-to='" + ad_ber[i] + "' data-color='red'></div> " + ad_ber[i] + "</div><br />";
- }
- myTable += "<td class='dt-right'>" + signal + " </td>";
+ // TUNER
+ myTable += "<td class='dt-right'>" + i + "</td>";
- if(has_axe)
- {
- myTable += "<td class='dt-right'>" + ad_axe_pktc[i] + " </td>";
- myTable += "<td class='dt-right'>" + ad_axe_ccerr[i] + " </td>";
- myTable += "<td class='dt-right'>" + ad_axe_coax[i] + " </td>"; }
-
- // STREAMS
- myTable += "<td class='dt-left'>";
- for (var j = 0; j < max_streams; j++) {
- if (st_enabled[j] == 1 && st_adapter[j] == i) {
- var st_rh = st_rhost[j]+":"+st_rport[j];
- if (ad_master[i] == j)
- st_rh = "<b>"+st_rh+"</b>";
- if (st_play[j] == 0)
- st_rh = "<i>"+st_rh+"</i>";
- myTable += st_rh + "<br />";
- if (st_useragent[j] != "")
- myTable += "<small>Client: " + st_useragent[j] + "</small><br />";
+ // STATUS
+ var csys = "";
+ if (state['ad_sys'][i] == 0)
+ csys = state['ad_allsys'][i];
+ else
+ csys = sys[state['ad_sys'][i]];
+
+ var tmpimg = csys.split(',');
+ var sysimg = csys;
+ if(tmpimg.length > 0)
+ sysimg = tmpimg[0];
+
+ var ad_enabled = state['ad_enabled'][i];
+ var ad_type = state['ad_type'][i];
+ var ad_sys = state['ad_sys'][i];
+
+ if (ad_enabled)
+ myTable += "<td class='dt-right enabled'><img src='" + sysimg + ".png' title='" + csys + "' /><br />";
+ else
+ myTable += "<td class='dt-right disabled'>" + state['ad_allsys'][i];
+
+ if (ad_type == 1 || ad_type == 3) {
+ // myTable += "<small>(" + state['ad_phyad'][i] + "," + state['ad_phyfd'][i] +")</small>";
+ } else {
+ myTable += "<small>(" + state['ad_satip'][i] + ")</small>";
}
- }
- for (var j = 0; j < max_streams; j++) {
- if (st_enabled[j] == 1 && st_adapter[j] == i) {
- var st_p = st_pids[j];
- if (ad_master[i] == j)
- st_p = "" + st_p + "";
- if (st_play[j] == 0)
- st_p = "<i>" + st_p + "</i>";
- myTable += "<small>Pids: " + st_p + "</small><br />";
+ myTable += "</td>";
+
+ // POSITION
+ if ((ad_sys == 5 || ad_sys == 6) && ad_enabled)
+ myTable += "<td class='dt-right'>" + state['ad_pos'][i] + "</td>";
+ else
+ myTable += "<td class='dt-right'></td>";
+
+ // FREQUENCY
+ if (ad_enabled)
+ myTable += "<td class='dt-right'>" +state['ad_freq'][i] + " "+pol[state['ad_pol'][i]]+"</td>";
+ else
+ myTable += "<td class='dt-right'></td>";
+
+ if (ad_enabled && (ad_sys == 0 || ad_sys == 1 || ad_sys == 2 || ad_sys == 5 || ad_sys == 6 || ad_sys == 18 || ad_sys == 19))
+ myTable += "<td class='dt-right'>" + state['ad_sr'][i] + "</td>";
+ else if (ad_enabled)
+ myTable += "<td class='dt-right'>" + state['ad_bw'][i]/1000 + "MHZ</td>";
+ else
+ myTable += "<td class='dt-right'></td>";
+
+ // SIGNAL
+ var signal = "";
+ if (!ad_enabled) {
+ signal = "<small>OFFLINE</small>";
+ } else {
+ var sig = parseInt(state['ad_strength'][i] / 2.55);
+ var sig0 = Math.max(0, sig - 10);
+ signal = "<div class='level'>STR <div class='pBar' data-from='"+ sig0 + "' data-to='" + sig + "'></div> " + sig + "%</div><br />";
+
+ if (ad_type == 1 || ad_type == 3)
+ var snr = parseInt(state['ad_snr'][i] / 2.55);
+ else
+ var snr = parseInt(state['ad_snr'][i] / 0.15);
+ var snr0 = Math.max(0, snr - 10);
+ signal += "<div class='level'>SNR <div class='pBar' data-from='"+ snr0 + "' data-to='" + snr + "'></div> " + snr + "%</div><br />";
+
+ var ber = state['ad_ber'][i];
+ if (ber > 0)
+ signal += "<div class='level'>BER <div class='pBar' data-from='"+ ber + "' data-to='" + ber + "' data-color='red'></div> " + ber + "</div><br />";
}
- }
- myTable +="</td>";
-
- // CRYPT
- myTable +="<td class=''><small>";
- for (var j = 0; j < max_keys; j++)
- if (key_enabled[j] == 1 && key_adapter[j] == i) {
- myTable += "SYSTEM: " + key_cardsystem[j] + "<br />";
- myTable += "PMT: " + key_pmt[j] + "<br />";
- myTable += "ECMTIME: " + key_ecmtime[j] + "<br />";
- myTable += "READER: " + key_reader[j] + "<br />";
- myTable += "IP: " + key_from[j] + " (" + key_protocol[j] + ")<br /><br />";
+ myTable += "<td class='dt-right'>" + signal + " </td>";
+
+ if(has_axe)
+ {
+ myTable += "<td class='dt-right'>" + state['ad_axe_pktc'][i] + " </td>";
+ myTable += "<td class='dt-right'>" + state['ad_axe_ccerr'][i] + " </td>";
+ myTable += "<td class='dt-right'>" + state['ad_axe_coax'][i] + " </td>"; }
+
+ // STREAMS
+ myTable += "<td class='dt-left'>";
+ for (var j = 0; j < max_streams; j++) {
+ if (state['st_enabled'][j] == 1 && state['st_adapter'][j] == i) {
+ var st_rh = state['st_rhost'][j]+":"+state['st_rport'][j];
+ if (state['ad_master'][i] == j)
+ st_rh = "<b>"+st_rh+"</b>";
+ if (state['st_play'][j] == 0)
+ st_rh = "<i>"+st_rh+"</i>";
+ myTable += st_rh + "<br />";
+ if (state['st_useragent'][j] != "")
+ myTable += "<small>Client: " + state['st_useragent'][j] + "</small><br />";
+ }
}
- myTable +="</small></td></tr>";
-}
-myTable+="</tbody></table>";
+ for (var j = 0; j < max_streams; j++) {
+ if (state['st_enabled'][j] == 1 && state['st_adapter'][j] == i) {
+ var st_p = state['st_pids'][j];
+ if (state['ad_master'][i] == j)
+ st_p = "" + st_p + "";
+ if (state['st_play'][j] == 0)
+ st_p = "<i>" + st_p + "</i>";
+ myTable += "<small>Pids: " + st_p + "</small><br />";
+ }
+ }
+ myTable +="</td>";
+
+ // CRYPT
+ myTable +="<td class=''><small>";
+ for (var j = 0; j < max_keys; j++)
+ if (state['key_enabled'][j] == 1 && state['key_adapter'][j] == i) {
+ myTable += "SYSTEM: " + state['key_cardsystem'][j] + "<br />";
+ myTable += "PMT: " + state['key_pmt'][j] + "<br />";
+ myTable += "ECMTIME: " + state['key_ecmtime'][j] + "<br />";
+ myTable += "READER: " + state['key_reader'][j] + "<br />";
+ myTable += "IP: " + state['key_from'][j] + " (" + state['key_protocol'][j] + ")<br /><br />";
+ }
+ myTable +="</small></td></tr>";
+ }
+ myTable += "</tbody></table>";
+ return myTable;
+}
var pcurrent = 1;
var pvalues = [5, 10, 15, 30, 60, 300 ];
var prefresh;
+var stats = 0;
+var statsrefresh;
+var table = null;
var hashTag = location.hash;
if (typeof hashTag.split('#')[1] !== "undefined") {
@@ -262,30 +273,27 @@ if (typeof hashTag.split('#')[1] !== "undefined") {
}
2017-05-03 17:04:12 +02:00
}
-function reloadPage() {
- $("#pintervall").val( pvalues[pcurrent] );
-
- clearInterval(prefresh);
-
- prefresh = setInterval(function () {
- var url = location.origin + location.pathname + "#" + pcurrent;
- location.href = url;
- location.reload(true); // force reload
- }, pvalues[pcurrent] * 1000);
+function updateStats() {
+ $.post("bandwidth.json", function(data, status) {
+ if (status !== "success") return;
+ $("#statsarea").html(getDebug(data));
+ }).fail(function() {
+ $("#statsarea").html("No data from server");
+ });
}
-$(document).ready(function() {
- console.log("minisatip status: " + Date());
-
- var el = document.createElement('div');
- el.innerHTML = myTable;
- document.body.appendChild(el);
-
- $('#myTable').DataTable({
+function renewTable(data) {
+ if (table)
+ table.destroy();
+ document.title = "Minisatip/" + data['version'] + " on " + data['http_host'];
+ $('#table').html(getTable(data));
+ table = $('#myTable').DataTable({
"paging": false,
"bFilter": false,
"ordering": true,
"info": false,
+ "stateSave": true,
+ "stateDuration": -1,
"columnDefs": [
{ "width": "40px", "targets": 0 },
{ "width": "40px", "targets": 1 },
@@ -300,8 +308,32 @@ $(document).ready(function() {
"emptyTable": "No tuner found/active"
}
});
-
$(".pBar").pBar();
+}
+
+function getData() {
+ $.post("state.json", function(data, status) {
+ if (status === "success") {
+ renewTable(data);
+ }
+ }).fail(function() {
+ if (table)
+ table.clear().draw();
+ });
+}
+
+function reloadPage() {
+ $("#pintervall").val( pvalues[pcurrent] );
+
+ clearInterval(prefresh);
+
+ prefresh = setInterval(getData, pvalues[pcurrent] * 1000);
+}
+
+$(document).ready(function() {
+ $("#table").html("Loading...");
+
+ document.title = "Minisatip on " + document.location.hostname;
$("#pdec").click(function() {
if (pcurrent > 0) {
@@ -329,6 +361,20 @@ $(document).ready(function() {
}
});
+ $("#stats").click(function() {
+ stats ^= 1;
+ $("#stats").html("Stats " + (stats ? "OFF" : "ON"));
+ if (stats) {
+ updateStats();
+ statsrefresh = setInterval(updateStats, 500);
+ } else {
+ clearInterval(statsrefresh);
+ $("#statsarea").html("");
+ }
+ });
+
+
+ getData();
reloadPage();
});
2017-04-25 13:06:33 +02:00
diff --git a/minisatip.c b/minisatip.c
index e6e2254..4cff2c7 100755
2017-04-25 13:06:33 +02:00
--- a/minisatip.c
+++ b/minisatip.c
2017-05-12 09:56:52 +02:00
@@ -73,6 +73,7 @@ static const struct option long_options[] =
{ "jess", required_argument, NULL, 'j' },
{ "diseqc", required_argument, NULL, 'd' },
{ "diseqc-timing", required_argument, NULL, 'q' },
+ { "diseqc-multi", required_argument, NULL, '0' },
{ "nopm", required_argument, NULL, 'Z' },
#ifndef DISABLE_DVBAPI
{ "dvbapi", required_argument, NULL, 'o' },
@@ -149,6 +150,7 @@ static const struct option long_options[] =
#define AXE_SKIP_PKT 'M'
#define AXE_POWER 'W'
#define ABSOLUTE_SRC 'A'
+#define DISEQC_MULTI '0'
char *built_info[] =
{
@@ -235,7 +237,7 @@ void usage()
#ifdef AXE
"[-7 M1:S1[,M2:S2]] [-M mpegts_packets] [-A SRC1:INP1:DISEQC1[,SRC2:INP2:DISEQC2]]\n\n"
#endif
- "\t[-x http_port] [-X xml_path] [-y rtsp_port] \n\n\
+ "\t[-x http_port] [-X xml_path] [-y rtsp_port]\n\n\
Help\n\
-------\n\
\n\
@@ -263,6 +265,10 @@ Help\n\
\t* All timing values are in ms, default adapter values are: 15-54-15-15-15-0\n\
- note: * as adapter means apply to all adapters\n\
\n\
+* -0 --diseqc-multi ADAPTER1:DISEQC_POSITION[,...]\n\
+\t* Send diseqc to selected position before other position is set.\n\
+ - note: * as adapter means apply to all adapters\n\
+\n\
* -D --device-id DVC_ID: specify the device id (in case there are multiple SAT>IP servers in the network)\n \
* eg: -D 4 \n\
\n\
@@ -464,6 +470,7 @@ void set_options(int argc, char *argv[])
opts.diseqc_after_burst = 15;
opts.diseqc_after_tone = 0;
opts.diseqc_committed_no = 1;
+ opts.diseqc_multi = -1;
opts.nopm = 0;
opts.lnb_low = (9750*1000UL);
opts.lnb_high = (10600*1000UL);
@@ -471,7 +478,9 @@ void set_options(int argc, char *argv[])
opts.lnb_switch = (11700*1000UL);
opts.max_sbuf = 100;
opts.max_pids = 0;
-#if defined(__sh__)
+#if defined(AXE)
+ opts.max_pids = 32;
+#elif defined(__sh__)
opts.max_pids = 20;
#endif
@@ -482,7 +491,7 @@ void set_options(int argc, char *argv[])
2017-04-25 13:06:33 +02:00
#ifdef AXE
opts.no_threads = 1;
opts.axe_skippkt = 35;
- opts.document_root = "/usr/share/minisatip/html";
+ opts.document_root = "/usr/share/minisatip7/html";
#define AXE_OPTS "7:QW:M:8:A:"
#else
#define AXE_OPTS ""
@@ -491,7 +500,7 @@ void set_options(int argc, char *argv[])
2017-05-12 09:56:52 +02:00
memset(opts.playlist, 0, sizeof(opts.playlist));
while ((opt = getopt_long(argc, argv,
- "flr:a:td:w:p:s:n:hB:b:H:m:p:e:x:u:j:o:gy:i:q:D:VR:S:TX:Y:OL:EP:Z:"AXE_OPTS,
+ "flr:a:td:w:p:s:n:hB:b:H:m:p:e:x:u:j:o:gy:i:q:D:VR:S:TX:Y:OL:EP:Z:0:"AXE_OPTS,
long_options, NULL)) != -1)
{
// printf("options %d %c %s\n",opt,opt,optarg);
@@ -651,6 +660,12 @@ void set_options(int argc, char *argv[])
2017-05-12 09:56:52 +02:00
break;
}
+ case DISEQC_MULTI:
+ {
+ set_diseqc_multi(optarg);
+ break;
+ }
+
case LNB_OPT:
{
set_lnb_adapters(optarg);
@@ -830,7 +845,6 @@ int read_rtsp(sockets * s)
2017-05-07 09:05:04 +02:00
int sess_id = 0;
int end = s->type == TYPE_HTTP;
char buf[2000];
- char tmp_ra[50];
streams *sid = get_sid(s->sid);
if (s->buf[0] == 0x24 && s->buf[1] < 2)
@@ -850,7 +864,7 @@ int read_rtsp(sockets * s)
2017-05-07 09:05:04 +02:00
}
}
- if (s->rlen < 4 || !end_of_header(s->buf + s->rlen - 4))
+ if (s->rlen < 4 || !end_of_header((char *)s->buf + s->rlen - 4))
{
if (s->rlen > RBUF - 10)
{
@@ -1024,7 +1038,7 @@ int read_rtsp(sockets * s)
2017-05-03 17:04:12 +02:00
arg[1], getTick(), (getTickUs() / 1000000));
}
if (buf[0] == 0 && sid->type == STREAM_HTTP)
- snprintf(buf, sizeof(buf), "Content-Type: video/mp2t");
+ snprintf(buf, sizeof(buf), "Content-Type: video/mp2t\r\nConnection: close");
http_response(s, 200, buf, NULL, cseq, 0, end);
}
else if (strncmp(arg[0], "TEARDOWN", 8) == 0)
@@ -1066,6 +1080,8 @@ int read_rtsp(sockets * s)
2017-05-03 17:04:12 +02:00
#define REPLY_AND_RETURN(c) {http_response (s, c, NULL, NULL, 0, 0, 1); return 0;}
+#define JSON_STATE_MAXLEN (128*1024)
+
char uuid[100];
int uuidi;
struct sockaddr_in ssdp_sa;
@@ -1096,7 +1112,7 @@ int read_http(sockets * s)
2017-05-07 09:05:04 +02:00
"<satip:X_SATIPCAP xmlns:satip=\"urn:ses-com:satip\">%s</satip:X_SATIPCAP>"
"%s"
"</device></root>";
- if (s->rlen < 5 || !end_of_header(s->buf + s->rlen - 4))
+ if (s->rlen < 5 || !end_of_header((char *)s->buf + s->rlen - 4))
{
if (s->rlen > RBUF - 10)
{
@@ -1114,7 +1130,7 @@ int read_http(sockets * s)
2017-05-07 09:05:04 +02:00
return 0;
}
url[0] = 0;
- space = strchr(s->buf, ' ');
+ space = strchr((char *)s->buf, ' ');
if(space)
{
int i = 0;
@@ -1134,6 +1150,8 @@ int read_http(sockets * s)
2017-05-03 17:04:12 +02:00
return 0;
}
+ sockets_timeout(s->id, 1); //close the connection
+
if(!strncasecmp((const char*) s->buf, "HEAD ", 5))
is_head = 1;
@@ -1149,13 +1167,11 @@ int read_http(sockets * s)
2017-05-03 17:04:12 +02:00
split(arg, (char*) s->buf, 50, ' ');
// LOG("args: %s -> %s -> %s",arg[0],arg[1],arg[2]);
- if (strncmp(arg[0], "GET", 3) && !is_head)
+ if (strncmp(arg[0], "GET", 3) && strncmp(arg[0], "POST", 4))
REPLY_AND_RETURN(503);
if (uuidi == 0)
ssdp_discovery(s);
- sockets_timeout(s->id, 1); //close the connection
-
if (strcmp(arg[1], "/"DESC_XML) == 0)
{
extern int tuner_s2, tuner_t, tuner_c, tuner_t2, tuner_c2;
@@ -1179,11 +1195,29 @@ int read_http(sockets * s)
2017-05-03 17:04:12 +02:00
snprintf(buf, sizeof(buf), xml, app_name, app_name, app_name, uuid,
opts.http_host, adapters, opts.playlist);
sprintf(headers,
- "CACHE-CONTROL: no-cache\r\nContent-type: text/xml\r\nX-SATIP-RTSP-Port: %d",
+ "Cache-Control: no-cache\r\nContent-type: text/xml\r\nX-SATIP-RTSP-Port: %d\r\nConnection: close",
opts.rtsp_port);
http_response(s, 200, headers, buf, 0, 0, 1);
return 0;
}
+
+ if (strcmp(arg[1], "/state.json") == 0)
+ {
+ char *buf = malloc(JSON_STATE_MAXLEN);
+ int len = get_json_state(buf, JSON_STATE_MAXLEN);
+ http_response(s, 200, "Content-Type: application/json\r\nConnection: close", buf, 0, len, 1);
+ free(buf);
+ return 0;
+ }
+
+ if (strcmp(arg[1], "/bandwidth.json") == 0)
+ {
+ char buf[1024];
+ int len = get_json_bandwidth(buf, sizeof(buf));
+ http_response(s, 200, "Content-Type: application/json\r\nConnection: close", buf, 0, len, 1);
+ return 0;
+ }
+
// process file from html directory, the images are just sent back
if (!strcmp(arg[1], "/"))
@@ -1206,8 +1240,7 @@ int read_http(sockets * s)
2017-05-03 17:04:12 +02:00
http_response(s, 200, ctype, NULL, 0, 0, 1);
return 0;
}
- if (strstr(ctype, "image") || strstr(ctype, "css")
- || strstr(ctype, "javascript") || strstr(ctype, "octet-stream"))
+ if (strstr(ctype, "no-cache") == NULL)
{
http_response(s, 200, ctype, f, 0, nl, 1);
closefile(f, nl);
@@ -1433,7 +1466,7 @@ pthread_t main_tid;
2017-05-07 09:05:04 +02:00
extern int sock_signal;
int main(int argc, char *argv[])
{
- int sock_st, sock_bw, rv;
+ int sock_bw, rv;
main_tid = get_tid();
thread_name = "main";
set_options(argc, argv);
2017-04-25 13:06:33 +02:00
diff --git a/minisatip.h b/minisatip.h
index a242532..9f1fbad 100644
2017-04-25 13:06:33 +02:00
--- a/minisatip.h
+++ b/minisatip.h
@@ -10,7 +10,7 @@
2017-05-12 09:56:52 +02:00
#define VERSION_BUILD "4"
2017-04-25 13:06:33 +02:00
#define CC(a,b,c) #a b #c
-#define VERSION CC(0.7.,VERSION_BUILD,)
+#define VERSION CC(0.7.,VERSION_BUILD,-axe205)
2017-04-25 13:06:33 +02:00
void set_options (int argc, char *argv[]);
2017-05-12 09:56:52 +02:00
@@ -77,6 +77,7 @@ struct struct_opts
int diseqc_after_switch;
int diseqc_after_burst;
int diseqc_after_tone;
+ int diseqc_multi;
int lnb_low, lnb_high, lnb_switch, lnb_circular;
int nopm;
int max_pids;
2017-05-07 09:05:04 +02:00
diff --git a/satipc.c b/satipc.c
index f08deb6..df3b191 100755
2017-05-07 09:05:04 +02:00
--- a/satipc.c
+++ b/satipc.c
@@ -130,7 +130,7 @@ int satipc_reply(sockets * s)
LOG("satipc_reply (sock %d) handle %d, adapter %d:\n%s", s->id, s->sock,
s->sid, s->buf);
- if ((timeout = strstr(s->buf, "timeout=")))
+ if ((timeout = strstr((char *)s->buf, "timeout=")))
{
int tmout;
timeout += strlen("timeout=");
@@ -138,21 +138,21 @@ int satipc_reply(sockets * s)
sockets_timeout(ad->fe_sock, tmout * 500); // 2 times 30s
}
- sess = strstr(s->buf, "Session:");
+ sess = strstr((char *)s->buf, "Session:");
if (sip->last_cmd == RTSP_DESCRIBE)
{
- set_adapter_signal(ad, s->buf, rlen);
+ set_adapter_signal(ad, (char *)s->buf, rlen);
}
- sep = strstr(s->buf, "minisatip");
+ sep = strstr((char *)s->buf, "minisatip");
if(sep)
{
sip->option_no_session = 1;
sip->option_no_setup = 1;
sip->option_no_option = 1;
}
- sep = strstr(s->buf, "enigma_minisatip");
+ sep = strstr((char *)s->buf, "enigma_minisatip");
if(sep && !ad->restart_when_tune)
{
LOGL(3, "Setting adapter %d to restart every time the transponder is changed", ad->id);
@@ -288,7 +288,7 @@ int satipc_close(sockets * s)
void set_adapter_signal(adapter *ad, char *b, int rlen)
{
int i, strength, status, snr;
- char *ver, *tun, *signal;
+ char *ver, *tun, *signal = NULL;
for (i = 0; i < rlen - 4; i++)
if (b[i] == 'v' && b[i + 1] == 'e' && b[i + 2] == 'r'
&& b[i + 3] == '=')
@@ -314,13 +314,11 @@ void set_adapter_signal(adapter *ad, char *b, int rlen)
int satipc_rtcp_reply(sockets * s)
{
- unsigned char *b = s->buf, *ver, *signal;
- char *tun;
- int i, rlen = s->rlen;
+ unsigned char *b = s->buf;
+ int rlen = s->rlen;
adapter *ad;
satipc *sip;
get_ad_and_sipr(s->sid, 0);
- int strength, status, snr;
uint32_t rp;
s->rlen = 0;
@@ -335,7 +333,7 @@ int satipc_rtcp_reply(sockets * s)
ad->id, rp - sip->rcvp, sip->rtp_miss, sip->rtp_ooo,
ad->pid_err - ad->dec_err);
}
- set_adapter_signal(ad, b, rlen);
+ set_adapter_signal(ad, (char *)b, rlen);
return 0;
}
@@ -488,7 +486,7 @@ int process_rtsp_tcp(sockets *ss, unsigned char *rtsp, int rtsp_len, void *buf,
{
tmp_char = rtsp[rtsp_len + 4];
rtsp[rtsp_len + 4] = 0;
- set_adapter_signal(ad, rtsp + 4, rtsp_len);
+ set_adapter_signal(ad, (char *)rtsp + 4, rtsp_len);
rtsp[rtsp_len + 4] = tmp_char;
return 0;
}
@@ -513,8 +511,6 @@ int satipc_tcp_read(int socket, void *buf, int len, sockets *ss, int *rb)
{
unsigned char *rtsp;
sockets tmp_sock;
- uint16_t seq;
- static int iter;
int pos;
int rtsp_len;
int tmp_len = 0;
@@ -621,7 +617,7 @@ int satipc_tcp_read(int socket, void *buf, int len, sockets *ss, int *rb)
2017-05-07 09:05:04 +02:00
*rb = pos;
}
- else if (!strncmp(rtsp, "RTSP", 4))
+ else if (!strncmp((char *)rtsp, "RTSP", 4))
{
unsigned char *nlnl, *cl;
int bytes, icl = 0;
@@ -631,7 +627,7 @@ int satipc_tcp_read(int socket, void *buf, int len, sockets *ss, int *rb)
2017-05-07 09:05:04 +02:00
LOG("%s: skipped %d bytes", __FUNCTION__, skipped_bytes);
skipped_bytes = 0;
}
- nlnl = strstr(rtsp, "\r\n\r\n");
+ nlnl = (unsigned char *)strstr((char *)rtsp, "\r\n\r\n");
// LOG("found RTSP nlnl %d, len %d", nlnl - rtsp, sip->tcp_len);
if(nlnl > sip->tcp_data + sip->tcp_len)
{
@@ -639,13 +635,13 @@ int satipc_tcp_read(int socket, void *buf, int len, sockets *ss, int *rb)
2017-05-07 09:05:04 +02:00
nlnl = NULL;
sip->tcp_data[sip->tcp_size + 1] = 0;
}
- if (nlnl && (cl = strcasestr(rtsp, "content-length:")))
+ if (nlnl && (cl = (unsigned char *)strcasestr((char *)rtsp, "content-length:")))
{
cl += 15;
while (*cl == 0x20)
cl++;
- icl = map_intd(cl, NULL, 0);
+ icl = map_intd((char *)cl, NULL, 0);
nlnl += icl;
}
if (!nlnl)
@@ -822,7 +818,6 @@ int http_request(adapter *ad, char *url, char *method)
2017-05-07 09:05:04 +02:00
session[0] = 0;
sid[0] = 0;
- int64_t ctime = getTick();
remote_socket = sip->use_tcp ? ad->dvr : ad->fe;
if (!sip->option_no_setup && !method && sip->sent_transport == 0)
@@ -1042,7 +1037,6 @@ void satipc_commit(adapter *ad)
2017-05-07 09:05:04 +02:00
if (send_apids)
{
- int pids[MAX_PIDS];
int i;
if (len > 0)
len += sprintf(url + len, "&");
diff --git a/socketworks.c b/socketworks.c
index 6891c27..139fc60 100755
--- a/socketworks.c
+++ b/socketworks.c
@@ -324,7 +324,7 @@ int tcp_listen(char *addr, int port)
int connect_local_socket(char *file, int blocking)
{
struct sockaddr_un serv;
- int sock, optval = 1;
+ int sock;
sock = socket(AF_LOCAL, SOCK_STREAM, 0);
@@ -593,7 +593,6 @@ __thread char *thread_name;
void *select_and_execute(void *arg)
{
- fd_set io;
int i, rv, rlen, les, es;
unsigned char buf[2001];
int err;
@@ -870,7 +869,6 @@ int get_mac(char *mac)
struct ifreq ifr;
struct ifconf ifc;
char buf[1024];
- int success = 0;
if (opts.mac[0])
{
@@ -900,10 +898,7 @@ int get_mac(char *mac)
if (!(ifr.ifr_flags & IFF_LOOPBACK))
{ // don't count loopback
if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0)
- {
- success = 1;
break;
- }
}
}
else
diff --git a/stream.c b/stream.c
index 345ad4c..70f3f58 100755
--- a/stream.c
+++ b/stream.c
2017-05-03 17:04:12 +02:00
@@ -47,7 +47,7 @@
2017-05-03 17:04:12 +02:00
extern struct struct_opts opts;
streams *st[MAX_STREAMS];
-SMutex st_mutex;
+SMutex st_mutex, bw_mutex;
extern int tuner_s2, tuner_t, tuner_c, tuner_t2, tuner_c2;
2017-05-03 17:04:12 +02:00
char *describe_streams(sockets *s, char *req, char *sbuf, int size)
2017-05-07 09:05:04 +02:00
@@ -295,6 +295,7 @@ int close_stream_for_socket(sockets *s)
LOG("%s: start close_stream_for_socket for id %d %p", __FUNCTION__, s->sid, sid);
if(sid)
sid->timeout = 1;
+ return 0;
}
int close_stream(int i)
@@ -545,6 +546,10 @@ int64_t tbw, bw, bwtt;
2017-05-03 17:04:12 +02:00
uint32_t reads, writes, failed_writes;
int64_t nsecs;
2017-05-03 17:04:12 +02:00
+int64_t c_tbw, c_bw;
+uint32_t c_reads, c_writes, c_failed_writes;
+int64_t c_ns_read, c_tt;
+
uint64_t last_sd;
2017-05-03 17:04:12 +02:00
int send_rtp(streams * sid, const struct iovec *iov, int liov)
2017-05-07 09:05:04 +02:00
@@ -618,7 +623,6 @@ int send_rtcp(int s_id, int64_t ctime)
char dad[1000];
char ra[50];
unsigned char rtcp_buf[1600];
- int c_time = (int) (ctime / 1000) & 0xFFFFFFFF;
unsigned char *rtcp = rtcp_buf + 4;
streams *sid = get_sid(s_id);
@@ -891,10 +895,9 @@ int process_dmx(sockets * s)
{
void *min, *max;
int i, j, dp;
- static int cnt;
streams *sid;
adapter *ad;
- int send = 0, flush_all = 0;
+ int flush_all = 0;
int64_t stime;
ad = get_adapter(s->sid);
@@ -990,7 +993,6 @@ int read_dmx(sockets * s)
adapter *ad;
int send = 0, flush_all = 0, ls, lse, i;
int threshold = opts.udp_threshold;
- uint64_t stime;
uint64_t rtime = getTick();
if (s->rlen % DVB_FRAME != 0)
@@ -1080,10 +1082,21 @@ int calculate_bw(sockets *s)
2017-05-03 17:04:12 +02:00
tbw += bw;
if (!reads)
reads = 1;
- if (bw > 2000)
+ if (bw > 2000) {
+ mutex_init(&bw_mutex);
+ mutex_lock(&bw_mutex);
+ c_bw = bw / 1024;
+ c_tbw = tbw / 1024576;
+ c_ns_read = nsecs / reads;
+ c_reads = reads;
+ c_writes = writes;
+ c_failed_writes = failed_writes;
+ c_tt = nsecs / 1000;
LOG(
"BW %jdKB/s, Total BW: %jd MB, ns/read %jd, r: %d, w: %d fw: %d, tt: %jd ms",
- bw / 1024, tbw / 1024576, nsecs / reads, reads, writes, failed_writes, nsecs / 1000);
+ c_bw, c_tbw, c_ns_read, c_reads, c_writes, c_failed_writes, c_tt);
+ mutex_unlock(&bw_mutex);
+ }
bw = 0;
failed_writes = 0;
nsecs = 0;
@@ -1305,8 +1318,7 @@ int get_stream_rport(int s_id)
2017-05-07 09:05:04 +02:00
char* get_stream_pids(int s_id, char *dest, int max_size)
{
int len = 0;
- int pids[MAX_PIDS];
- int lp, i, j;
+ int i, j;
streams *s = get_sid_nw(s_id);
adapter *ad;
dest[0] = 0;
@@ -1350,10 +1362,10 @@ _symbols stream_sym[] =
2017-05-03 17:04:12 +02:00
{ "st_useragent", VAR_AARRAY_STRING, st, 1, MAX_STREAMS, offsetof(
streams, useragent) },
{ "st_rhost", VAR_FUNCTION_STRING, (void *) &get_stream_rhost,
- 0, 0, 0 },
+ 0, MAX_STREAMS, 0 },
{ "st_rport", VAR_FUNCTION_INT, (void *) &get_stream_rport, 0,
- 0, 0 },
+ MAX_STREAMS, 0 },
{ "st_pids", VAR_FUNCTION_STRING, (void *) &get_stream_pids, 0,
- 0, 0 },
+ MAX_STREAMS, 0 },
{ NULL, 0, NULL, 0, 0 }
};
diff --git a/stream.h b/stream.h
2017-05-03 17:04:12 +02:00
index 05e9f09..15414e2 100644
--- a/stream.h
+++ b/stream.h
2017-05-03 17:04:12 +02:00
@@ -87,4 +87,9 @@ int unlock_streams_for_adapter(int aid);
#define get_sid(a) get_sid1(a, __FILE__, __LINE__)
#define get_sid_for(i) ((st[i] && st[i]->enabled)?st[i]:NULL)
#define get_sid_nw(i) ((i>=0 && i<MAX_STREAMS && st[i] && st[i]->enabled)?st[i]:NULL)
+
+extern int64_t c_tbw, c_bw;
+extern uint32_t c_reads, c_writes, c_failed_writes;
+extern int64_t c_ns_read, c_tt;
+
#endif
diff --git a/utils.c b/utils.c
index b7cb28a..57b6bcb 100755
--- a/utils.c
+++ b/utils.c
2017-05-07 09:05:04 +02:00
@@ -199,12 +199,10 @@ int setItemTimeout(int64_t key, int tmout)
int setItem(int64_t key, unsigned char *data, int len, int pos) // pos = -1 -> append, owerwrite the existing key
{
- int new_key = 0;
STmpinfo *s = getItemPos(key);
if (!s)
{
s = getFreeItemPos(key);
- new_key = 1;
}
if (!s)
LOG_AND_RETURN(-1, "%s failed for key %jx", __FUNCTION__, key);
@@ -449,7 +447,6 @@ void print_trace(void)
{
void *array[10];
size_t size;
- char **strings;
size_t i;
#if !defined(NO_BACKTRACE)
@@ -757,16 +754,135 @@ int snprintf_pointer(char *dest, int max_len, int type, void *p,
case VAR_HEX:
2017-05-03 17:04:12 +02:00
nb = snprintf(dest, max_len, "0x%x", (int) ((*(int *) p) * multiplier));
break;
2017-05-07 09:05:04 +02:00
+
+ default:
+ nb = 0;
+ break;
2017-05-03 17:04:12 +02:00
}
+ if (nb > max_len) /* see man 'snprintf' */
+ nb = max_len;
return nb;
}
2017-05-03 17:04:12 +02:00
-char zero[16];
+char zero[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+int get_json_state(char *buf, int len)
+{
+ int ptr = 0, first = 1, i, j, off, string;
+ _symbols *p;
+
+ strlcatf(buf, len, ptr, "{\n");
+ for (i = 0; sym[i] != NULL; i++) {
+ for (j = 0; sym[i][j].name; j++) {
+ p = sym[i] + j;
+ strlcatf(buf, len, ptr, first ? "\"%s\":" : ",\n\"%s\":", p->name);
+ string = 0;
+ switch (p->type) {
+ case VAR_STRING:
+ case VAR_PSTRING:
+ case VAR_HEX:
+ case VAR_AARRAY_STRING:
+ case VAR_AARRAY_PSTRING: string = 1; break;
+ }
+ if (p->type < VAR_ARRAY)
+ {
+ if (string) strlcatf(buf, len, ptr, "\"");
+ ptr += snprintf_pointer(buf + ptr, len - ptr, p->type, p->addr, p->multiplier);
+ if (string) strlcatf(buf, len, ptr, "\"");
+ }
+ else if ((p->type & 0xF0) == VAR_ARRAY)
+ {
+ strlcatf(buf, len, ptr, "[");
+ for (off = 0; off < p->len; off++) {
+ if (string) strlcatf(buf, len, ptr, off > 0 ? ",\"" : "\"");
+ ptr += snprintf_pointer(buf + ptr, len - ptr, p->type,
+ ((char *)p->addr) + off + p->skip, p->multiplier);
+ if (string) strlcatf(buf, len, ptr, "\"");
+ }
+ strlcatf(buf, len, ptr, "]");
+ }
+ else if ((sym[i][j].type & 0xF0) == VAR_AARRAY)
+ {
+ strlcatf(buf, len, ptr, "[");
+ for (off = 0; off < p->len; off++) {
+ char **p1 = (char **) p->addr;
+ if (string)
+ strlcatf(buf, len, ptr, off > 0 ? ",\"" : "\"");
+ else if (off > 0)
+ strlcatf(buf, len, ptr, ",");
+ ptr += snprintf_pointer(buf + ptr, len - ptr, p->type,
+ p1[off] ? p1[off] + p->skip : zero, p->multiplier);
+ if (string) strlcatf(buf, len, ptr, "\"");
+ }
+ strlcatf(buf, len, ptr, "]");
+ }
+ else if (sym[i][j].type == VAR_FUNCTION_INT)
+ {
+ get_data_int funi = (get_data_int) p->addr;
+ strlcatf(buf, len, ptr, "[");
+ for (off = 0; off < p->len; off++) {
+ int storage = funi(off);
+ if (off > 0) strlcatf(buf, len, ptr, ",");
+ ptr += snprintf_pointer(buf + ptr, len - ptr, p->type, &storage, 1);
+ }
+ strlcatf(buf, len, ptr, "]");
+ }
+ else if (sym[i][j].type == VAR_FUNCTION_INT64)
+ {
+ get_data_int64 fun64 = (get_data_int64) p->addr;
+ strlcatf(buf, len, ptr, "[");
+ for (off = 0; off < p->len; off++) {
+ int64_t storage = fun64(off);
+ if (off > 0) strlcatf(buf, len, ptr, ",");
+ ptr += snprintf_pointer(buf + ptr, len - ptr, p->type, &storage, 1);
+ }
+ strlcatf(buf, len, ptr, "]");
+ }
+ else if (sym[i][j].type == VAR_FUNCTION_STRING)
+ {
+ char storage[64 * 5]; // variable max len
+ get_data_string funs = (get_data_string) p->addr;
+ strlcatf(buf, len, ptr, "[");
+ for (off = 0; off < p->len; off++) {
+ funs(off, storage, sizeof(storage));
+ strlcatf(buf, len, ptr, off > 0 ? ",\"%s\"" : "\"%s\"", storage);
+ }
+ strlcatf(buf, len, ptr, "]");
+ } else {
+ strlcatf(buf, len, ptr, "\"\"");
+ }
+ first = 0;
+ }
+ }
+ strlcatf(buf, len, ptr, "\n}\n");
+ return ptr;
+}
+
+extern SMutex bw_mutex;
+
+int get_json_bandwidth(char *buf, int len)
+{
+ int ptr = 0;
+ mutex_init(&bw_mutex);
+ mutex_lock(&bw_mutex);
+ strlcatf(buf, len, ptr, "\
+{\n\
+\"bw\":%jd,\n\
+\"tbw\":%jd,\n\
+\"reads\":%u,\n\
+\"writes\":%u,\n\
+\"fwrites\":%u,\n\
+\"ns_read\":%jd,\n\
+\"tt\":%jd\n\
+}", c_bw, c_tbw, c_reads, c_writes, c_failed_writes, c_ns_read, c_tt);
+ mutex_unlock(&bw_mutex);
+ return ptr;
+}
void * get_var_address(char *var, float *multiplier, int * type, void *storage,
int ls)
2017-05-07 09:05:04 +02:00
{
- int nb = 0, i, j, off;
+ int i, j, off;
*multiplier = 0;
for (i = 0; sym[i] != NULL; i++)
for (j = 0; sym[i][j].name; j++)
@@ -797,7 +913,6 @@ void * get_var_address(char *var, float *multiplier, int * type, void *storage,
2017-05-03 17:04:12 +02:00
if (!p)
{
- memset(zero, 0, sizeof(zero));
p = zero;
}
else
2017-05-07 09:05:04 +02:00
@@ -917,7 +1032,7 @@ char *readfile(char *fn, char *ctype, int *len)
char ffn[256];
char *mem;
struct stat sb;
- int fd, i, nl = 0, sr;
+ int fd, nl = 0;
*len = 0;
ctype[0] = 0;
@@ -949,20 +1064,23 @@ char *readfile(char *fn, char *ctype, int *len)
2017-05-03 17:04:12 +02:00
if (ctype)
{
2017-05-03 17:04:12 +02:00
if (endswith(fn, "png"))
- strcpy(ctype, "Content-type: image/png\r\nConnection: close");
+ strcpy(ctype, "Cache-Control: max-age=3600\r\nContent-type: image/png\r\nConnection: close");
else if (endswith(fn, "jpg") || endswith(fn, "jpeg"))
- strcpy(ctype, "Content-type: image/jpeg\r\nConnection: close");
+ strcpy(ctype, "Cache-Control: max-age=3600\r\nContent-type: image/jpeg\r\nConnection: close");
else if (endswith(fn, "css"))
- strcpy(ctype, "Content-type: text/css\r\nConnection: close");
+ strcpy(ctype, "Cache-Control: max-age=3600\r\nContent-type: text/css\r\nConnection: close");
else if (endswith(fn, "js"))
- strcpy(ctype, "Content-type: text/javascript\r\nConnection: close");
+ strcpy(ctype, "Cache-Control: max-age=3600\r\nContent-type: text/javascript\r\nConnection: close");
else if (endswith(fn, "htm") || endswith(fn, "html"))
- strcpy(ctype, "CACHE-CONTROL: no-cache\r\nContent-type: text/html");
+ strcpy(ctype, "Cache-Control: max-age=3600\r\nContent-type: text/html\r\nConnection: close");
else if (endswith(fn, "xml"))
- strcpy(ctype, "CACHE-CONTROL: no-cache\r\nContent-type: text/xml");
+ strcpy(ctype, "Cache-Control: no-cache\r\nContent-type: text/xml");
+ else if (endswith(fn, "json"))
+ strcpy(ctype, "Cache-Control: no-cache\r\nContent-type: application/json");
else if (endswith(fn, "m3u"))
- strcpy(ctype, "CACHE-CONTROL: no-cache\r\nContent-type: video/x-mpegurl");
- else strcpy(ctype, "CACHE-CONTROL: no-cache\r\nContent-type: application/octet-stream");
+ strcpy(ctype, "Cache-Control: no-cache\r\nContent-type: video/x-mpegurl");
+ else
+ strcpy(ctype, "Cache-Control: no-cache\r\nContent-type: application/octet-stream");
}
return mem;
}
2017-05-07 09:05:04 +02:00
@@ -1071,7 +1189,7 @@ int mutex_unlock1(char *FILE, int line, SMutex* mutex)
if (rv == 0 || rv == 1)
rv = 0;
- if (rv != -1 && imtx > 0)
+ if (rv != -1 && imtx > 0) {
if ((imtx >= 1) && mutexes[imtx - 1] == mutex)
imtx--;
else if ((imtx >= 2) && mutexes[imtx - 2] == mutex)
@@ -1081,7 +1199,7 @@ int mutex_unlock1(char *FILE, int line, SMutex* mutex)
}
else
LOG("mutex_leak: Expected %p got %p", mutex, mutexes[imtx - 1]);
-
+ }
return rv;
}
2017-05-03 17:04:12 +02:00
diff --git a/utils.h b/utils.h
index 109eff9..4619511 100755
--- a/utils.h
+++ b/utils.h
@@ -92,6 +92,8 @@ void set_signal_handler(char *argv0);
int becomeDaemon();
int end_of_header(char *buf);
char *readfile(char *fn, char *ctype, int *len);
+int get_json_state(char *buf, int len);
+int get_json_bandwidth(char *buf, int len);
void process_file(void *sock, char *s, int len, char *ctype);
int closefile(char *mem, int len);
@@ -126,4 +128,8 @@ void hexdump(char *log_message,void *addr, int len);
#define malloc1(a) mymalloc(a,__FILE__,__LINE__)
#define free1(a) myfree(a,__FILE__,__LINE__)
2017-05-03 17:04:12 +02:00
+#define strlcatf(buf, size, ptr, fmt...) \
+ do { int __r = snprintf((buf) + ptr, (size) - ptr, fmt); \
+ ptr = __r >= (size) - ptr ? (size) - 1 : ptr + __r; } while (0)
+
#endif