Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: Problems with budget dvb-s cards
The following code does a few loops and then kills my card:
(or is there something wrong with the program??)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <fcntl.h>
void SetFiltSection (int fd, unsigned short pid, unsigned char tid)
{
struct dmx_sct_filter_params sctFilterParams;
memset(&sctFilterParams, 0, sizeof(sctFilterParams));
sctFilterParams.pid = pid;
sctFilterParams.timeout = 6000;
sctFilterParams.flags = DMX_IMMEDIATE_START;
sctFilterParams.filter.filter[0] = tid;
sctFilterParams.filter.mask[0] = 0xFF;
if (ioctl(fd, DMX_SET_FILTER, &sctFilterParams) < 0)
{
fprintf(stderr, "couldn't set filter: %m\n", errno);
exit (1);
}
}
int get_epg(unsigned char *buffer,unsigned int pid,unsigned int table_id)
{
int fd;
int n;
if((fd = open("/dev/dvb/adapter0/demux0",O_RDWR)) < 0)
{
fprintf(stderr,"DEMUX DEVICE: %m\n",errno);
return 0;
}
SetFiltSection (fd,pid,table_id);
n = read(fd,buffer,4096);
if (n <= 0)
{
fprintf(stderr,"Error reading epg: %m\n",errno);
return 0;
}
ioctl(fd, DMX_STOP);
close (fd);
return n;
}
int main(void)
{
int fd;
int n;
int i=0;
unsigned char *buffer=new unsigned char[4097];
unsigned char *sb=buffer;
while(true)
{
buffer=sb;
n=get_epg(buffer,0x12,0x4e);
printf("%d: %d Bytes\n",++i,n);
fflush(stderr);
fflush(stdout);
}
return 0;
}
Home |
Main Index |
Thread Index