Beispiel #1
0
/**
* @brief Set the A vfo frequency
*
* @param f
*/
void setAFrequency(long long f) {

    double cal;
    dspAFrequency=0;
    ddsAFrequency=0;
    frequencyA=f;

    dspAFrequency=0;
    ddsAFrequency=f-frequencyALO;

    cal=(float)f*calibOffset;
    SetRXOsc(0,0,cal);
    updateVfoADisplay();

    frequencyAChanged=1;

    // check the band
    if(displayHF) {
        int thisBand=getBand(f);
        if(band!=thisBand) {
            if(band!=-1) {
                forceBand(thisBand,FALSE);
            }
        }
    }
}
Beispiel #2
0
/** 
* @brief Set the speed
* 
* @param speed
*/
void setSpeed(int s) {
fprintf(stderr,"setSpeed %d\n",s);
    speed=s;
    control_out[1]=control_out[1]&0xFC;
    control_out[1]=control_out[1]|s;
    if(s==SPEED_48KHZ) {
        sampleRate=48000;
        output_sample_increment=1;
        SetSampleRate((double)sampleRate);
        SetRXOsc(0,1, LO_OFFSET);			// tweaked by Alex Lee 18 Aug 2010
        setFilter(filter);
        {
            int *m=malloc(sizeof(int));
            *m=mode;
            setMode(m);
        }
        SetRXOutputGain(0,0,volume/100.0);
    } else if(s==SPEED_96KHZ) {
        sampleRate=96000;
        output_sample_increment=2;
        SetSampleRate((double)sampleRate);
        SetRXOsc(0,1, LO_OFFSET);			// tweaked by Alex Lee 18 Aug 2010
        setFilter(filter);
        {
            int *m=malloc(sizeof(int));
            *m=mode;
            setMode(m);
        }
        SetRXOutputGain(0,0,volume/100.0);
    } else if(s==SPEED_192KHZ) {
        sampleRate=192000;
        output_sample_increment=4;
        SetSampleRate((double)sampleRate);
        SetRXOsc(0,1, LO_OFFSET);			// tweaked by Alex Lee 18 Aug 2010
        setFilter(filter);
        {
            int *m=malloc(sizeof(int));
            *m=mode;
            setMode(m);
        }
        SetRXOutputGain(0,0,volume/100.0);
    }
}
Beispiel #3
0
/**
* @brief  Set the B vfo frequency
*
* @param f
*/
void setBFrequency(long long f) {
    double cal;
    GdkGC* gc;
    PangoContext *context;
    PangoLayout *layout;
    char temp[128];

    dspBFrequency=0;
    ddsBFrequency=0;
    frequencyB=f;

    dspBFrequency=0;
    ddsBFrequency=f-frequencyBLO;

    cal=(float)f*calibOffset;
    SetRXOsc(0,1,cal);
    updateVfoBDisplay();

    frequencyBChanged=1;

//    if(bSubRx) {
//        /* sub rx can only run within the sampled spectrum range */
//        if((f>=(frequencyA-(sampleRate/2)))&& (f<=(frequencyA+(sampleRate/2)))) {
//            frequencyB=f;
//        }
//    } else {
//        frequencyB=f;
//    }
//    updateVfoBDisplay();
//    frequencyBChanged=1;
//
//    if(bSubRx) {
//        long long diff=frequencyA-frequencyB;
//        SetRXOsc(0,1,(double)diff);
//    }

}
Beispiel #4
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);

}
Beispiel #5
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;
}
Beispiel #6
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;
}