mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-19 10:32:02 -05:00
Starting to implement sound I/O. Changing T/R period to 30 s.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/jtms3@2478 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
8e3105751b
commit
900ff9f2c8
@ -115,6 +115,8 @@ void DevSetup::initDlg()
|
|||||||
ui.comboBoxSndOut->setCurrentIndex(m_nDevOut);
|
ui.comboBoxSndOut->setCurrentIndex(m_nDevOut);
|
||||||
m_paInDevice=m_inDevList[m_nDevIn];
|
m_paInDevice=m_inDevList[m_nDevIn];
|
||||||
m_paOutDevice=m_outDevList[m_nDevOut];
|
m_paOutDevice=m_outDevList[m_nDevOut];
|
||||||
|
qDebug() << "A" << m_nDevIn << m_paInDevice << m_nDevOut << m_paOutDevice;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +143,8 @@ void DevSetup::accept()
|
|||||||
m_paInDevice=m_inDevList[m_nDevIn];
|
m_paInDevice=m_inDevList[m_nDevIn];
|
||||||
m_nDevOut=ui.comboBoxSndOut->currentIndex();
|
m_nDevOut=ui.comboBoxSndOut->currentIndex();
|
||||||
m_paOutDevice=m_outDevList[m_nDevOut];
|
m_paOutDevice=m_outDevList[m_nDevOut];
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
qDebug() << "B" << m_nDevIn << m_paInDevice << m_nDevOut << m_paOutDevice;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ SOURCES += main.cpp mainwindow.cpp plotter.cpp about.cpp \
|
|||||||
displaytext.cpp getdev.cpp
|
displaytext.cpp getdev.cpp
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
SOURCES += killbyname.cpp set570.cpp
|
SOURCES += killbyname.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
HEADERS += mainwindow.h plotter.h soundin.h soundout.h \
|
HEADERS += mainwindow.h plotter.h soundin.h soundout.h \
|
||||||
|
@ -132,7 +132,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
m_colors="000066ff0000ffff00969696646464";
|
m_colors="000066ff0000ffff00969696646464";
|
||||||
|
|
||||||
ui->xThermo->setFillBrush(Qt::green);
|
ui->xThermo->setFillBrush(Qt::green);
|
||||||
ui->yThermo->setFillBrush(Qt::magenta);
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
while(true) {
|
while(true) {
|
||||||
@ -180,7 +179,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
genStdMsgs("");
|
genStdMsgs("");
|
||||||
|
|
||||||
on_actionWide_Waterfall_triggered();
|
on_actionWide_Waterfall_triggered(); //###
|
||||||
if(m_mode=="JT65A") on_actionJT65A_triggered();
|
if(m_mode=="JT65A") on_actionJT65A_triggered();
|
||||||
if(m_mode=="JT65B") on_actionJT65B_triggered();
|
if(m_mode=="JT65B") on_actionJT65B_triggered();
|
||||||
if(m_mode=="JT65C") on_actionJT65C_triggered();
|
if(m_mode=="JT65C") on_actionJT65C_triggered();
|
||||||
@ -467,7 +466,6 @@ void MainWindow::dataSink(int k)
|
|||||||
if(!m_xpol) t.sprintf(" Rx noise: %5.1f %5.1f %% ",px,m_pctZap);
|
if(!m_xpol) t.sprintf(" Rx noise: %5.1f %5.1f %% ",px,m_pctZap);
|
||||||
lab4->setText(t);
|
lab4->setText(t);
|
||||||
ui->xThermo->setValue((double)px); //Update the bargraphs
|
ui->xThermo->setValue((double)px); //Update the bargraphs
|
||||||
ui->yThermo->setValue((double)py);
|
|
||||||
if(m_monitoring || m_diskData) {
|
if(m_monitoring || m_diskData) {
|
||||||
g_pWideGraph->dataSink2(s,nkhz,ihsym,m_diskData,lstrong);
|
g_pWideGraph->dataSink2(s,nkhz,ihsym,m_diskData,lstrong);
|
||||||
}
|
}
|
||||||
@ -821,7 +819,7 @@ void MainWindow::on_actionWide_Waterfall_triggered() //Display Waterfalls
|
|||||||
connect(g_pWideGraph, SIGNAL(f11f12(int)),this,
|
connect(g_pWideGraph, SIGNAL(f11f12(int)),this,
|
||||||
SLOT(bumpDF(int)));
|
SLOT(bumpDF(int)));
|
||||||
}
|
}
|
||||||
g_pWideGraph->show();
|
// g_pWideGraph->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionOpen_triggered() //Open File
|
void MainWindow::on_actionOpen_triggered() //Open File
|
||||||
@ -1191,19 +1189,20 @@ void MainWindow::guiUpdate()
|
|||||||
static char msgsent[23];
|
static char msgsent[23];
|
||||||
static int nsendingsh=0;
|
static int nsendingsh=0;
|
||||||
int khsym=0;
|
int khsym=0;
|
||||||
|
double trperiod=30.0;
|
||||||
|
|
||||||
double tx1=0.0;
|
double tx1=0.0;
|
||||||
double tx2=126.0*4096.0/11025.0 + 1.8; //### depend on TxDelay? ###
|
double tx2=trperiod;
|
||||||
|
|
||||||
if(!m_txFirst) {
|
if(!m_txFirst) {
|
||||||
tx1 += 60.0;
|
tx1 += trperiod;
|
||||||
tx2 += 60.0;
|
tx2 += trperiod;
|
||||||
}
|
}
|
||||||
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
qint64 ms = QDateTime::currentMSecsSinceEpoch() % 86400000;
|
||||||
int nsec=ms/1000;
|
int nsec=ms/1000;
|
||||||
double tsec=0.001*ms;
|
double tsec=0.001*ms;
|
||||||
double t120=fmod(tsec,120.0);
|
double t2p=fmod(tsec,2*trperiod);
|
||||||
bool bTxTime = t120 >= tx1 && t120 < tx2;
|
bool bTxTime = t2p >= tx1 && t2p < tx2;
|
||||||
|
|
||||||
if(m_auto) {
|
if(m_auto) {
|
||||||
if(bTxTime and iptt==0 and !m_txMute) {
|
if(bTxTime and iptt==0 and !m_txMute) {
|
||||||
@ -1237,9 +1236,10 @@ void MainWindow::guiUpdate()
|
|||||||
|
|
||||||
ba2msg(ba,message);
|
ba2msg(ba,message);
|
||||||
int len1=22;
|
int len1=22;
|
||||||
|
|
||||||
|
//### Wrong mode!
|
||||||
int mode65=m_mode65;
|
int mode65=m_mode65;
|
||||||
double samfac=1.0;
|
double samfac=1.0;
|
||||||
|
|
||||||
gen65_(message,&mode65,&samfac,&nsendingsh,msgsent,iwave,&nwave,len1,len1);
|
gen65_(message,&mode65,&samfac,&nsendingsh,msgsent,iwave,&nwave,len1,len1);
|
||||||
msgsent[22]=0;
|
msgsent[22]=0;
|
||||||
|
|
||||||
@ -1260,7 +1260,6 @@ void MainWindow::guiUpdate()
|
|||||||
if(nc1 <= 0) nc1++;
|
if(nc1 <= 0) nc1++;
|
||||||
if(nc1 == 0) {
|
if(nc1 == 0) {
|
||||||
ui->xThermo->setValue(0.0); //Set the Thermos to zero
|
ui->xThermo->setValue(0.0); //Set the Thermos to zero
|
||||||
ui->yThermo->setValue(0.0);
|
|
||||||
m_monitoring=false;
|
m_monitoring=false;
|
||||||
soundInThread.setMonitoring(false);
|
soundInThread.setMonitoring(false);
|
||||||
btxok=true;
|
btxok=true;
|
||||||
@ -1360,9 +1359,8 @@ void MainWindow::guiUpdate()
|
|||||||
QString utc = " " + t.time().toString() + " ";
|
QString utc = " " + t.time().toString() + " ";
|
||||||
ui->labUTC->setText(utc);
|
ui->labUTC->setText(utc);
|
||||||
if((!m_monitoring and !m_diskData) or (khsym==m_hsym0)) {
|
if((!m_monitoring and !m_diskData) or (khsym==m_hsym0)) {
|
||||||
ui->xThermo->setValue(0.0); // Set Rx levels to 0
|
ui->xThermo->setValue(0.0); // Set Rx level to 20
|
||||||
ui->yThermo->setValue(0.0);
|
lab4->setText(" Rx noise: 0.0 0.0% ");
|
||||||
lab4->setText(" Rx noise: 0.0 0.0 0.0% ");
|
|
||||||
}
|
}
|
||||||
m_hsym0=khsym;
|
m_hsym0=khsym;
|
||||||
m_sec0=nsec;
|
m_sec0=nsec;
|
||||||
|
@ -244,7 +244,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QwtThermo" name="xThermo" native="true">
|
<widget class="QwtThermo" name="xThermo">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -257,50 +257,19 @@ p, li { white-space: pre-wrap; }
|
|||||||
<height>180</height>
|
<height>180</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="borderWidth" stdset="0">
|
<property name="borderWidth">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maxValue" stdset="0">
|
<property name="maxValue">
|
||||||
<double>60.000000000000000</double>
|
<double>60.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="minValue" stdset="0">
|
<property name="minValue">
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="pipeWidth" stdset="0">
|
<property name="pipeWidth">
|
||||||
<number>8</number>
|
<number>8</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="value" stdset="0">
|
<property name="value">
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QwtThermo" name="yThermo" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>12</width>
|
|
||||||
<height>177</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="borderWidth" stdset="0">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maxValue" stdset="0">
|
|
||||||
<double>60.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="minValue" stdset="0">
|
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="pipeWidth" stdset="0">
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<property name="value" stdset="0">
|
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@ -1185,7 +1154,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Decode</string>
|
<string>Decode</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionNo_Deep_Search"/>
|
<addaction name="actionNo_Deep_Search"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuSave">
|
<widget class="QMenu" name="menuSave">
|
||||||
@ -1366,7 +1334,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No Deep Search</string>
|
<string>TBD...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionNormal_Deep_Search">
|
<action name="actionNormal_Deep_Search">
|
||||||
@ -1555,16 +1523,16 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>DisplayText</class>
|
|
||||||
<extends>QTextBrowser</extends>
|
|
||||||
<header>displaytext.h</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QwtThermo</class>
|
<class>QwtThermo</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>qwt_thermo.h</header>
|
<header>qwt_thermo.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>DisplayText</class>
|
||||||
|
<extends>QTextBrowser</extends>
|
||||||
|
<header>displaytext.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
275
set570.cpp
275
set570.cpp
@ -1,275 +0,0 @@
|
|||||||
|
|
||||||
/* Linux / Windows program to control the frequency of a si570 synthesizer
|
|
||||||
ON5GN 6 jan 2012
|
|
||||||
Under Linux:
|
|
||||||
-use the linux version of function void si570_sleep(int us)
|
|
||||||
-compile with
|
|
||||||
gcc -Wall -o set_si570_freq set_si570_freq.c -lusb -lm
|
|
||||||
-run with sudo ./set_si570_freq
|
|
||||||
Under Windows:
|
|
||||||
-use the windows version of function void si570_sleep(int us)
|
|
||||||
-compile with mingw
|
|
||||||
C:\mingw\bin\mingw32-gcc -Wall -o set_si570_freq set_si570_freq.c -lusb -lm
|
|
||||||
-run with set_si570_freq.exe
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h> /* Standard input/output definitions */
|
|
||||||
#include <string.h> /* String function definitions */
|
|
||||||
#include <unistd.h> /* UNIX standard function definitions */
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <usb.h>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define USB_SUCCESS 0
|
|
||||||
#define USB_ERROR_NOTFOUND 1
|
|
||||||
#define USB_ERROR_ACCESS 2
|
|
||||||
#define USB_ERROR_IO 3
|
|
||||||
#define VENDOR_NAME "www.obdev.at"
|
|
||||||
#define PRODUCT_NAME "DG8SAQ-I2C"
|
|
||||||
#define USBDEV_SHARED_VENDOR 0x16C0 // VOTI VID
|
|
||||||
#define USBDEV_SHARED_PRODUCT 0x05DC // OBDEV PID
|
|
||||||
// Use obdev's generic shared VID/PID pair
|
|
||||||
// following the rules outlined in
|
|
||||||
// firmware/usbdrv/USBID-License.txt.
|
|
||||||
#define REQUEST_SET_FREQ_BY_VALUE 0x32
|
|
||||||
#define MAX_USB_ERR_CNT 6
|
|
||||||
|
|
||||||
double freq_parm;
|
|
||||||
double delay_average;
|
|
||||||
int from_freq;
|
|
||||||
int to_freq;
|
|
||||||
int increment_freq;
|
|
||||||
int retval = -1;
|
|
||||||
int display_freq = -1;
|
|
||||||
int delay;
|
|
||||||
usb_dev_handle *global_si570usb_handle = NULL;
|
|
||||||
|
|
||||||
// ********sleep functions***************
|
|
||||||
//use this function under LINUX
|
|
||||||
/*
|
|
||||||
void si570_sleep(int us)
|
|
||||||
{
|
|
||||||
usleep(us);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//use this function under WINDOWS
|
|
||||||
void si570_sleep(int us)
|
|
||||||
{
|
|
||||||
Sleep(us/1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
double round(double x)
|
|
||||||
{
|
|
||||||
int i=x+0.5;
|
|
||||||
return (double)i;
|
|
||||||
}
|
|
||||||
|
|
||||||
double current_time(void) //for delay measurements
|
|
||||||
{
|
|
||||||
struct timeval t;
|
|
||||||
gettimeofday(&t,NULL);
|
|
||||||
return 0.000001*t.tv_usec+t.tv_sec;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usbGetStringAscii(usb_dev_handle *dev, int my_index,
|
|
||||||
int langid, char *buf, int buflen);
|
|
||||||
unsigned char Si570usbOpenDevice(usb_dev_handle **device, char *usbSerialID);
|
|
||||||
void setLongWord( int value, char * bytes);
|
|
||||||
int setFreqByValue(usb_dev_handle * handle, double frequency);
|
|
||||||
void sweepa_freq(void);
|
|
||||||
void sweepm_freq(void);
|
|
||||||
|
|
||||||
int set570(double freq_MHz)
|
|
||||||
{
|
|
||||||
char * my_usbSerialID = NULL;
|
|
||||||
|
|
||||||
// MAIN MENU DIALOG
|
|
||||||
retval=Si570usbOpenDevice(&global_si570usb_handle, my_usbSerialID);
|
|
||||||
if (retval != 0) return -1;
|
|
||||||
|
|
||||||
//SET FREQUENCY
|
|
||||||
if((freq_MHz < 3.45)|(freq_MHz > 866.0)) return -2;
|
|
||||||
retval=setFreqByValue(global_si570usb_handle,freq_MHz);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int usbGetStringAscii(usb_dev_handle *dev, int my_index,
|
|
||||||
int langid, char *buf, int buflen)
|
|
||||||
{
|
|
||||||
char buffer[256];
|
|
||||||
int rval, i;
|
|
||||||
if((rval = usb_control_msg(dev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR,
|
|
||||||
(USB_DT_STRING << 8) + my_index, langid, buffer,
|
|
||||||
sizeof(buffer), 1000)) < 0) return rval;
|
|
||||||
if(buffer[1] != USB_DT_STRING) return 0;
|
|
||||||
if((unsigned char)buffer[0] < rval) rval = (unsigned char)buffer[0];
|
|
||||||
rval /= 2;
|
|
||||||
// lossy conversion to ISO Latin1
|
|
||||||
for(i=1;i<rval;i++) {
|
|
||||||
if(i > buflen) break; // destination buffer overflow
|
|
||||||
buf[i-1] = buffer[2 * i];
|
|
||||||
if(buffer[2 * i + 1] != 0) buf[i-1] = '?'; // outside of ISO Latin1 range
|
|
||||||
}
|
|
||||||
buf[i-1] = 0;
|
|
||||||
return i-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char Si570usbOpenDevice(usb_dev_handle **device, char *usbSerialID)
|
|
||||||
{
|
|
||||||
struct usb_bus *bus;
|
|
||||||
struct usb_device *dev;
|
|
||||||
usb_dev_handle *handle = NULL;
|
|
||||||
unsigned char errorCode = USB_ERROR_NOTFOUND;
|
|
||||||
char string[256];
|
|
||||||
int len;
|
|
||||||
int vendor = USBDEV_SHARED_VENDOR;
|
|
||||||
char *vendorName = VENDOR_NAME;
|
|
||||||
int product = USBDEV_SHARED_PRODUCT;
|
|
||||||
char *productName = PRODUCT_NAME;
|
|
||||||
char serialNumberString[20];
|
|
||||||
static int didUsbInit = 0;
|
|
||||||
|
|
||||||
if(!didUsbInit) {
|
|
||||||
didUsbInit = 1;
|
|
||||||
usb_init();
|
|
||||||
}
|
|
||||||
usb_find_busses();
|
|
||||||
usb_find_devices();
|
|
||||||
for(bus=usb_get_busses(); bus; bus=bus->next) {
|
|
||||||
for(dev=bus->devices; dev; dev=dev->next) {
|
|
||||||
if(dev->descriptor.idVendor == vendor &&
|
|
||||||
dev->descriptor.idProduct == product) {
|
|
||||||
handle = usb_open(dev); // open the device in order to query strings
|
|
||||||
if(!handle) {
|
|
||||||
errorCode = USB_ERROR_ACCESS;
|
|
||||||
printf("si570.c: Warning: cannot open Si570-USB device:\n");
|
|
||||||
printf("usb error message: %s\n",usb_strerror());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(vendorName == NULL && productName == NULL) { //name does not matter
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// now check whether the names match
|
|
||||||
len = usbGetStringAscii(handle, dev->descriptor.iManufacturer, 0x0409, string, sizeof(string));
|
|
||||||
if(len < 0) {
|
|
||||||
errorCode = USB_ERROR_IO;
|
|
||||||
printf("si570.c: Warning: cannot query manufacturer for Si570-USB device:\n");
|
|
||||||
printf("usb error message: %s\n",usb_strerror());
|
|
||||||
} else {
|
|
||||||
errorCode = USB_ERROR_NOTFOUND;
|
|
||||||
//fprintf(stderr, "seen device from vendor ->%s<-\n", string);
|
|
||||||
if(strcmp(string, vendorName) == 0){
|
|
||||||
len = usbGetStringAscii(handle, dev->descriptor.iProduct,
|
|
||||||
0x0409, string, sizeof(string));
|
|
||||||
if(len < 0) {
|
|
||||||
errorCode = USB_ERROR_IO;
|
|
||||||
printf("si570.c: Warning: cannot query product for Si570-USB device: \n");
|
|
||||||
printf("usb error message: %s\n",usb_strerror());
|
|
||||||
} else {
|
|
||||||
errorCode = USB_ERROR_NOTFOUND;
|
|
||||||
// fprintf(stderr, "seen product ->%s<-\n", string);
|
|
||||||
if(strcmp(string, productName) == 0) {
|
|
||||||
len = usbGetStringAscii(handle, dev->descriptor.iSerialNumber,
|
|
||||||
0x0409, serialNumberString, sizeof(serialNumberString));
|
|
||||||
if (len < 0) {
|
|
||||||
errorCode = USB_ERROR_IO;
|
|
||||||
printf("si570.c: Warning: cannot query serial number for Si570-USB device: \n");
|
|
||||||
printf("usb error message: %s\n",usb_strerror());
|
|
||||||
} else {
|
|
||||||
errorCode = USB_ERROR_NOTFOUND;
|
|
||||||
if ((usbSerialID == NULL) ||
|
|
||||||
(strcmp(serialNumberString, usbSerialID) == 0)) {
|
|
||||||
// printf("\nOpen Si570 USB device: OK\n");
|
|
||||||
// printf("usbSerialID : %s\n",serialNumberString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
usb_close(handle);
|
|
||||||
handle = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(handle) break;
|
|
||||||
}
|
|
||||||
if(handle != NULL) {
|
|
||||||
errorCode = USB_SUCCESS;
|
|
||||||
*device = handle;
|
|
||||||
}
|
|
||||||
return errorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLongWord( int value, char * bytes)
|
|
||||||
{
|
|
||||||
bytes[0] = value & 0xff;
|
|
||||||
bytes[1] = ((value & 0xff00) >> 8) & 0xff;
|
|
||||||
bytes[2] = ((value & 0xff0000) >> 16) & 0xff;
|
|
||||||
bytes[3] = ((value & 0xff000000) >> 24) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
int setFreqByValue(usb_dev_handle * handle, double frequency)
|
|
||||||
{
|
|
||||||
// Windows Doc from PE0FKO:
|
|
||||||
//
|
|
||||||
// Command 0x32:
|
|
||||||
// -------------
|
|
||||||
// Set the oscillator frequency by value. The frequency is formatted in MHz
|
|
||||||
// as 11.21 bits value.
|
|
||||||
// The "automatic band pass filter selection", "smooth tune",
|
|
||||||
// "one side calibration" and the "frequency subtract multiply" are all
|
|
||||||
// done in this function. (if enabled in the firmware)
|
|
||||||
//
|
|
||||||
// Default: None
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
// requesttype: USB_ENDPOINT_OUT
|
|
||||||
// request: 0x32
|
|
||||||
// value: 0
|
|
||||||
// index: 0
|
|
||||||
// bytes: pointer 32 bits integer
|
|
||||||
// size: 4
|
|
||||||
//
|
|
||||||
// Code sample:
|
|
||||||
// uint32_t iFreq;
|
|
||||||
// double dFreq;
|
|
||||||
//
|
|
||||||
// dFreq = 30.123456; // MHz
|
|
||||||
// iFreq = (uint32_t)( dFreq * (1UL << 21) )
|
|
||||||
// r = usbCtrlMsgOUT(0x32, 0, 0, (char *)&iFreq, sizeof(iFreq));
|
|
||||||
// if (r < 0) Error
|
|
||||||
//
|
|
||||||
|
|
||||||
char buffer[4];
|
|
||||||
int i2cAddress = 0x55;
|
|
||||||
int request = REQUEST_SET_FREQ_BY_VALUE;
|
|
||||||
int value = 0x700 + i2cAddress;
|
|
||||||
int my_index = 0;
|
|
||||||
int retval;
|
|
||||||
int err_cnt;
|
|
||||||
|
|
||||||
err_cnt =0;
|
|
||||||
set_again:;
|
|
||||||
setLongWord(round(frequency * 2097152.0), buffer); // 2097152=2^21
|
|
||||||
retval=usb_control_msg(
|
|
||||||
handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT,
|
|
||||||
request,
|
|
||||||
value,
|
|
||||||
my_index,
|
|
||||||
buffer,
|
|
||||||
sizeof(buffer),
|
|
||||||
5000);
|
|
||||||
if (retval != 4) {
|
|
||||||
err_cnt ++;
|
|
||||||
if(err_cnt < MAX_USB_ERR_CNT) {
|
|
||||||
si570_sleep(1000); // delay 1000 microsec
|
|
||||||
goto set_again;
|
|
||||||
} else {
|
|
||||||
printf("Error when setting frequency, returncode=%i\n",retval);
|
|
||||||
printf("usb error message: %s\n", usb_strerror());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
@ -125,7 +125,7 @@ void SoundOutThread::run()
|
|||||||
paerr=Pa_IsFormatSupported(NULL,&outParam,11025.0);
|
paerr=Pa_IsFormatSupported(NULL,&outParam,11025.0);
|
||||||
if(paerr<0) {
|
if(paerr<0) {
|
||||||
qDebug() << "PortAudio says requested output format not supported.";
|
qDebug() << "PortAudio says requested output format not supported.";
|
||||||
qDebug() << paerr;
|
qDebug() << paerr << m_nDevOut;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ void SoundOutThread::run()
|
|||||||
paerr=Pa_OpenStream(&outStream, //Output stream
|
paerr=Pa_OpenStream(&outStream, //Output stream
|
||||||
NULL, //No input parameters
|
NULL, //No input parameters
|
||||||
&outParam, //Output parameters
|
&outParam, //Output parameters
|
||||||
11025.0, //Sample rate
|
12000.0, //Sample rate
|
||||||
FRAMES_PER_BUFFER, //Frames per buffer
|
FRAMES_PER_BUFFER, //Frames per buffer
|
||||||
paClipOff, //No clipping
|
paClipOff, //No clipping
|
||||||
d2aCallback, //output callbeck routine
|
d2aCallback, //output callbeck routine
|
||||||
|
@ -280,7 +280,7 @@ void WideGraph::on_fCenterLineEdit_editingFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WideGraph::on_pbSetRxHardware_clicked()
|
void WideGraph::on_pbSetRxHardware_clicked()
|
||||||
{
|
{/*
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int iret=set570(m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq);
|
int iret=set570(m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq);
|
||||||
if(iret != 0) {
|
if(iret != 0) {
|
||||||
@ -290,12 +290,14 @@ void WideGraph::on_pbSetRxHardware_clicked()
|
|||||||
mb.exec();
|
mb.exec();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void WideGraph::initIQplus()
|
void WideGraph::initIQplus()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int iret=set570(288.0);
|
// int iret=set570(288.0);
|
||||||
if(iret != 0) {
|
if(iret != 0) {
|
||||||
QMessageBox mb;
|
QMessageBox mb;
|
||||||
if(iret==-1) mb.setText("Failed to open Si570.");
|
if(iret==-1) mb.setText("Failed to open Si570.");
|
||||||
@ -305,6 +307,7 @@ void WideGraph::initIQplus()
|
|||||||
on_pbSetRxHardware_clicked();
|
on_pbSetRxHardware_clicked();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void WideGraph::on_cbSpec2d_toggled(bool b)
|
void WideGraph::on_cbSpec2d_toggled(bool b)
|
||||||
|
Loading…
Reference in New Issue
Block a user