コード例 #1
0
ファイル: Main_Window.cpp プロジェクト: Sean3Don/robocup-pcb
void Main_Window::on_sweep_clicked()
{
    QProgressDialog *dlg = new QProgressDialog(this);
    dlg->setWindowModality(Qt::WindowModal);
    dlg->setLabelText("Frequency Sweep");
    dlg->setCancelButtonText("Cancel");
    dlg->setMaximum(100);
    dlg->show();
    
    double start = ui.sweep_start->value();
    double stop = ui.sweep_stop->value();
    double step = ui.sweep_step->value();
    
    for (double f = start; f <= stop && !dlg->wasCanceled(); f += step)
    {
        dlg->setValue((int)((f - start) * 100.0 / (stop - start)));
        QCoreApplication::processEvents();
        
        ui.freq->setValue(f);
        on_idle_clicked();
        update_freq();
        send_freq();
        on_cal_clicked();
        on_tx_clicked();
        
        usleep(100 * 1000);
    }
    
    delete dlg;
}
コード例 #2
0
ファイル: Main_Window.cpp プロジェクト: Sean3Don/robocup-pcb
void Main_Window::on_send_clicked()
{
    update_freq();
    send_freq();
    
    int channel = ui.channel->value();
    _dev->control(USB_Device::Control_In | USB_Device::Control_Vendor, 1, channel, 0x0a);
}
コード例 #3
0
ファイル: Main_Window.cpp プロジェクト: Sean3Don/robocup-pcb
void Main_Window::update_freq()
{
    double crystal = ui.crystal->value();
    double base_freq = ui.freq->value();
    
    if (base_freq >= 770 && base_freq <= 970)
    {
        freq = (int)round(base_freq * 65536.0 / crystal);
        double freq_actual = crystal / 65536.0 * freq;
        ui.freq_actual->setText(QString::number(freq_actual, 'f', 6));
        printf("%08x %f\n", freq, freq_actual);
        
        if (tx)
        {
            on_idle_clicked();
            send_freq();
            on_cal_clicked();
            on_tx_clicked();
        } else {
            send_freq();
        }
    }
}
コード例 #4
0
ファイル: time_update.c プロジェクト: thatchristoph/tlf
/** broadcast to LAN
 *
 * every 120s broadcast frequency via LAN and
 * act as time master if allowed */
