Internal szap-s2, femon-s2 utils.

This commit is contained in:
CrazyCat
2020-10-12 23:02:17 +03:00
parent e3a28fb5e2
commit 9dbd0bb545
9 changed files with 2664 additions and 0 deletions

26
femon-s2/Makefile Normal file
View File

@@ -0,0 +1,26 @@
CC=gcc
SRC=femon-s2.c
OBJ=femon-s2.o
BIND=/usr/local/bin/
INCLUDE=-I ../linux/include/uapi
TARGET=femon-s2
all: $(TARGET) $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLG) $(OBJ) -o $(TARGET) $(CLIB)
install: all
cp $(TARGET) $(BIND)
uninstall:
rm $(BIND)$(TARGET)
clean:
rm -f $(OBJ) $(TARGET) *~
%.o: %.c
$(CC) $(INCLUDE) -c $< -o $@

34
femon-s2/README Normal file
View File

@@ -0,0 +1,34 @@
femon -- simple frontend monitoring tool for the Linux DVB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
femon requires Linux DVB driver API version >= 5.0.
If compiler not found DVB headers in ../s2/linux/include/linux/dvb,
then it looks at usual location /usr/include/linux/dvb.
Install as follows:
(Option) make
make install
Uninstall
make uninstall
usage: femon [options]
-H : human readable output
-a number : use given adapter (default 0)
-f number : use given frontend (default 0)
-c number : samples to take (default 0 = infinite)
Igor M. Liplianin (liplianin@me.by)

164
femon-s2/femon-s2.c Normal file
View File

@@ -0,0 +1,164 @@
/* femon-s2 -- monitor frontend status
*
* Copyright (C) 2003 convergence GmbH
* Johannes Stezenbach <js@convergence.de>
*
* Copyright (C) 2009 Igor M. Liplianin <liplianin@me.by>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* femon 2011/06/16
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/time.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/version.h>
#if DVB_API_VERSION < 5
#error femon-s2 requires Linux DVB driver API version >= 5.0!
#endif
#define FRONTENDDEVICE "/dev/dvb/adapter%d/frontend%d"
static char *usage_str =
"\nusage: femon-s2 [options]\n"
" -H : human readable output\n"
" -a number : use given adapter (default 0)\n"
" -f number : use given frontend (default 0)\n"
" -c number : samples to take (default 0 = infinite)\n\n";
static void usage(void)
{
fprintf(stderr, usage_str);
exit(1);
}
static
int check_frontend (int fe_fd, int human_readable, unsigned int count)
{
fe_status_t status;
uint16_t snr = 10, signal = 10;
uint32_t ber = 1, uncorrected_blocks =1;
int16_t temp = 0;
int timeout = 0;
unsigned int samples = 0;
do {
if (ioctl(fe_fd, FE_READ_STATUS, &status) == -1)
perror("FE_READ_STATUS failed");
/* some frontends might not support all these ioctls, thus we
* avoid printing errors
*/
if (ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &signal) == -1)
signal = -2;
if (ioctl(fe_fd, FE_READ_SNR, &snr) == -1)
snr = -2;
if (ioctl(fe_fd, FE_READ_BER, &ber) == -1)
ber = -2;
if (ioctl(fe_fd, FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks) == -1)
uncorrected_blocks = -2;
if (ioctl(fe_fd, FE_READ_TEMP, &temp) == -1)
ber = -2;
if (human_readable) {
printf ("status %02x | signal %3u%% | snr %3u%% | ber %d | unc %d | temp %d | ",
status, (signal * 100) / 0xffff, (snr * 100) / 0xffff, ber, uncorrected_blocks, temp);
} else {
printf ("status %02x | signal %04x | snr %04x | ber %08x | unc %08x | temp %d | ",
status, signal, snr, ber, uncorrected_blocks, temp);
}
if (status & FE_HAS_LOCK)
printf("FE_HAS_LOCK");
printf("\n");
usleep(1000000);
samples++;
} while ((!count) || (count-samples));
return 0;
}
static
int do_mon(unsigned int adapter, unsigned int frontend, int human_readable, unsigned int count)
{
int result;
static int fefd;
char fedev[128];
if (!fefd) {
snprintf(fedev, sizeof(fedev), FRONTENDDEVICE, adapter, frontend);
if ((fefd = open(fedev, O_RDONLY | O_NONBLOCK)) < 0) {
perror("opening frontend failed");
return 0;
}
}
/* TODO here we may put frontend description */
result = check_frontend (fefd, human_readable, count);
close(fefd);
return result;
}
int main(int argc, char *argv[])
{
unsigned int adapter = 0, frontend = 0, count = 0;
int human_readable = 0;
int opt;
while ((opt = getopt(argc, argv, "Ha:f:c:")) != -1) {
switch (opt)
{
default:
usage();
break;
case 'a':
adapter = strtoul(optarg, NULL, 0);
break;
case 'c':
count = strtoul(optarg, NULL, 0);
break;
case 'f':
frontend = strtoul(optarg, NULL, 0);
break;
case 'H':
human_readable = 1;
break;
}
}
do_mon(adapter, frontend, human_readable, count);
return 0;
}

