Commit ef4b02ef authored by Nicolas Guilbert's avatar Nicolas Guilbert

More command line parameters and better defaults

parent 90ba855a
......@@ -9,12 +9,26 @@ int main(int argc, char *argv[]) {
parser.setApplicationDescription("Command line tool to extract S-parameters (S11 and S21) from a miniVNA Tiny");
parser.addHelpOption();
parser.addOptions({
{"m",
{ "m",
QCoreApplication::translate("main", "Measurement mode, R: reflection, T: transmission, default R"),
QCoreApplication::translate("main", "mode")},
{"p",
QCoreApplication::translate("main", "mode")
},
{ "p",
QCoreApplication::translate("main", "Serial port, default /dev/ttyUSB0"),
QCoreApplication::translate("main", "Port name")},
QCoreApplication::translate("main", "Port name")
},
{ "start",
QCoreApplication::translate("main", "Start frequency (daHz), default 1000000"),
QCoreApplication::translate("main", "frequency")
},
{ "stop",
QCoreApplication::translate("main", "Stop frequency (daHz), default 300000000"),
QCoreApplication::translate("main", "frequency")
},
{ "samples",
QCoreApplication::translate("main", "Number of samples, default 1001"),
QCoreApplication::translate("main", "samples")
},
});
parser.process(app);
VnaSerial vna;
......@@ -27,7 +41,10 @@ int main(int argc, char *argv[]) {
if (parser.isSet("m") && parser.value("m") == 'T') {
measurementMode = VnaSerial::TRANSMISSION;
}
QVector<SParameters> sParameterForAllFrequencies = vna.doMeasure(measurementMode, 1000000, 299999938, 994);
const int startFrequency = parser.isSet("start") ? parser.value("start").toInt() : 1000000;
const int stopFrequency = parser.isSet("stop") ? parser.value("stop").toInt() : 300000000;
const int nbSamples = parser.isSet("samples") ? parser.value("samples").toInt() : 1001;
QVector<SParameters> sParameterForAllFrequencies = vna.doMeasure(measurementMode, startFrequency, stopFrequency, nbSamples);
for(const SParameters& sParameter : sParameterForAllFrequencies) {
std::cout << sParameter.toString().toStdString() << std::endl;
}
......
......@@ -55,10 +55,6 @@ QVector<SParameters> VnaSerial::doMeasure(MeasurementMode mode, unsigned int sta
return extractSParametersFromSerialResponse(responseData, startFrequency, stopFrequency);
}
int VnaSerial::getError() {
return (serial.error());
}
void VnaSerial::sendParam(unsigned int x) {
QByteArray s = QByteArray::number(x);
serial.write(s + "\r");
......
......@@ -44,7 +44,6 @@ public:
int initVna(QString deviceName);
QVector<SParameters> doMeasure(MeasurementMode mode,
unsigned int startFrequency, unsigned int stopFrequency, unsigned int requestedNbSamples);
int getError();
private:
void sendParam(unsigned int x);
static QVector<SParameters> extractSParametersFromSerialResponse(const QByteArray& serialResponse,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment