mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2025-03-01 10:35:23 +00:00
Add reset function.
This commit is contained in:
parent
e7390e1cd8
commit
4e0bf8b182
42
apps/cit.c
42
apps/cit.c
@ -10,8 +10,9 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <linux/dvb/ca.h>
|
||||||
|
|
||||||
uint32_t adapter = 0, device = 0, snum = 256, rnum = 256;
|
uint32_t adapter = 0, device = 0, snum = 256, rnum = 256, do_reset = 0;
|
||||||
|
|
||||||
uint8_t fill[188]={0x47, 0x1f, 0xff, 0x10,
|
uint8_t fill[188]={0x47, 0x1f, 0xff, 0x10,
|
||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||||
@ -171,6 +172,34 @@ int send(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void reset()
|
||||||
|
{
|
||||||
|
char fname[80];
|
||||||
|
int fd, i;
|
||||||
|
|
||||||
|
sprintf(fname, "/dev/dvb/adapter%u/ca%u", adapter, device);
|
||||||
|
fd=open(fname, O_WRONLY);
|
||||||
|
if (fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ioctl(fd, CA_RESET);
|
||||||
|
|
||||||
|
for (i=0; i<24; i++) {
|
||||||
|
ca_slot_info_t info;
|
||||||
|
|
||||||
|
usleep(500000);
|
||||||
|
info.num = 0;
|
||||||
|
if (ioctl(fd, CA_GET_SLOT_INFO, &info))
|
||||||
|
return;
|
||||||
|
if (info.flags & CA_CI_MODULE_READY)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i==24)
|
||||||
|
dprintf(2, "RESET failed\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
pthread_t th;
|
pthread_t th;
|
||||||
@ -183,11 +212,12 @@ int main(int argc, char **argv)
|
|||||||
{"device", required_argument, 0, 'd'},
|
{"device", required_argument, 0, 'd'},
|
||||||
{"snum", required_argument, 0, 's'},
|
{"snum", required_argument, 0, 's'},
|
||||||
{"rnum", required_argument, 0, 'r'},
|
{"rnum", required_argument, 0, 'r'},
|
||||||
|
{"reset", no_argument, 0, 'R'},
|
||||||
{"help", no_argument , 0, 'h'},
|
{"help", no_argument , 0, 'h'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
c = getopt_long(argc, argv,
|
c = getopt_long(argc, argv,
|
||||||
"a:d:h",
|
"a:d:hs:R",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
if (c==-1)
|
if (c==-1)
|
||||||
break;
|
break;
|
||||||
@ -205,6 +235,9 @@ int main(int argc, char **argv)
|
|||||||
case 'r':
|
case 'r':
|
||||||
rnum = strtoul(optarg, NULL, 10);
|
rnum = strtoul(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
do_reset = 1;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
printf("cit -a<adapter> -d<device>\n");
|
printf("cit -a<adapter> -d<device>\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -216,6 +249,11 @@ int main(int argc, char **argv)
|
|||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
printf("Warning: unused arguments\n");
|
printf("Warning: unused arguments\n");
|
||||||
}
|
}
|
||||||
|
if (do_reset) {
|
||||||
|
reset();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
printf("adapter %d, device: %d\n", adapter, device);
|
printf("adapter %d, device: %d\n", adapter, device);
|
||||||
memset(ts+8, 180, 0x5a);
|
memset(ts+8, 180, 0x5a);
|
||||||
pthread_create(&th, NULL, get_ts, NULL);
|
pthread_create(&th, NULL, get_ts, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user