37
szap-s2/Makefile Normal file
View File

@@ -0,0 +1,37 @@
CC=gcc
SRC=lnb.c szap-s2.c tzap-t2.c
HED=lnb.h
OBJ1=lnb.o szap-s2.o
OBJ2=tzap-t2.o lnb.o
BIND=/usr/local/bin/
INCLUDE=-I ../linux/include/uapi
TARGET1=szap-s2
TARGET2=tzap-t2
all: $(TARGET1) $(TARGET2)
$(TARGET1): $(OBJ1)
$(CC) $(CFLG) $(OBJ1) -o $(TARGET1) $(CLIB)
$(TARGET2): $(OBJ2)
$(CC) $(CFLG) $(OBJ2) -o $(TARGET2) $(CLIB)
$(OBJ): $(HED)
install: all
cp $(TARGET1) $(BIND)
cp $(TARGET2) $(BIND)
uninstall:
rm $(BIND)$(TARGET1)
rm $(BIND)$(TARGET2)
clean:
rm -f $(OBJ1) $(TARGET1) *~
rm -f $(OBJ2) $(TARGET2) *~
%.o: %.c
$(CC) $(INCLUDE) -c $< -o $@

62
szap-s2/README Normal file
View File

@@ -0,0 +1,62 @@
szap-s2 -- simple zapping tool for the Linux DVB S2 API
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
szap-s2 requires Linux DVB driver API version 5.0.
If compiler not found DVB headers in ../s2/linux/include/linux/dvb,
then it looks at usual location /usr/include/linux/dvb.
Install as follows:
(Option) make
make install
Uninstall
make uninstall
location of channel list file is ~/.szap/channels.conf
one line of the szap channel file has the following format:
name:frequency_MHz:polarization[coderate][delivery][modulation][rolloff]:sat_no:symbolrate:vpid:apid:service_id
one line of the VDR channel file has the following format:
name:frequency_MHz:polarization[coderate][delivery][modulation][rolloff]:sat_no:symbolrate:vpid:apid:?:?:service_id:?:?:?
usage:
szap -q
list known channels
szap [options] {-n channel-number|channel_name}
zap to channel via number or full name (case insensitive)
-a number : use given adapter (default 0)
-f number : use given frontend (default 0)
-d number : use given demux (default 0)
-c file : read channels list from 'file'
-V : use vdr channels list file format (default zap)
-b : enable Audio Bypass (default no)
-x : exit after tuning
-H : human readable output
-D : params debug
-r : set up /dev/dvb/adapterX/dvr0 for TS recording
-l lnb-type (DVB-S Only) (use -l help to print types) or
-l low[,high[,switch]] in Mhz
-i : run interactively, allowing you to type in channel names
-p : add pat and pmt to TS recording (implies -r)
or -n numbers for zapping
-S : delivery system type DVB-S=0, DVB-S2=1
-M : modulation 1=BPSK 2=QPSK 5=8PSK
-C : fec 0=NONE 12=1/2 23=2/3 34=3/4 35=3/5 45=4/5 56=5/6 67=6/7 89=8/9 910=9/10 999=AUTO
-O : rolloff 35=0.35 25=0.25 20=0.20 0=UNKNOWN
-m : input stream 0-255
Igor M. Liplianin (liplianin@me.by)

