mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2023-10-10 13:37:43 +02:00
Make setmod tool configurable
This commit is contained in:
parent
cb4834cca0
commit
0d9752284e
@ -9,25 +9,85 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <linux/dvb/mod.h>
|
||||
|
||||
int main()
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int fd;
|
||||
struct dvb_mod_params mp;
|
||||
struct dvb_mod_channel_params mc;
|
||||
|
||||
fd = open("/dev/dvb/adapter1/mod0", O_RDONLY);
|
||||
if (argc != 7)
|
||||
{
|
||||
printf("Usage: device base_frequency[Hz] attenuation[dB]"
|
||||
" modulation[qam_16, qam32, qam_64, qam_128, qam256] pcr_correction[1/0]"
|
||||
" bitrate[bps]\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mp.base_frequency = 722000000;
|
||||
mp.attenuator = 0;
|
||||
char *device = argv[1];
|
||||
uint32_t base_freq = strtoul(argv[2], NULL, 10);
|
||||
if (base_freq < 114000000 || base_freq > 794000000)
|
||||
{
|
||||
printf("Invalid frequency \'%i\'\n", base_freq);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
uint32_t attenuation = strtoul(argv[3], NULL, 10);
|
||||
|
||||
enum fe_modulation modulation;
|
||||
char *modulation_str = argv[4];
|
||||
if (strcmp(modulation_str, "qam_16") == 0)
|
||||
{
|
||||
modulation = QAM_16;
|
||||
}
|
||||
else if (strcmp(modulation_str, "qam_32") == 0)
|
||||
{
|
||||
modulation = QAM_32;
|
||||
}
|
||||
else if (strcmp(modulation_str, "qam_64") == 0)
|
||||
{
|
||||
modulation = QAM_64;
|
||||
}
|
||||
else if (strcmp(modulation_str, "qam_128") == 0)
|
||||
{
|
||||
modulation = QAM_128;
|
||||
}
|
||||
else if (strcmp(modulation_str, "qam_256") == 0)
|
||||
{
|
||||
modulation = QAM_256;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid modulation \'%s\'\n", modulation_str);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
int pcr_correction = strtoul(argv[5], NULL, 10);
|
||||
uint64_t bitrate = strtoul(argv[6], NULL, 10);
|
||||
|
||||
fd = open(device, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
printf("Invalid device \'%s\': %s\n", device, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Setting base_freq=%u attenuation=%u modulation=%s, pcr_correction=%d"
|
||||
"input_bitrate=%u on %s\n",
|
||||
base_freq, attenuation, modulation_str, pcr_correction, bitrate, device);
|
||||
|
||||
mp.base_frequency = base_freq;
|
||||
mp.attenuator = attenuation;
|
||||
ioctl(fd, DVB_MOD_SET, &mp);
|
||||
|
||||
mc.modulation = QAM_256;
|
||||
mc.input_bitrate = 40000000ULL << 32;
|
||||
mc.pcr_correction = 0;
|
||||
ioctl(fd, DVB_MOD_CHANNEL_SET, &mc);
|
||||
mc.modulation = modulation;
|
||||
mc.input_bitrate = bitrate << 32;
|
||||
mc.pcr_correction = pcr_correction;
|
||||
if (ioctl(fd, DVB_MOD_CHANNEL_SET, &mc) != 0)
|
||||
{
|
||||
printf("Invalid options: %s\n", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user