mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-09 22:08:40 -04:00
USRP: Implement GPIO settings.
This commit is contained in:
parent
a4269dcd78
commit
56bd20d59b
@ -813,6 +813,25 @@ bool USRPOutput::applySettings(const USRPOutputSettings& settings, const QList<Q
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("gpioDir") || force)
|
||||
{
|
||||
if (m_deviceShared.m_deviceParams->getDevice())
|
||||
{
|
||||
m_deviceShared.m_deviceParams->getDevice()->set_gpio_attr("FP0", "CTRL", ~settings.m_gpioDir, 0xff); // 0 for GPIO, 1 for ATR
|
||||
m_deviceShared.m_deviceParams->getDevice()->set_gpio_attr("FP0", "DDR", settings.m_gpioDir, 0xff); // 0 for input, 1 for output
|
||||
qDebug() << "USRPOutput::applySettings: set GPIO dir to " << settings.m_gpioDir;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("gpioPins") || force)
|
||||
{
|
||||
if (m_deviceShared.m_deviceParams->getDevice())
|
||||
{
|
||||
m_deviceShared.m_deviceParams->getDevice()->set_gpio_attr("FP0", "OUT", settings.m_gpioPins, 0xff);
|
||||
qDebug() << "USRPOutput::applySettings: set GPIO pins to " << settings.m_gpioPins;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("useReverseAPI"))
|
||||
{
|
||||
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||
@ -1036,6 +1055,12 @@ void USRPOutput::webapiUpdateDeviceSettings(
|
||||
if (deviceSettingsKeys.contains("transverterMode")) {
|
||||
settings.m_transverterMode = response.getUsrpOutputSettings()->getTransverterMode() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioDir")) {
|
||||
settings.m_gpioDir = response.getUsrpOutputSettings()->getGpioDir();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioPins")) {
|
||||
settings.m_gpioPins = response.getUsrpOutputSettings()->getGpioPins();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
||||
settings.m_useReverseAPI = response.getUsrpOutputSettings()->getUseReverseApi() != 0;
|
||||
}
|
||||
@ -1072,6 +1097,8 @@ void USRPOutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& resp
|
||||
response.getUsrpOutputSettings()->setLpfBw(settings.m_lpfBW);
|
||||
response.getUsrpOutputSettings()->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
||||
response.getUsrpOutputSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
||||
response.getUsrpOutputSettings()->setGpioDir(settings.m_gpioDir);
|
||||
response.getUsrpOutputSettings()->setGpioPins(settings.m_gpioPins);
|
||||
response.getUsrpOutputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
||||
|
||||
if (response.getUsrpOutputSettings()->getReverseApiAddress()) {
|
||||
@ -1172,6 +1199,12 @@ void USRPOutput::webapiReverseSendSettings(const QList<QString>& deviceSettingsK
|
||||
if (deviceSettingsKeys.contains("transverterMode") || force) {
|
||||
swgUsrpOutputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioDir") || force) {
|
||||
swgUsrpOutputSettings->setGpioDir(settings.m_gpioDir);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioPins") || force) {
|
||||
swgUsrpOutputSettings->setGpioPins(settings.m_gpioPins);
|
||||
}
|
||||
|
||||
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
||||
.arg(settings.m_reverseAPIAddress)
|
||||
|
@ -40,6 +40,8 @@ void USRPOutputSettings::resetToDefaults()
|
||||
m_clockSource = "internal";
|
||||
m_transverterMode = false;
|
||||
m_transverterDeltaFrequency = 0;
|
||||
m_gpioDir = 0;
|
||||
m_gpioPins = 0;
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
m_reverseAPIPort = 8888;
|
||||
@ -63,6 +65,8 @@ QByteArray USRPOutputSettings::serialize() const
|
||||
s.writeU32(11, m_reverseAPIPort);
|
||||
s.writeU32(12, m_reverseAPIDeviceIndex);
|
||||
s.writeS32(13, m_loOffset);
|
||||
s.writeU32(14, m_gpioDir);
|
||||
s.writeU32(15, m_gpioPins);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -102,6 +106,10 @@ bool USRPOutputSettings::deserialize(const QByteArray& data)
|
||||
d.readU32(12, &uintval, 0);
|
||||
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
|
||||
d.readS32(13, &m_loOffset, 0);
|
||||
d.readU32(14, &uintval, 0);
|
||||
m_gpioDir = uintval & 0xFF;
|
||||
d.readU32(15, &uintval, 0);
|
||||
m_gpioPins = uintval & 0xFF;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -148,6 +156,12 @@ void USRPOutputSettings::applySettings(const QStringList& settingsKeys, const US
|
||||
if (settingsKeys.contains("transverterDeltaFrequency")) {
|
||||
m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency;
|
||||
}
|
||||
if (settingsKeys.contains("gpioDir")) {
|
||||
m_gpioDir = settings.m_gpioDir;
|
||||
}
|
||||
if (settingsKeys.contains("gpioPins")) {
|
||||
m_gpioPins = settings.m_gpioPins;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI")) {
|
||||
m_useReverseAPI = settings.m_useReverseAPI;
|
||||
}
|
||||
@ -199,6 +213,12 @@ QString USRPOutputSettings::getDebugString(const QStringList& settingsKeys, bool
|
||||
if (settingsKeys.contains("transverterDeltaFrequency") || force) {
|
||||
ostr << " m_transverterDeltaFrequency: " << m_transverterDeltaFrequency;
|
||||
}
|
||||
if (settingsKeys.contains("gpioDir") || force) {
|
||||
ostr << " m_gpioDir: " << (int) m_gpioDir;
|
||||
}
|
||||
if (settingsKeys.contains("gpioPins") || force) {
|
||||
ostr << " m_gpioPins: " << (int) m_gpioPins;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI") || force) {
|
||||
ostr << " m_useReverseAPI: " << m_useReverseAPI;
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ struct USRPOutputSettings
|
||||
QString m_clockSource;
|
||||
bool m_transverterMode;
|
||||
qint64 m_transverterDeltaFrequency;
|
||||
uint8_t m_gpioDir; //!< GPIO pin direction; 0 ATR (automatic transmit/receive), 1 output
|
||||
uint8_t m_gpioPins; //!< GPIO pins levels for outputs
|
||||
bool m_useReverseAPI;
|
||||
QString m_reverseAPIAddress;
|
||||
uint16_t m_reverseAPIPort;
|
||||
|
@ -895,6 +895,25 @@ bool USRPInput::applySettings(const USRPInputSettings& settings, const QList<QSt
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("gpioDir") || force)
|
||||
{
|
||||
if (m_deviceShared.m_deviceParams->getDevice())
|
||||
{
|
||||
m_deviceShared.m_deviceParams->getDevice()->set_gpio_attr("FP0", "CTRL", ~settings.m_gpioDir, 0xff); // 0 for GPIO, 1 for ATR
|
||||
m_deviceShared.m_deviceParams->getDevice()->set_gpio_attr("FP0", "DDR", settings.m_gpioDir, 0xff); // 0 for input, 1 for output
|
||||
qDebug() << "USRPInput::applySettings: set GPIO dir to " << settings.m_gpioDir;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("gpioPins") || force)
|
||||
{
|
||||
if (m_deviceShared.m_deviceParams->getDevice())
|
||||
{
|
||||
m_deviceShared.m_deviceParams->getDevice()->set_gpio_attr("FP0", "OUT", settings.m_gpioPins, 0xff);
|
||||
qDebug() << "USRPInput::applySettings: set GPIO pins to " << settings.m_gpioPins;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingsKeys.contains("useReverseAPI"))
|
||||
{
|
||||
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||
@ -1162,6 +1181,12 @@ void USRPInput::webapiUpdateDeviceSettings(
|
||||
if (deviceSettingsKeys.contains("transverterMode")) {
|
||||
settings.m_transverterMode = response.getUsrpInputSettings()->getTransverterMode() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioDir")) {
|
||||
settings.m_gpioDir = response.getUsrpInputSettings()->getGpioDir();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioPins")) {
|
||||
settings.m_gpioPins = response.getUsrpInputSettings()->getGpioPins();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
||||
settings.m_useReverseAPI = response.getUsrpInputSettings()->getUseReverseApi() != 0;
|
||||
}
|
||||
@ -1191,6 +1216,8 @@ void USRPInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& respo
|
||||
response.getUsrpInputSettings()->setLpfBw(settings.m_lpfBW);
|
||||
response.getUsrpInputSettings()->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
||||
response.getUsrpInputSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
||||
response.getUsrpInputSettings()->setGpioDir(settings.m_gpioDir);
|
||||
response.getUsrpInputSettings()->setGpioPins(settings.m_gpioPins);
|
||||
response.getUsrpInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
||||
|
||||
if (response.getUsrpInputSettings()->getReverseApiAddress()) {
|
||||
@ -1311,6 +1338,12 @@ void USRPInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKe
|
||||
if (deviceSettingsKeys.contains("transverterMode") || force) {
|
||||
swgUsrpInputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioDir") || force) {
|
||||
swgUsrpInputSettings->setGpioDir(settings.m_gpioDir);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("gpioPins") || force) {
|
||||
swgUsrpInputSettings->setGpioPins(settings.m_gpioPins);
|
||||
}
|
||||
|
||||
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
||||
.arg(settings.m_reverseAPIAddress)
|
||||
|
@ -46,6 +46,8 @@ void USRPInputSettings::resetToDefaults()
|
||||
m_replayLength = 20.0f;
|
||||
m_replayStep = 5.0f;
|
||||
m_replayLoop = false;
|
||||
m_gpioDir = 0;
|
||||
m_gpioPins = 0;
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
m_reverseAPIPort = 8888;
|
||||
@ -76,6 +78,8 @@ QByteArray USRPInputSettings::serialize() const
|
||||
s.writeFloat(18, m_replayLength);
|
||||
s.writeFloat(19, m_replayStep);
|
||||
s.writeBool(20, m_replayLoop);
|
||||
s.writeU32(21, m_gpioDir);
|
||||
s.writeU32(22, m_gpioPins);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -124,6 +128,10 @@ bool USRPInputSettings::deserialize(const QByteArray& data)
|
||||
d.readFloat(18, &m_replayLength, 20.0f);
|
||||
d.readFloat(19, &m_replayStep, 5.0f);
|
||||
d.readBool(20, &m_replayLoop, false);
|
||||
d.readU32(21, &uintval, 0);
|
||||
m_gpioDir = uintval & 0xFF;
|
||||
d.readU32(22, &uintval, 0);
|
||||
m_gpioPins = uintval & 0xFF;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -191,6 +199,12 @@ void USRPInputSettings::applySettings(const QStringList& settingsKeys, const USR
|
||||
if (settingsKeys.contains("replayLoop")) {
|
||||
m_replayLoop = settings.m_replayLoop;
|
||||
}
|
||||
if (settingsKeys.contains("gpioDir")) {
|
||||
m_gpioDir = settings.m_gpioDir;
|
||||
}
|
||||
if (settingsKeys.contains("gpioPins")) {
|
||||
m_gpioPins = settings.m_gpioPins;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI")) {
|
||||
m_useReverseAPI = settings.m_useReverseAPI;
|
||||
}
|
||||
@ -263,6 +277,12 @@ QString USRPInputSettings::getDebugString(const QStringList& settingsKeys, bool
|
||||
if (settingsKeys.contains("replayLoop") || force) {
|
||||
ostr << " m_replayLoop: " << m_replayLoop;
|
||||
}
|
||||
if (settingsKeys.contains("gpioDir") || force) {
|
||||
ostr << " m_gpioDir: " << (int) m_gpioDir;
|
||||
}
|
||||
if (settingsKeys.contains("gpioPins") || force) {
|
||||
ostr << " m_gpioPins: " << (int) m_gpioPins;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI") || force) {
|
||||
ostr << " m_useReverseAPI: " << m_useReverseAPI;
|
||||
}
|
||||
|
@ -52,10 +52,12 @@ struct USRPInputSettings
|
||||
QString m_clockSource;
|
||||
bool m_transverterMode;
|
||||
qint64 m_transverterDeltaFrequency;
|
||||
float m_replayOffset; //!< Replay offset in seconds
|
||||
float m_replayOffset; //!< Replay offset in seconds
|
||||
float m_replayLength; //!< Replay buffer size in seconds
|
||||
float m_replayStep; //!< Replay forward/back step size in seconds
|
||||
bool m_replayLoop; //!< Replay buffer repeatedly without recording new data
|
||||
uint8_t m_gpioDir; //!< GPIO pin direction; 0 ATR (automatic transmit/receive), 1 output
|
||||
uint8_t m_gpioPins; //!< GPIO pins levels for outputs
|
||||
bool m_useReverseAPI;
|
||||
QString m_reverseAPIAddress;
|
||||
uint16_t m_reverseAPIPort;
|
||||
|
Loading…
Reference in New Issue
Block a user