101
szap-s2/lnb.c Normal file
View File

@@ -0,0 +1,101 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "lnb.h"
static char *univ_desc[] = {
"Europe",
"10800 to 11800 MHz and 11600 to 12700 Mhz",
"Dual LO, loband 9750, hiband 10600 MHz",
(char *)NULL };
static char *dbs_desc[] = {
"Expressvu, North America",
"12200 to 12700 MHz",
"Single LO, 11250 MHz",
(char *)NULL };
static char *standard_desc[] = {
"10945 to 11450 Mhz",
"Single LO, 10000 Mhz",
(char *)NULL };
static char *enhan_desc[] = {
"Astra",
"10700 to 11700 MHz",
"Single LO, 9750 MHz",
(char *)NULL };
static char *cband_desc[] = {
"Big Dish",
"3700 to 4200 MHz",
"Single LO, 5150 Mhz",
(char *)NULL };
static struct lnb_types_st lnbs[] = {
{"UNIVERSAL", univ_desc, 9750, 10600, 11700 },
{"DBS", dbs_desc, 11250, 0, 0 },
{"STANDARD", standard_desc, 10000, 0, 0 },
{"ENHANCED", enhan_desc, 9750, 0, 0 },
{"C-BAND", cband_desc, 5150, 0, 0 }
};
/* Enumerate through standard types of LNB's until NULL returned.
* Increment curno each time
*/
struct lnb_types_st *
lnb_enum(int curno)
{
if (curno >= (int) (sizeof(lnbs) / sizeof(lnbs[0])))
return (struct lnb_types_st *)NULL;
return &lnbs[curno];
}
/* Decode an lnb type, for example given on a command line
* If alpha and standard type, e.g. "Universal" then match that
* otherwise low[,high[,switch]]
*/
int
lnb_decode(char *str, struct lnb_types_st *lnbp)
{
int i;
char *cp, *np;
memset(lnbp, 0, sizeof(*lnbp));
cp = str;
while(*cp && isspace(*cp))
cp++;
if (isalpha(*cp)) {
for (i = 0; i < (int)(sizeof(lnbs) / sizeof(lnbs[0])); i++) {
if (!strcasecmp(lnbs[i].name, cp)) {
*lnbp = lnbs[i];
return 1;
}
}
return -1;
}
if (*cp == '\0' || !isdigit(*cp))
return -1;
lnbp->low_val = strtoul(cp, &np, 0);
if (lnbp->low_val == 0)
return -1;
cp = np;
while(*cp && (isspace(*cp) || *cp == ','))
cp++;
if (*cp == '\0')
return 1;
if (!isdigit(*cp))
return -1;
lnbp->high_val = strtoul(cp, &np, 0);
cp = np;
while(*cp && (isspace(*cp) || *cp == ','))
cp++;
if (*cp == '\0')
return 1;
if (!isdigit(*cp))
return -1;
lnbp->switch_val = strtoul(cp, NULL, 0);
return 1;
}

24
szap-s2/lnb.h Normal file
View File

@@ -0,0 +1,24 @@
struct lnb_types_st {
char *name;
char **desc;
unsigned long low_val;
unsigned long high_val; /* zero indicates no hiband */
unsigned long switch_val; /* zero indicates no hiband */
};
/* Enumerate through standard types of LNB's until NULL returned.
* Increment curno each time
*/
struct lnb_types_st *
lnb_enum(int curno);
/* Decode an lnb type, for example given on a command line
* If alpha and standard type, e.g. "Universal" then match that
* otherwise low[,high[,switch]]
*/
int
lnb_decode(char *str, struct lnb_types_st *lnbp);

1127
szap-s2/szap-s2.c Normal file

File diff suppressed because it is too large Load Diff

1089
szap-s2/tzap-t2.c Normal file

File diff suppressed because it is too large Load Diff