void broadcast_lan(void)
{
    extern int time_master;
    extern float freq;
    static int frcounter = 0;

    frcounter++;

    if (frcounter >= 60) {	// every 60 calls
	frcounter = 0;
	if (lan_active != 0) {
	    send_freq(freq);
	    if (time_master == 1)
		send_time();
	}
    }
}
コード例 #5
0
void plugin_set_uplink_frequency( double frequency )
{
  double freq;
  char upFreq[12];
  int freqTX = 0x2e;
  int term;

  freq=frequency-fmod(frequency,5);
  if(fmod(frequency,5)>2.5)
    freq+=5;

/* printf("Uplink Frequency: %f kHz -> %f kHz\n", frequency, freq); */

  frequency = frequency / 1000;		/* Convert: kHz -> MHz */
  sprintf(upFreq, "%.6f", frequency);
  term = strlen(upFreq);
  upFreq[term] = '\0';

  send_freq(upFreq);
  putc(freqTX, radioFileA);
  fflush(radioFileA);

}
コード例 #6
0
int plugin_open_rig( char * config )
{
    char dumm[64];
    char tty[12];
    char Smod[4];
    char Qmod[4];
    char *ptr, *parm;
    char cmd[64];
 
    int dummy = 0;
    int saton = 0x0E;
    int modLSB = 0x00;
    int modUSB = 0x01;
    int modCW = 0x02;
    int modFM = 0x08;
    int modRX = 0x17;
    int modTX = 0x27;
    int freqRX = 0x1e;
    int freqTX = 0x2e;
    int term;

    int upMode, downMode;

    char freq[12];
    char upFreq[12], downFreq[12], tmp1Freq[12], tmp2Freq[12];
    double V = 145.950;
    double U = 435.850;
    double T1 = 52.000;
    double T2 = 1260.000; 

    tty[0]='\0';
    Smod[0]='\0';
    Qmod[0]='\0';

    printf("FT736 plugin opened.\n");

    if(config) {
      strncpy(dumm,config,64);

      ptr=dumm;
      parm=ptr;
      while( parm != NULL ) {
        parm=strsep(&ptr,":");
        if(parm==NULL)
          break;
        if(strlen(parm)!=0) {
          switch( *parm ) {
          case 'D':			/* tty port */
            strcpy(tty,parm+1);
            break;
          case 'S':			/* Up/Down Freq. */
            strcpy(Smod,parm+1);
            break;
          case 'Q':			/* QSO Mode */
            strcpy(Qmod,parm+1);
            break;
          }
        }
      }
    }

    if(strlen(tty)==0)
        strcpy(tty,"/dev/ttyS0");
    if(strlen(Smod)==0)
        strcpy(Smod,"UV");
    if(strlen(Qmod)==0)
        strcpy(Qmod,"CW");

/* Open CAT port */
    radioFileA = fopen(tty, "a");
    if ( radioFileA == NULL ) {
	fprintf(stderr, "can't open %s\n", tty);
        return 0;
    }

/* CAT port initialize */
   sprintf(cmd, "/bin/stty speed 4800 < %s", tty);
   system(cmd);
   sprintf(cmd, "/bin/stty cstopb < %s", tty);
   system(cmd);

/* Send CMD: CAT ON */
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    fflush(radioFileA);

/* Send CMD: SAT ON */
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(saton, radioFileA);
    fflush(radioFileA);
    sleep(1);

/* set QSO MODE  */
    upMode = downMode = modCW;

    if ( strcmp(Qmod, "CW") == 0 ) {
      upMode = downMode = modCW;  
    }
    if ( strcmp(Qmod, "SSB") == 0 ) {
      upMode = modLSB;
      downMode = modUSB;
    }
    if ( strcmp(Qmod, "FM") == 0 ) {
      upMode = downMode = modFM;
    }

/* Send CMD: SAT RX MODE */
    putc(downMode, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(modRX, radioFileA);
    fflush(radioFileA);

/* Send CMD: SAT TX MODE */
    putc(upMode, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(dummy, radioFileA);
    putc(modTX, radioFileA);
    fflush(radioFileA);
    sleep(1);

/* set SAT MODE */
    sprintf(upFreq, "%.6f", U);
    sprintf(downFreq, "%.6f", V);
    sprintf(tmp1Freq, "%.6f", T1);
    sprintf(tmp2Freq, "%.6f", T2);

    if ( strcmp(Smod, "UV") == 0 ) {	/* ^ 430MHz v 144MHz */
      sprintf(upFreq, "%.6f", U);
      sprintf(downFreq, "%.6f", V);
    }
    if ( strcmp(Smod, "VU") == 0 ) {	/* ^ 144MHz v 430MHz */
      sprintf(upFreq, "%.6f", V);
      sprintf(downFreq, "%.6f", U);
    }
    if ( strcmp(Smod, "US") == 0 ) {	/* ^ 430MHz v 2.4GHz */
      sprintf(upFreq, "%.6f", U);
      sprintf(downFreq, "%.6f", V);
    }
    term = strlen(upFreq);
    upFreq[term] = '\0';
    term = strlen(downFreq);
    downFreq[term] = '\0';
    term = strlen(tmp1Freq);
    tmp1Freq[term] = '\0';
    term = strlen(tmp2Freq);
    tmp2Freq[term] = '\0';

/* Send CMD: dummy downlink Freq */
    send_freq(tmp2Freq);
    putc(freqRX, radioFileA);
    fflush(radioFileA);
    sleep(1);
 
/* Send CMD: dummy uplink Freq */
    send_freq(tmp1Freq);
    putc(freqTX, radioFileA);
    fflush(radioFileA);

/* Send CMD: uplink Freq */
    send_freq(upFreq);
    putc(freqTX, radioFileA);
    fflush(radioFileA);
    sleep(1);

/* Send CMD: downlink Freq */
    send_freq(downFreq);
    putc(freqRX, radioFileA);
    fflush(radioFileA);

  return 1;
}
コード例 #7
0
ファイル: driver-bitfury.c プロジェクト: CSRedRat/cgminer
static int64_t bitfury_scanHash(struct thr_info *thr)
{
	static struct bitfury_device *devices; // TODO Move somewhere to appropriate place
	int chip_n;
	int chip;
	uint64_t hashes = 0;
	struct timeval now;
	unsigned char line[2048];
	int short_stat = 10;
	static time_t short_out_t;
	int long_stat = 1800;
	static time_t long_out_t;
	int long_long_stat = 60 * 30;
	static time_t long_long_out_t;
	static first = 0; //TODO Move to detect()
	int i;

	devices = thr->cgpu->devices;
	chip_n = thr->cgpu->chip_n;

	if (!first) {
		for (i = 0; i < chip_n; i++) {
			devices[i].osc6_bits = 54;
		}
		for (i = 0; i < chip_n; i++) {
			send_reinit(devices[i].slot, devices[i].fasync, devices[i].osc6_bits);
		}
	}
	first = 1;

	for (chip = 0; chip < chip_n; chip++) {
		devices[chip].job_switched = 0;
		if(!devices[chip].work) {
			devices[chip].work = get_queued(thr->cgpu);
			if (devices[chip].work == NULL) {
				return 0;
			}
			work_to_payload(&(devices[chip].payload), devices[chip].work);
		}
	}

	libbitfury_sendHashData(devices, chip_n);
	nmsleep(5);

	cgtime(&now);
	chip = 0;
	for (;chip < chip_n; chip++) {
		if (devices[chip].job_switched) {
			int i,j;
			int *res = devices[chip].results;
			struct work *work = devices[chip].work;
			struct work *owork = devices[chip].owork;
			struct work *o2work = devices[chip].o2work;
			i = devices[chip].results_n;
			for (j = i - 1; j >= 0; j--) {
				if (owork) {
					submit_nonce(thr, owork, bswap_32(res[j]));
					devices[chip].stat_ts[devices[chip].stat_counter++] =
						now.tv_sec;
					if (devices[chip].stat_counter == BITFURY_STAT_N) {
						devices[chip].stat_counter = 0;
					}
				}
				if (o2work) {
					// TEST
					//submit_nonce(thr, owork, bswap_32(res[j]));
				}
			}
			devices[chip].results_n = 0;
			devices[chip].job_switched = 0;
			if (devices[chip].old_nonce && o2work) {
					submit_nonce(thr, o2work, bswap_32(devices[chip].old_nonce));
					i++;
			}
			if (devices[chip].future_nonce) {
					submit_nonce(thr, work, bswap_32(devices[chip].future_nonce));
					i++;
			}

			if (o2work)
				work_completed(thr->cgpu, o2work);

			devices[chip].o2work = devices[chip].owork;
			devices[chip].owork = devices[chip].work;
			devices[chip].work = NULL;
			hashes += 0xffffffffull * i;
		}
	}

	if (now.tv_sec - short_out_t > short_stat) {
		int shares_first = 0, shares_last = 0, shares_total = 0;
		char stat_lines[32][256] = {0};
		int len, k;
		double gh[32][8] = {0};
		double ghsum = 0, gh1h = 0, gh2h = 0;
		unsigned strange_counter = 0;

		for (chip = 0; chip < chip_n; chip++) {
			int shares_found = calc_stat(devices[chip].stat_ts, short_stat, now);
			double ghash;
			len = strlen(stat_lines[devices[chip].slot]);
			ghash = shares_to_ghashes(shares_found, short_stat);
			gh[devices[chip].slot][chip & 0x07] = ghash;
			snprintf(stat_lines[devices[chip].slot] + len, 256 - len, "%.1f-%3.0f ", ghash, devices[chip].mhz);

			if(short_out_t && ghash < 0.5) {
				applog(LOG_WARNING, "Chip_id %d FREQ CHANGE\n", chip);
				send_freq(devices[chip].slot, devices[chip].fasync, devices[chip].osc6_bits - 1);
				nmsleep(1);
				send_freq(devices[chip].slot, devices[chip].fasync, devices[chip].osc6_bits);
			}
			shares_total += shares_found;
			shares_first += chip < 4 ? shares_found : 0;
			shares_last += chip > 3 ? shares_found : 0;
			strange_counter += devices[chip].strange_counter;
			devices[chip].strange_counter = 0;
		}
		sprintf(line, "vvvvwww SHORT stat %ds: wwwvvvv", short_stat);
		applog(LOG_WARNING, line);
		sprintf(line, "stranges: %u", strange_counter);
		applog(LOG_WARNING, line);
		for(i = 0; i < 32; i++)
			if(strlen(stat_lines[i])) {
				len = strlen(stat_lines[i]);
				ghsum = 0;
				gh1h = 0;
				gh2h = 0;
				for(k = 0; k < 4; k++) {
					gh1h += gh[i][k];
					gh2h += gh[i][k+4];
					ghsum += gh[i][k] + gh[i][k+4];
				}
				snprintf(stat_lines[i] + len, 256 - len, "- %2.1f + %2.1f = %2.1f slot %i ", gh1h, gh2h, ghsum, i);
				applog(LOG_WARNING, stat_lines[i]);
			}
		short_out_t = now.tv_sec;
	}

	if (now.tv_sec - long_out_t > long_stat) {
		int shares_first = 0, shares_last = 0, shares_total = 0;
		char stat_lines[32][256] = {0};
		int len, k;
		double gh[32][8] = {0};
		double ghsum = 0, gh1h = 0, gh2h = 0;

		for (chip = 0; chip < chip_n; chip++) {
			int shares_found = calc_stat(devices[chip].stat_ts, long_stat, now);
			double ghash;
			len = strlen(stat_lines[devices[chip].slot]);
			ghash = shares_to_ghashes(shares_found, long_stat);
			gh[devices[chip].slot][chip & 0x07] = ghash;
			snprintf(stat_lines[devices[chip].slot] + len, 256 - len, "%.1f-%3.0f ", ghash, devices[chip].mhz);

			shares_total += shares_found;
			shares_first += chip < 4 ? shares_found : 0;
			shares_last += chip > 3 ? shares_found : 0;
		}
		sprintf(line, "!!!_________ LONG stat %ds: ___________!!!", long_stat);
		applog(LOG_WARNING, line);
		for(i = 0; i < 32; i++)
			if(strlen(stat_lines[i])) {
				len = strlen(stat_lines[i]);
				ghsum = 0;
				gh1h = 0;
				gh2h = 0;
				for(k = 0; k < 4; k++) {
					gh1h += gh[i][k];
					gh2h += gh[i][k+4];
					ghsum += gh[i][k] + gh[i][k+4];
				}
				snprintf(stat_lines[i] + len, 256 - len, "- %2.1f + %2.1f = %2.1f slot %i ", gh1h, gh2h, ghsum, i);
				applog(LOG_WARNING, stat_lines[i]);
			}
		long_out_t = now.tv_sec;
	}

	return hashes;
}
コード例 #8
0
    SL_ext_atten.clear();
    SL_ext_atten << "0.0" << "3.0";
    ui->CB_int2Atten->addItems(SL_ext_atten);
    SL_ext_atten.clear();
    SL_ext_atten << "0.0" << "3.0" << "6.0" << "9.0";
    ui->CB_int1Atten->addItems(SL_ext_atten);

    QRegExp fRegex ("^[1]{0,1}[0-9]{4,4}[.]{1,1}[0-9]{0,6}$");
    QRegExpValidator *fValidator = new QRegExpValidator(fRegex, this);
    ui->LE_freq->setValidator(fValidator);


    connect(ui->PB_start,SIGNAL(clicked()),this,SLOT(portStart()));
    connect(ui->PB_stop,SIGNAL(clicked()),this,SLOT(protStop()));
    connect(ui->PB_refresh,SIGNAL(clicked()),this,SLOT(protRefresh()));
    connect(ui->PB_freq, SIGNAL(clicked()), this, SLOT(send_freq()));
    connect(protocol_inst, SIGNAL(portInfo(QString)), this, SLOT(setInfo(QString)));
    connect(protocol_inst, SIGNAL(portError(QString)), this, SLOT(setError(QString)));
}

Generator::~Generator()
{
    delete ui;
}

void Generator::portStart(void)
{
    if(protocol_inst->start(ui->CB_comList->currentText(),ui->CB_baudList->currentText().toUInt()))
    {
        setInfo("Device started.");
    }