Example #1
0
/* ----------------------------------------------------------------------------*/
int main(int argc,char* argv[]) {
    int i;
    char directory[1024];

    strcpy(soundCardName,"HPSDR");
    strcpy(server_address,"127.0.0.1"); // localhost

    processCommands(argc,argv);

    fprintf(stderr,"gHPSDR rx %d (Version %s)\n",receiver,VERSION);

    setSoundcard(getSoundcardId(soundCardName));

    // initialize DttSP
    if(getcwd(directory, sizeof(directory))==NULL) {
        fprintf(stderr,"current working directory path is > 1024 bytes!");
        exit(1);
    }
    Setup_SDR(directory);
    Release_Update();
    SetTRX(0,0); // thread 0 is for receive
    SetTRX(1,1);  // thread 1 is for transmit
    SetRingBufferOffset(0,offset);
    SetThreadProcessingMode(0,2);
    SetThreadProcessingMode(1,2);
    SetSubRXSt(0,0,1);
    SetRXOutputGain(0,0,0.20);

    reset_for_buflen(0,1024);
    reset_for_buflen(1,1024);

    client_init(receiver);
    audio_stream_init(receiver);

    // initialize ozy
    ozy_init();

    while(1) {
        sleep(10000);
    }

    return 0;
}
Example #2
0
Startup::Startup(int argv, char* argc[]) {

    //QString configFileName=Static::getConfigDir()+"/"+APPNAME+".ini";

    // defaults
    receiver=0;

    host="127.0.0.1";
    serverPort=10600;
    localPort=10700;
    clientPort=10800;

    QRegExp rxArg("--receiver=([0-3])");
    QRegExp clientArg("--clientport=(\\d{1,6}$)");
    QRegExp serverArg("--serverport=(\\d{1,6}$)");
    QRegExp hostArg("--server=(\\S+$)");

    for (int i = 1; i < argv; ++i) {
        if (rxArg.indexIn(argc[i]) != -1 ) {
            receiver=rxArg.cap(1).toInt();
        } else if (clientArg.indexIn(argc[i]) != -1 ) {
            clientPort=clientArg.cap(1).toInt();
        } else if (serverArg.indexIn(argc[i]) != -1 ) {
            serverPort=serverArg.cap(1).toInt();
        } else if (hostArg.indexIn(argc[i]) != -1 ) {
            host=hostArg.cap(1);
        }
    }
    qDebug()<<"receiver:"<<receiver;
    qDebug()<<"clientPort:"<<clientPort;
    qDebug()<<"serverPort:"<<serverPort;
    qDebug()<<"host:"<<host;

    // startup the client listener
    connect(Connection::getInstance(),SIGNAL(setSampleRate(int)),this,SLOT(setSampleRate(int)));
    Connection::getInstance()->setConnection(host,serverPort);
    Data::getInstance();
    ClientListener::getInstance()->setup(clientPort,receiver);



    // Configure DttSP
    Setup_SDR();
    Release_Update();
    SetTRX(0,RX); // thread 0 is for receive
    SetTRX(1,TX);  // thread 1 is for transmit
    SetRingBufferOffset(0,0); // 0 for HPSDR
    SetThreadProcessingMode(0,RUN_PLAY);
    SetThreadProcessingMode(1,RUN_PLAY);
    SetSubRXSt(0,0,1);
    SetRXOutputGain(0,0,0.20);
    SetSampleRate(96000.0);
    reset_for_buflen(0,1024);
    reset_for_buflen(1,1024);

    SetRXOsc(0,0,0.0);
    SetRXOsc(0,1,0.0);
    SetTXOsc(1,0.0);


    QString command;
    command.append(QString("attach "));
    command.append(QString::number(receiver));
    Connection::getInstance()->sendCommand(command);

    command.clear();
    command.append(QString("frequency "));
    command.append(QString::number(receiver));
    command.append(QString(" 7056000"));
    Connection::getInstance()->sendCommand(command);

    // startup to receive the I, Q and microphone samples
    Data::getInstance()->setConnection(host,serverPort+receiver,localPort+receiver);

    // start the IQ and microphone samples
    command.clear();
    command.append(QString("start "));
    command.append(QString::number(receiver));
    command.append(QString(" iq "));
    command.append(QString(host));
    command.append(QString(" "));
    command.append(QString::number(localPort+receiver));
    Connection::getInstance()->sendCommand(command);

}
Example #3
0
File: main.c Project: dl3yc/gHermes
/* ----------------------------------------------------------------------------*/
int main(int argc,char* argv[]) {
    gboolean retry;
    GtkWidget* dialog;
    gint result;
    int i;

    gtk_init(&argc,&argv);

    fprintf(stderr,"gHermes Version %s\n",VERSION);

    strcpy(propertyPath,"gHermes.properties");
    // strcpy(soundCardName,"HPSDR");
    ozy_set_interface("eth0");
    processCommands(argc,argv);
    loadProperties(propertyPath);

#ifdef ALEX_TEST
    alex_rx_test_load("alex_rx_test.csv");
    alex_tx_test_load("alex_tx_test.csv");
#endif

    //init_cw();

    // initialize DttSP
    Setup_SDR();
    Release_Update();
    SetTRX(0,FALSE); // thread 0 is for receive
    SetTRX(1,TRUE);  // thread 1 is for transmit
    SetThreadProcessingMode(0,2); // set thread 0 to RUN
    SetThreadProcessingMode(1,2); // set thread 1 to RUN
    SetSubRXSt(0,0,TRUE);

    reset_for_buflen(0,buffer_size);
    reset_for_buflen(1,buffer_size);


    // initialize ozy (default 48K)
    //ozyRestoreState();
    do {
        switch(ozy_init()) {
            case -1: // cannot find ozy
                dialog = gtk_message_dialog_new (NULL,
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_MESSAGE_ERROR,
                                                 GTK_BUTTONS_YES_NO,
                                                 "Cannot locate Ozy!\n\nIs it powered on and plugged in?");
                gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Retry?");
                gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR");
                result = gtk_dialog_run (GTK_DIALOG (dialog));
                switch (result) {
                    case GTK_RESPONSE_YES:
                        retry=TRUE;
                        break;
                    default:
                        exit(1);
                        break;
                }
                gtk_widget_destroy (dialog);
                break;
            case -2: // found but needs initializing
                result=fork();
                if(result==0) {
                    // child process - exec initozy
                    fprintf(stderr,"exec initozy\n");
                    result=execl("initozy",NULL,NULL);
                    fprintf(stderr,"exec returned %d\n",result);
                    exit(result);
                } else if(result>0) {
                    // wait for the forked process to terminate
                    dialog = gtk_message_dialog_new (NULL,
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_MESSAGE_INFO,
                                                 GTK_BUTTONS_NONE,
                                                 "Initializing Ozy");
                    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Please Wait ...");
                    gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR");
                    gtk_widget_show_all (dialog);
                    while (gtk_events_pending ())
                        gtk_main_iteration ();

                    wait(&result);
                    fprintf(stderr,"wait status=%d\n",result);
                    retry=TRUE;
                }
                gtk_widget_destroy (dialog);
                break;

            case -3: // did not find metis
                dialog = gtk_message_dialog_new (NULL,
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_MESSAGE_ERROR,
                                                 GTK_BUTTONS_YES_NO,
                                                 "Cannot locate Metis on interface %s!",
                                                 ozy_get_interface());
                gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"Retry?");
                gtk_window_set_title(GTK_WINDOW(dialog),"GHPSDR");
                result = gtk_dialog_run (GTK_DIALOG (dialog));
                switch (result) {
                    case GTK_RESPONSE_YES:
                        retry=TRUE;
                        break;
                    default:
                        exit(1);
                        break;
                }
                gtk_widget_destroy (dialog);
                break;
            default:
                retry=FALSE;
                break;
        }
    } while(retry);

    mainRootX=0;
    mainRootY=0;

    cwPitch =600;

    restoreInitialState();

    //SetKeyerResetSize(4096);
    //NewKeyer(600.0f,TRUE,0.0f,3.0f,25.0f,48000.0f);
    //SetKeyerPerf(FALSE);
    //StartKeyer();

    initColors();
    //gtk_key_snooper_install((GtkKeySnoopFunc)keyboardSnooper,NULL);

    //bandscopeRestoreState();
    //bandscopeWindow=buildBandscopeUI();
   
    //bandscope_controlRestoreState();
    //bandscope_controlWindow=buildBandscope_controlUI();
   
    meterRestoreState();
    meterWindow=buildMeterUI();

    vfoRestoreState();
    vfoWindow=buildVfoUI();

    bandRestoreState();
    bandWindow=buildBandUI();

    modeRestoreState();
    modeWindow=buildModeUI();

    filterRestoreState();
    filterWindow=buildFilterUI();

    displayRestoreState();
    displayWindow=buildDisplayUI();

    audioRestoreState();
    audioWindow=buildAudioUI();


    agcRestoreState();
    agcWindow=buildAgcUI();

    preampWindow=buildPreampUI();
    zoomWindow=buildZoomUI();

    receiverRestoreState();
    receiverWindow=buildReceiverUI();

    volumeRestoreState();
    volumeWindow=buildVolumeUI();

    keyerRestoreState();
    keyerWindow=buildKeyerUI();
    cwPitch =(int)cw_sidetone_frequency;

    transmitRestoreState();
    transmitWindow=buildTransmitUI();
    mic_meterWindow=buildMic_MeterUI();

    subrxRestoreState();
    subrxWindow=buildSubRxUI();

    restoreState();


    // build the Main UI
    buildMainUI();

    //setSoundcard(getSoundcardId(soundCardName));

    audio_stream_init();
    
    hamlibserv_init();

    gtk_main();

    return 0;
}
Example #4
0
int main(int argc,char* argv[]) {
    struct dspserver_config config;
    memset(&config, 0, sizeof(config));
    // Register signal and signal handler
    signal(SIGINT, signal_shutdown);    
    char directory[MAXPATHLEN];
    strcpy(config.soundCardName,"HPSDR");
    strcpy(config.server_address,"127.0.0.1"); // localhost
    strcpy(config.share_config_file, getenv("HOME"));
    strcat(config.share_config_file, "/dspserver.conf");
    processCommands(argc,argv,&config);
    fprintf(stderr, "Reading conf file %s\n", config.share_config_file);
    init_register(config.share_config_file); // we now read our conf always
	 // start web registration if set
    if  (toShareOrNotToShare) {
        fprintf(stderr, "Activating Web register\n");
    }
    fprintf(stderr,"gHPSDR rx %d (Version %s)\n",receiver,VERSION);
    printversion();
    setSoundcard(getSoundcardId(config.soundCardName));

    // initialize DttSP
    if(getcwd(directory, sizeof(directory))==NULL) {
        fprintf(stderr,"current working directory path is > MAXPATHLEN");
        exit(1);
    }
    Setup_SDR(directory);
    Release_Update();
    SetTRX(0,0); // thread 0 is for receive
    SetTRX(1,1);  // thread 1 is for transmit
    SetRingBufferOffset(0,config.offset);
    SetThreadProcessingMode(0,RUN_PLAY);
    SetThreadProcessingMode(1,RUN_PLAY);
    SetSubRXSt(0,1,1);
    SetRXOutputGain(0,0,0.20);
    SetRXOsc(0,0, -LO_offset);
    SetRXOsc(0,1, -LO_offset);
    reset_for_buflen(0,1024);
    reset_for_buflen(1,1024);

    client_init(receiver);
    audio_stream_init(receiver);
    audio_stream_reset();

    codec2 = codec2_create();
    G711A_init();
    ozy_init(config.server_address);

    SetMode(1, 0, USB);
    SetTXFilter(1, 150, 2850);
    SetTXOsc(1, LO_offset);
    SetTXAMCarrierLevel(1, 0.5);

    tx_init();	// starts the tx_thread

    while(1) {
        sleep(10000);
    }

 //   codec2_destroy(codec2);
    return 0;
}
Example #5
0
int main(int argc,char* argv[]) {
    memset(&config, 0, sizeof(config));
    // Register signal and signal handler
    signal(SIGINT, signal_shutdown);    
    char directory[MAXPATHLEN];
    strcpy(config.soundCardName,"HPSDR");
    strcpy(config.server_address,"127.0.0.1"); // localhost
    strcpy(config.share_config_file, getenv("HOME"));
    strcat(config.share_config_file, "/dspserver.conf");
    processCommands(argc,argv,&config);

#ifdef THREAD_DEBUG
    sdr_threads_init();
#endif /* THREAD_DEBUG */

    fprintf(stderr, "Reading conf file %s\n", config.share_config_file);
    init_register(config.share_config_file); // we now read our conf always
	 // start web registration if set
    if  (toShareOrNotToShare) {
        fprintf(stderr, "Activating Web register\n");
    }
    fprintf(stderr,"gHPSDR rx %d (Version %s)\n",receiver,VERSION);
    printversion();
    setSoundcard(getSoundcardId(config.soundCardName));

    // initialize DttSP
    if(getcwd(directory, sizeof(directory))==NULL) {
        fprintf(stderr,"current working directory path is > MAXPATHLEN");
        exit(1);
    }
    Setup_SDR(directory);
    Release_Update();
    SetTRX(0,0); // thread 0 is for receive
    SetTRX(1,1);  // thread 1 is for transmit
    SetRingBufferOffset(0,config.offset);
    SetThreadProcessingMode(0,RUN_PLAY);
    SetThreadProcessingMode(1,RUN_PLAY);
    SetSubRXSt(0,1,1);
    SetRXOutputGain(0,0,0.20);
    SetRXOsc(0,0, -LO_offset);
    SetRXOsc(0,1, -LO_offset);
    reset_for_buflen(0,1024);
    reset_for_buflen(1,1024);

    client_init(receiver);        // create the main thread responsible for listen TCP socket
                                  // on the read callback:
                                  //    accept and interpret the commands from remote GUI  
                                  //    parse mic data from remote and enque them into Mic_audio_stream queue
                                  //    see client.c
                                  //
                                  // on the write callback:
                                  //    read the audio_stream_queue and send into the TCP socket
                                  //
    audio_stream_init(receiver);
    audio_stream_reset();

    codec2 = codec2_create(CODEC2_MODE_3200);
    G711A_init();
    ozy_init(config.server_address);   // create and starts iq_thread in ozy.c in order to
                                       // receive iq stream from hardware server
                                       // process it in DttSP
                                       // makes the sample rate adaption for resulting audio
                                       // puts audio stream in a queue (via calls to audio_stream_queue_add 
                                       // in audio_stream_put_samples() in audiostream.c)
                                       //
                                       // in case of HPSDR hardware (that is provided with a local D/A converter
                                       // sends via ozy_send() the audio back to the hardware server
    SetMode(1, 0, USB);
    SetTXFilter(1, 150, 2850);
    SetTXOsc(1, LO_offset);
    SetTXAMCarrierLevel(1, 0.5);

    tx_init();	// create and starts the tx_thread (see client.c)
                // the tx_thread reads the Mic_audio_stream queue, makes the sample rate adaption
                // process the data into DttSP in order to get the modulation process done,
                // and sends back to the hardware server process (via ozy_send() )

#ifdef THREAD_DEBUG
    /* Note that some thread interactions will be lost at startup due to
     * the fact that the subsystem threads are all started.  We can't
     * init this until late, though, or we'll catch initializations
     * performed at boot time as errors. */
    if (config.thread_debug) {
        sdr_threads_debug(TRUE);
    }
#endif /* THREAD_DEBUG */

    while(1) {
        sleep(10000);
    }

 //   codec2_destroy(codec2);
    return 0;
}