Пример #1
0
int create_ozy_thread() {
    int i;
    int rc;

#ifndef __linux__
    if (init_hpsdr() == 0) exit(9);
#endif

    for(i=0;i<receivers;i++) {
        receiver[i].frequency=7056000L;
        receiver[i].frequency_changed=1;
    }

    if(!playback) {
        ozy_init();
        ozy_prime();
    }

    if(timing) {
        ftime(&start_time);
    }

    if(playback) {
        // create a thread to read/write to EP6/EP2
        rc=pthread_create(&playback_thread_id,NULL,playback_thread,NULL);
        if(rc != 0) {
            fprintf(stderr,"pthread_create failed on playback_thread: rc=%d\n", rc);
            exit(1);
        }
    } else {
        // create a thread to read/write to EP6/EP2
        rc=pthread_create(&ep6_ep2_io_thread_id,NULL,ozy_ep6_ep2_io_thread,NULL);
        if(rc != 0) {
            fprintf(stderr,"pthread_create failed on ozy_ep6_io_thread: rc=%d\n", rc);
            exit(1);
        }

/*
        // create a thread to read from EP4
        rc=pthread_create(&ep4_io_thread_id,NULL,ozy_ep4_io_thread,NULL);
        if(rc != 0) {
            fprintf(stderr,"pthread_create failed on ozy_ep4_io_thread: rc=%d\n", rc);
            exit(1);
        }
*/
    }

    return 0;
}
Пример #2
0
void metis_start_receive_thread() {
    int i;
    int rc;
    struct hostent *h;

    fprintf(stderr,"Metis starting receive thread\n");

    discovering=0;

    h=gethostbyname(metis_cards[0].ip_address);
    if(h==NULL) {
        fprintf(stderr,"metis_start_receiver_thread: unknown host %s\n",metis_cards[0].ip_address);
        exit(1);
    }

    data_addr_length=sizeof(data_addr);
    memset(&data_addr,0,data_addr_length);
    data_addr.sin_family=AF_INET;
    data_addr.sin_port=htons(DATA_PORT);
    memcpy((char *)&data_addr.sin_addr.s_addr,h->h_addr_list[0],h->h_length);

    ozy_prime();
    
    // send a packet to start the stream
    buffer[0]=0xEF;
    buffer[1]=0xFE;
    buffer[2]=0x04;    // data send state
    buffer[3]=0x03;    // send (0x00=stop)

    for(i=0;i<60;i++) {
        buffer[i+4]=0x00;
    }

    metis_send_buffer(&buffer[0],64);

fprintf(stderr,"starting metis_watchdog_thread\n");
    // start a watchdog to make sure we are receiving frames
    rc=pthread_create(&watchdog_thread_id,NULL,metis_watchdog_thread,NULL);
    if(rc != 0) {
        fprintf(stderr,"pthread_create failed on metis_watchdog_thread: rc=%d\n", rc);
        exit(1);
    }

}
Пример #3
0
void metis_start_receive_thread() {
    int i;
    int rc;
    struct hostent *h;

    fprintf(stderr,"Metis starting receive thread\n");

    discovering=0;

    h=gethostbyname(metis_cards[0].ip_address);
    if(h==NULL) {
        fprintf(stderr,"metis_start_receiver_thread: unknown host %s\n",metis_cards[0].ip_address);
        exit(1);
    }

    data_addr_length=sizeof(data_addr);
    memset(&data_addr,0,data_addr_length);
    data_addr.sin_family=AF_INET;
    data_addr.sin_port=htons(DATA_PORT);
    memcpy((char *)&data_addr.sin_addr.s_addr,h->h_addr_list[0],h->h_length);

    ozy_prime();
    
    // send a packet to start the stream
    buffer[0]=0xEF;
    buffer[1]=0xFE;
    buffer[2]=0x04;    // data send state
    buffer[3]=0x03;    // send EP6 and EP4 data (0x00=stop)

    for(i=0;i<60;i++) {
        buffer[i+4]=0x00;
    }

    if(sendto(discovery_socket,buffer,64,0,(struct sockaddr*)&data_addr,data_addr_length)<0) {
        perror("sendto socket failed for start\n");
        exit(1);
    }

}