mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2023-10-10 13:37:43 +02:00
add some options for device, adapter and read/write lengths
This commit is contained in:
parent
2d71c946d3
commit
094e1f3e1f
89
apps/cit.c
89
apps/cit.c
@ -9,6 +9,9 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
uint32_t adapter = 0, device = 0, snum = 256, rnum = 256;
|
||||||
|
|
||||||
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,
|
||||||
@ -68,24 +71,34 @@ void proc_buf(uint8_t *buf, uint32_t *d)
|
|||||||
} else {
|
} else {
|
||||||
if (memcmp(ts+8, buf+8, 180))
|
if (memcmp(ts+8, buf+8, 180))
|
||||||
printf("error\n");
|
printf("error\n");
|
||||||
if (!(c&0xffff))
|
if (!(c&0xffff)) {
|
||||||
printf("R %08x\n", c);
|
printf("R %08x\r", c);
|
||||||
|
fflush(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(*d)++;
|
(*d)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *get_ts(void *a)
|
void *get_ts(void *a)
|
||||||
{
|
{
|
||||||
uint8_t buf[188*1024];
|
uint8_t *buf;
|
||||||
int len, off;
|
int len, off;
|
||||||
|
int fdi;
|
||||||
int fdi=open("/dev/dvb/adapter2/ci0", O_RDONLY);
|
char fname[80];
|
||||||
uint32_t d=0;
|
uint32_t d=0;
|
||||||
|
|
||||||
|
buf = malloc(188*rnum);
|
||||||
|
if (!buf)
|
||||||
|
return NULL;
|
||||||
|
sprintf(fname, "/dev/dvb/adapter%u/ci%u", adapter, device);
|
||||||
|
fdi = open(fname, O_RDONLY);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
len=read(fdi, buf, 188*1024);
|
memset(buf, 0, 188*rnum);
|
||||||
|
len=read(fdi, buf, 188*rnum);
|
||||||
if (len<0)
|
if (len<0)
|
||||||
continue;
|
continue;
|
||||||
|
//printf("read %u\n", len);
|
||||||
if (buf[0]!=0x47) {
|
if (buf[0]!=0x47) {
|
||||||
read(fdi, buf, 1);
|
read(fdi, buf, 1);
|
||||||
continue;
|
continue;
|
||||||
@ -96,20 +109,23 @@ void *get_ts(void *a)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SNUM 233
|
|
||||||
//671
|
int send(void)
|
||||||
void send(void)
|
|
||||||
{
|
{
|
||||||
uint8_t buf[188*SNUM], *cts;
|
uint8_t *buf, *cts;
|
||||||
int i;
|
int i;
|
||||||
uint32_t c=0;
|
uint32_t c=0;
|
||||||
int fdo;
|
int fdo;
|
||||||
|
char fname[80];
|
||||||
fdo=open("/dev/dvb/adapter2/ci0", O_WRONLY);
|
|
||||||
|
buf = malloc(188*snum);
|
||||||
|
if (!buf)
|
||||||
|
return -1;
|
||||||
|
sprintf(fname, "/dev/dvb/adapter%u/ci%u", adapter, device);
|
||||||
|
fdo=open(fname, O_WRONLY);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
for (i=0; i<SNUM; i++) {
|
for (i=0; i<snum; i++) {
|
||||||
cts=buf+i*188;
|
cts=buf+i*188;
|
||||||
memcpy(cts, ts, 188);
|
memcpy(cts, ts, 188);
|
||||||
cts[4]=(c>>24);
|
cts[4]=(c>>24);
|
||||||
@ -122,15 +138,54 @@ void send(void)
|
|||||||
//usleep(100000+0xffff&rand());
|
//usleep(100000+0xffff&rand());
|
||||||
//usleep(1000);
|
//usleep(1000);
|
||||||
}
|
}
|
||||||
write(fdo, buf, 188*SNUM);
|
write(fdo, buf, 188*snum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
pthread_t th;
|
pthread_t th;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
int option_index = 0;
|
||||||
|
int c;
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"adapter", required_argument, 0, 'a'},
|
||||||
|
{"device", required_argument, 0, 'd'},
|
||||||
|
{"snum", required_argument, 0, 's'},
|
||||||
|
{"rnum", required_argument, 0, 'r'},
|
||||||
|
{"help", no_argument , 0, 'h'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
c = getopt_long(argc, argv,
|
||||||
|
"a:d:h",
|
||||||
|
long_options, &option_index);
|
||||||
|
if (c==-1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case 'd':
|
||||||
|
device = strtoul(optarg, NULL, 10);
|
||||||
|
break;
|
||||||
|
case 'a':
|
||||||
|
adapter = strtoul(optarg, NULL, 10);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
snum = strtoul(optarg, NULL, 10);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
rnum = strtoul(optarg, NULL, 10);
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (optind < argc) {
|
||||||
|
printf("Warning: unused arguments\n");
|
||||||
|
}
|
||||||
memset(ts+8, 180, 0x5a);
|
memset(ts+8, 180, 0x5a);
|
||||||
pthread_create(&th, NULL, get_ts, NULL);
|
pthread_create(&th, NULL, get_ts, NULL);
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
Loading…
Reference in New Issue
Block a user