kopia lustrzana https://github.com/f4exb/sdrangel
SDRdaemon: added data address and port options
rodzic
44fe60b56f
commit
d7c7eb9f43
|
@ -28,30 +28,39 @@
|
||||||
|
|
||||||
SDRDaemonParser::SDRDaemonParser() :
|
SDRDaemonParser::SDRDaemonParser() :
|
||||||
m_serverAddressOption(QStringList() << "a" << "api-address",
|
m_serverAddressOption(QStringList() << "a" << "api-address",
|
||||||
"Web API server address.",
|
"API server and data (Tx) address.",
|
||||||
"address",
|
"localAddress",
|
||||||
"127.0.0.1"),
|
"127.0.0.1"),
|
||||||
m_serverPortOption(QStringList() << "p" << "api-port",
|
m_serverPortOption(QStringList() << "p" << "api-port",
|
||||||
"Web API server port.",
|
"Web API server port.",
|
||||||
"port",
|
"apiPort",
|
||||||
|
"9091"),
|
||||||
|
m_dataAddressOption(QStringList() << "A" << "data-address",
|
||||||
|
"Remote data address (Rx).",
|
||||||
|
"remoteAddress",
|
||||||
|
"127.0.0.1"),
|
||||||
|
m_dataPortOption(QStringList() << "D" << "data-port",
|
||||||
|
"UDP stream data port.",
|
||||||
|
"dataPort",
|
||||||
"9091"),
|
"9091"),
|
||||||
m_deviceTypeOption(QStringList() << "T" << "device-type",
|
m_deviceTypeOption(QStringList() << "T" << "device-type",
|
||||||
"Device type.",
|
"Device type.",
|
||||||
"deviceType",
|
"deviceType",
|
||||||
"TestSource"),
|
"TestSource"),
|
||||||
m_txOption(QStringList() << "t" << "tx",
|
m_txOption(QStringList() << "t" << "tx",
|
||||||
"Tx indicator.",
|
"Tx indicator."),
|
||||||
"tx"),
|
|
||||||
m_serialOption(QStringList() << "s" << "serial",
|
m_serialOption(QStringList() << "s" << "serial",
|
||||||
"Device serial number.",
|
"Device serial number.",
|
||||||
"serial"),
|
"serial"),
|
||||||
m_sequenceOption(QStringList() << "n" << "sequence",
|
m_sequenceOption(QStringList() << "n" << "sequence",
|
||||||
"Device sequence number in enumeration for the same device type.",
|
"Device sequence number in enumeration for the same device type.",
|
||||||
"serial")
|
"sequence")
|
||||||
|
|
||||||
{
|
{
|
||||||
m_serverAddress = "127.0.0.1";
|
m_serverAddress = "127.0.0.1";
|
||||||
m_serverPort = 9091;
|
m_serverPort = 9091;
|
||||||
|
m_dataAddress = "127.0.0.1";
|
||||||
|
m_dataPort = 9090;
|
||||||
m_deviceType = "TestSource";
|
m_deviceType = "TestSource";
|
||||||
m_tx = false;
|
m_tx = false;
|
||||||
m_sequence = 0;
|
m_sequence = 0;
|
||||||
|
@ -64,6 +73,8 @@ SDRDaemonParser::SDRDaemonParser() :
|
||||||
|
|
||||||
m_parser.addOption(m_serverAddressOption);
|
m_parser.addOption(m_serverAddressOption);
|
||||||
m_parser.addOption(m_serverPortOption);
|
m_parser.addOption(m_serverPortOption);
|
||||||
|
m_parser.addOption(m_dataAddressOption);
|
||||||
|
m_parser.addOption(m_dataPortOption);
|
||||||
m_parser.addOption(m_deviceTypeOption);
|
m_parser.addOption(m_deviceTypeOption);
|
||||||
m_parser.addOption(m_txOption);
|
m_parser.addOption(m_txOption);
|
||||||
m_parser.addOption(m_serialOption);
|
m_parser.addOption(m_serialOption);
|
||||||
|
@ -108,6 +119,27 @@ void SDRDaemonParser::parse(const QCoreApplication& app)
|
||||||
qWarning() << "SDRDaemonParser::parse: server port invalid. Defaulting to " << m_serverPort;
|
qWarning() << "SDRDaemonParser::parse: server port invalid. Defaulting to " << m_serverPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// data address
|
||||||
|
|
||||||
|
QString dataAddress = m_parser.value(m_dataAddressOption);
|
||||||
|
|
||||||
|
if (ipValidator.validate(dataAddress, pos) == QValidator::Acceptable) {
|
||||||
|
m_dataAddress = dataAddress;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SDRDaemonParser::parse: data address invalid. Defaulting to " << m_dataAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
// server port
|
||||||
|
|
||||||
|
QString dataPortStr = m_parser.value(m_dataPortOption);
|
||||||
|
serverPort = serverPortStr.toInt(&ok);
|
||||||
|
|
||||||
|
if (ok && (serverPort > 1023) && (serverPort < 65536)) {
|
||||||
|
m_dataPort = serverPort;
|
||||||
|
} else {
|
||||||
|
qWarning() << "SDRDaemonParser::parse: data port invalid. Defaulting to " << m_dataPort;
|
||||||
|
}
|
||||||
|
|
||||||
// hardware Id
|
// hardware Id
|
||||||
|
|
||||||
QString deviceType = m_parser.value(m_deviceTypeOption);
|
QString deviceType = m_parser.value(m_deviceTypeOption);
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
|
|
||||||
const QString& getServerAddress() const { return m_serverAddress; }
|
const QString& getServerAddress() const { return m_serverAddress; }
|
||||||
uint16_t getServerPort() const { return m_serverPort; }
|
uint16_t getServerPort() const { return m_serverPort; }
|
||||||
|
const QString& getDataAddress() const { return m_dataAddress; }
|
||||||
|
uint16_t getDataPort() const { return m_dataPort; }
|
||||||
const QString& getDeviceType() const { return m_deviceType; }
|
const QString& getDeviceType() const { return m_deviceType; }
|
||||||
bool getTx() const { return m_tx; }
|
bool getTx() const { return m_tx; }
|
||||||
const QString& getSerial() const { return m_serial; }
|
const QString& getSerial() const { return m_serial; }
|
||||||
|
@ -45,18 +47,22 @@ public:
|
||||||
bool hasSerial() const { return m_hasSerial; }
|
bool hasSerial() const { return m_hasSerial; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_serverAddress;
|
QString m_serverAddress; //!< Address of interface the API and UDP data (Tx) listens on
|
||||||
uint16_t m_serverPort;
|
uint16_t m_serverPort; //!< Port the API listens on
|
||||||
QString m_deviceType; //!< Identifies the type of device
|
QString m_dataAddress; //!< Address of destination of UDP stream (Rx)
|
||||||
bool m_tx; //!< True for Tx
|
uint16_t m_dataPort; //!< Destination port of UDP stream (Rx) or listening port (Tx)
|
||||||
QString m_serial; //!< Serial number of the device
|
QString m_deviceType; //!< Identifies the type of device
|
||||||
uint16_t m_sequence; //!< Sequence of the device for the same type of device in enumeration process
|
bool m_tx; //!< True for Tx
|
||||||
bool m_hasSerial; //!< True if serial was specified
|
QString m_serial; //!< Serial number of the device
|
||||||
bool m_hasSequence; //!< True if sequence was specified
|
uint16_t m_sequence; //!< Sequence of the device for the same type of device in enumeration process
|
||||||
|
bool m_hasSerial; //!< True if serial was specified
|
||||||
|
bool m_hasSequence; //!< True if sequence was specified
|
||||||
|
|
||||||
QCommandLineParser m_parser;
|
QCommandLineParser m_parser;
|
||||||
QCommandLineOption m_serverAddressOption;
|
QCommandLineOption m_serverAddressOption;
|
||||||
QCommandLineOption m_serverPortOption;
|
QCommandLineOption m_serverPortOption;
|
||||||
|
QCommandLineOption m_dataAddressOption;
|
||||||
|
QCommandLineOption m_dataPortOption;
|
||||||
QCommandLineOption m_deviceTypeOption;
|
QCommandLineOption m_deviceTypeOption;
|
||||||
QCommandLineOption m_txOption;
|
QCommandLineOption m_txOption;
|
||||||
QCommandLineOption m_serialOption;
|
QCommandLineOption m_serialOption;
|
||||||
|
|
Ładowanie…
Reference in New Issue