示例#1
0
void *syncthread(void *threadid)
{
	fd_set rfd;
	fd_set efd;

	struct timeval tv;

	int ret;

  	int dev;

        dev = open(DEV, O_RDONLY);
	if (dev<0)
		printf("couldn't open(\"%s\"): %s\n", DEV, strerror(errno));

	uint16_t val;

	val=COA_MODE_SNIFF|COA_SUBMODE_SNIFF_SYNC;
	if (ioctl(dev, COA_IOCTL_MODE, &val))
		printf("couldn't set mode()\n");

	unsigned char *RFPI=cfg.getrfpi();
	if(ioctl(dev, COA_IOCTL_SETRFPI, RFPI))
		printf("couldn't set rfpi\n");

	int channel=cfg.getchannel();
	if (ioctl(dev, COA_IOCTL_CHAN, &channel))
		printf("couldn't set channel\n");

	psaver.openfilerfpi(RFPI);

	while (0xDEC + 'T')
	{
		tv.tv_sec  = 1;
		tv.tv_usec = 0;

		FD_ZERO(&rfd);
		FD_ZERO(&efd);

		FD_SET(dev, &rfd);
		FD_SET(dev, &efd);

		ret = select(dev+1, &rfd, NULL, &efd, &tv);
		if (ret < 0)
			printf("select() read error\n");

		if (FD_ISSET(dev, &efd))
			printf("select() exception\n");

		if (FD_ISSET(dev, &rfd))
		{
			if(cfg.getsync()==SYNC_SEARCH)
				cfg.setsync(SYNC_FOUND);

			process_dect_data(dev);
		}

	}



}
示例#2
0
void mainloop(void)
{
    fd_set rfd;
    fd_set wfd;
    fd_set efd;

    int nfds = max_int(cli.in, cli.fd);
    nfds++;

    struct timeval tv;

    int ret;

    while (0xDEC + 'T')
    {
        tv.tv_sec  = 1;
        tv.tv_usec = 0;

        FD_ZERO(&rfd);
        FD_ZERO(&wfd);
        FD_ZERO(&efd);

        FD_SET(cli.in, &rfd);
        FD_SET(cli.fd, &rfd);

        FD_SET(cli.in, &efd);
        FD_SET(cli.fd, &efd);

        ret = select(nfds, &rfd, &wfd, &efd, &tv);
        if (ret < 0)
        {
            LOG("!!! select()\n");
            exit(1);
        }
        if (FD_ISSET(cli.in, &efd))
        {
            LOG("!!! select() on in: %s\n",
                strerror(errno));
            exit(1);
        }
        if (FD_ISSET(cli.fd, &efd))
        {
            LOG("!!! select() on fd: %s\n",
                strerror(errno));
            exit(1);
        }

        if (FD_ISSET(cli.in, &rfd))
            process_cli_data();
        if (FD_ISSET(cli.fd, &rfd))
            process_dect_data();

        if( (cli.hop) &&
                ( (cli.mode & MODE_FPSCAN) ||
                  (cli.mode & MODE_PPSCAN) ||
                  (cli.mode & MODE_CALLSCAN) ||
                  (cli.mode & MODE_JAM   ) ))
        {
            if ( time(NULL) > cli.last_hop + cli.hop_ch_time )
            {
                cli.channel++;
                cli.channel %= 10;
                set_channel(cli.channel);
            }
        }

        if (cli.autorec)
        {
            if ( (time (NULL) - cli.autorec_last_bfield
                    > cli.autorec_timeout)
                    &&
                    (cli.mode != MODE_CALLSCAN)
               )
            {
                do_stop_keep_autorec();
                do_callscan();
                if (cli.pcap)
                {
                    pcap_dump_close(cli.pcap_d);
                    pcap_close(cli.pcap);
                    cli.pcap_d = NULL;
                    cli.pcap   = NULL;
                    cli.hop = 1;

                }

                //Closing dumps
                if (cli.imaDumping)
                    closeIma();
                if (cli.wavDumping)
                    closeWav();
                if (cli.audioPlaying)
                    closeAlsa();

            }
        }
    }

}