SoapySDR: Device.hpp Source File

| SoapySDR 0.7.2-ARCH Vendor and platform neutral SDR interface library

Device.hpp
Go to the documentation of this file.
1
12 #pragma once
13 #include <SoapySDR/Config.hpp>
14 #include <SoapySDR/Types.hpp>
15 #include <SoapySDR/Constants.h>
16 #include <SoapySDR/Errors.h>
17 #include <vector>
18 #include <string>
19 #include <complex>
20 #include <cstddef> //size_t
21
22 namespace SoapySDR
23 {
24
26 class Stream;
27
31 class SOAPY_SDR_API Device
32 {
33 public:
34
36 virtual ~Device(void);
37
43 static KwargsList enumerate(const Kwargs &args = Kwargs());
44
51 static KwargsList enumerate(const std::string &args);
52
62 static Device *make(const Kwargs &args = Kwargs());
63
73 static Device *make(const std::string &args);
74
80 static void unmake(Device *device);
81
82 /*******************************************************************
83 * Parallel support
84 ******************************************************************/
85
94 static std::vector<Device *> make(const KwargsList &argsList);
95
103 static void unmake(const std::vector<Device *> &devices);
104
105 /*******************************************************************
106 * Identification API
107 ******************************************************************/
108
114 virtual std::string getDriverKey(void) const;
115
121 virtual std::string getHardwareKey(void) const;
122
130 virtual Kwargs getHardwareInfo(void) const;
131
132 /*******************************************************************
133 * Channels API
134 ******************************************************************/
135
142 virtual void setFrontendMapping(const int direction, const std::string &mapping);
143
149 virtual std::string getFrontendMapping(const int direction) const;
150
154 virtual size_t getNumChannels(const int direction) const;
155
166 virtual Kwargs getChannelInfo(const int direction, const size_t channel) const;
167
174 virtual bool getFullDuplex(const int direction, const size_t channel) const;
175
176 /*******************************************************************
177 * Stream API
178 ******************************************************************/
179
186 virtual std::vector<std::string> getStreamFormats(const int direction, const size_t channel) const;
187
197 virtual std::string getNativeStreamFormat(const int direction, const size_t channel, double &fullScale) const;
198
205 virtual ArgInfoList getStreamArgsInfo(const int direction, const size_t channel) const;
206
256 virtual Stream *setupStream(
257 const int direction,
258 const std::string &format,
259 const std::vector<size_t> &channels = std::vector<size_t>(),
260 const Kwargs &args = Kwargs());
261
267 virtual void closeStream(Stream *stream);
268
278 virtual size_t getStreamMTU(Stream *stream) const;
279
297 virtual int activateStream(
298 Stream *stream,
299 const int flags = 0,
300 const long long timeNs = 0,
301 const size_t numElems = 0);
302
317 virtual int deactivateStream(
318 Stream *stream,
319 const int flags = 0,
320 const long long timeNs = 0);
321
341 virtual int readStream(
342 Stream *stream,
343 void * const *buffs,
344 const size_t numElems,
345 int &flags,
346 long long &timeNs,
347 const long timeoutUs = 100000);
348
368 virtual int writeStream(
369 Stream *stream,
370 const void * const *buffs,
371 const size_t numElems,
372 int &flags,
373 const long long timeNs = 0,
374 const long timeoutUs = 100000);
375
396 virtual int readStreamStatus(
397 Stream *stream,
398 size_t &chanMask,
399 int &flags,
400 long long &timeNs,
401 const long timeoutUs = 100000);
402
403 /*******************************************************************
404 * Direct buffer access API
405 ******************************************************************/
406
416 virtual size_t getNumDirectAccessBuffers(Stream *stream);
417
431 virtual int getDirectAccessBufferAddrs(Stream *stream, const size_t handle, void **buffs);
432
453 virtual int acquireReadBuffer(
454 Stream *stream,
455 size_t &handle,
456 const void **buffs,
457 int &flags,
458 long long &timeNs,
459 const long timeoutUs = 100000);
460
468 virtual void releaseReadBuffer(
469 Stream *stream,
470 const size_t handle);
471
490 virtual int acquireWriteBuffer(
491 Stream *stream,
492 size_t &handle,
493 void **buffs,
494 const long timeoutUs = 100000);
495
511 virtual void releaseWriteBuffer(
512 Stream *stream,
513 const size_t handle,
514 const size_t numElems,
515 int &flags,
516 const long long timeNs = 0);
517
518 /*******************************************************************
519 * Antenna API
520 ******************************************************************/
521
528 virtual std::vector<std::string> listAntennas(const int direction, const size_t channel) const;
529
536 virtual void setAntenna(const int direction, const size_t channel, const std::string &name);
537
544 virtual std::string getAntenna(const int direction, const size_t channel) const;
545
546 /*******************************************************************
547 * Frontend corrections API
548 ******************************************************************/
549
556 virtual bool hasDCOffsetMode(const int direction, const size_t channel) const;
557
564 virtual void setDCOffsetMode(const int direction, const size_t channel, const bool automatic);
565
572 virtual bool getDCOffsetMode(const int direction, const size_t channel) const;
573
580 virtual bool hasDCOffset(const int direction, const size_t channel) const;
581
588 virtual void setDCOffset(const int direction, const size_t channel, const std::complex<double> &offset);
589
596 virtual std::complex<double> getDCOffset(const int direction, const size_t channel) const;
597
604 virtual bool hasIQBalance(const int direction, const size_t channel) const;
605
612 virtual void setIQBalance(const int direction, const size_t channel, const std::complex<double> &balance);
613
620 virtual std::complex<double> getIQBalance(const int direction, const size_t channel) const;
621
628 virtual bool hasFrequencyCorrection(const int direction, const size_t channel) const;
629
636 virtual void setFrequencyCorrection(const int direction, const size_t channel, const double value);
637
644 virtual double getFrequencyCorrection(const int direction, const size_t channel) const;
645
646 /*******************************************************************
647 * Gain API
648 ******************************************************************/
649
657 virtual std::vector<std::string> listGains(const int direction, const size_t channel) const;
658
665 virtual bool hasGainMode(const int direction, const size_t channel) const;
666
673 virtual void setGainMode(const int direction, const size_t channel, const bool automatic);
674
681 virtual bool getGainMode(const int direction, const size_t channel) const;
682
690 virtual void setGain(const int direction, const size_t channel, const double value);
691
699 virtual void setGain(const int direction, const size_t channel, const std::string &name, const double value);
700
707 virtual double getGain(const int direction, const size_t channel) const;
708
716 virtual double getGain(const int direction, const size_t channel, const std::string &name) const;
717
724 virtual Range getGainRange(const int direction, const size_t channel) const;
725
733 virtual Range getGainRange(const int direction, const size_t channel, const std::string &name) const;
734
735 /*******************************************************************
736 * Frequency API
737 ******************************************************************/
738
766 virtual void setFrequency(const int direction, const size_t channel, const double frequency, const Kwargs &args = Kwargs());
767
784 virtual void setFrequency(const int direction, const size_t channel, const std::string &name, const double frequency, const Kwargs &args = Kwargs());
785
794 virtual double getFrequency(const int direction, const size_t channel) const;
795
803 virtual double getFrequency(const int direction, const size_t channel, const std::string &name) const;
804
812 virtual std::vector<std::string> listFrequencies(const int direction, const size_t channel) const;
813
820 virtual RangeList getFrequencyRange(const int direction, const size_t channel) const;
821
829 virtual RangeList getFrequencyRange(const int direction, const size_t channel, const std::string &name) const;
830
837 virtual ArgInfoList getFrequencyArgsInfo(const int direction, const size_t channel) const;
838
839 /*******************************************************************
840 * Sample Rate API
841 ******************************************************************/
842
849 virtual void setSampleRate(const int direction, const size_t channel, const double rate);
850
857 virtual double getSampleRate(const int direction, const size_t channel) const;
858
866 virtual std::vector<double> listSampleRates(const int direction, const size_t channel) const;
867
874 virtual RangeList getSampleRateRange(const int direction, const size_t channel) const;
875
876 /*******************************************************************
877 * Bandwidth API
878 ******************************************************************/
879
886 virtual void setBandwidth(const int direction, const size_t channel, const double bw);
887
894 virtual double getBandwidth(const int direction, const size_t channel) const;
895
903 virtual std::vector<double> listBandwidths(const int direction, const size_t channel) const;
904
911 virtual RangeList getBandwidthRange(const int direction, const size_t channel) const;
912
913 /*******************************************************************
914 * Clocking API
915 ******************************************************************/
916
921 virtual void setMasterClockRate(const double rate);
922
927 virtual double getMasterClockRate(void) const;
928
933 virtual RangeList getMasterClockRates(void) const;
934
939 virtual std::vector<std::string> listClockSources(void) const;
940
945 virtual void setClockSource(const std::string &source);
946
951 virtual std::string getClockSource(void) const;
952
953 /*******************************************************************
954 * Time API
955 ******************************************************************/
956
961 virtual std::vector<std::string> listTimeSources(void) const;
962
967 virtual void setTimeSource(const std::string &source);
968
973 virtual std::string getTimeSource(void) const;
974
980 virtual bool hasHardwareTime(const std::string &what = "") const;
981
988 virtual long long getHardwareTime(const std::string &what = "") const;
989
996 virtual void setHardwareTime(const long long timeNs, const std::string &what = "");
997
1006 virtual void setCommandTime(const long long timeNs, const std::string &what = "");
1007
1008 /*******************************************************************
1009 * Sensor API
1010 ******************************************************************/
1011
1017 virtual std::vector<std::string> listSensors(void) const;
1018
1025 virtual ArgInfo getSensorInfo(const std::string &key) const;
1026
1034 virtual std::string readSensor(const std::string &key) const;
1035
1043 virtual std::vector<std::string> listSensors(const int direction, const size_t channel) const;
1044
1053 virtual ArgInfo getSensorInfo(const int direction, const size_t channel, const std::string &key) const;
1054
1064 virtual std::string readSensor(const int direction, const size_t channel, const std::string &key) const;
1065
1066 /*******************************************************************
1067 * Register API
1068 ******************************************************************/
1069
1074 virtual std::vector<std::string> listRegisterInterfaces(void) const;
1075
1084 virtual void writeRegister(const std::string &name, const unsigned addr, const unsigned value);
1085
1092 virtual unsigned readRegister(const std::string &name, const unsigned addr) const;
1093
1102 virtual void writeRegister(const unsigned addr, const unsigned value);
1103
1110 virtual unsigned readRegister(const unsigned addr) const;
1111
1120 virtual void writeRegisters(const std::string &name, const unsigned addr, const std::vector<unsigned> &value);
1121
1129 virtual std::vector<unsigned> readRegisters(const std::string &name, const unsigned addr, const size_t length) const;
1130
1131 /*******************************************************************
1132 * Settings API
1133 ******************************************************************/
1134
1139 virtual ArgInfoList getSettingInfo(void) const;
1140
1147 virtual void writeSetting(const std::string &key, const std::string &value);
1148
1154 virtual std::string readSetting(const std::string &key) const;
1155
1162 virtual ArgInfoList getSettingInfo(const int direction, const size_t channel) const;
1163
1172 virtual void writeSetting(const int direction, const size_t channel, const std::string &key, const std::string &value);
1173
1181 virtual std::string readSetting(const int direction, const size_t channel, const std::string &key) const;
1182
1183 /*******************************************************************
1184 * GPIO API
1185 ******************************************************************/
1186
1190 virtual std::vector<std::string> listGPIOBanks(void) const;
1191
1197 virtual void writeGPIO(const std::string &bank, const unsigned value);
1198
1205 virtual void writeGPIO(const std::string &bank, const unsigned value, const unsigned mask);
1206
1212 virtual unsigned readGPIO(const std::string &bank) const;
1213
1220 virtual void writeGPIODir(const std::string &bank, const unsigned dir);
1221
1229 virtual void writeGPIODir(const std::string &bank, const unsigned dir, const unsigned mask);
1230
1237 virtual unsigned readGPIODir(const std::string &bank) const;
1238
1239 /*******************************************************************
1240 * I2C API
1241 ******************************************************************/
1242
1250 virtual void writeI2C(const int addr, const std::string &data);
1251
1260 virtual std::string readI2C(const int addr, const size_t numBytes);
1261
1262 /*******************************************************************
1263 * SPI API
1264 ******************************************************************/
1265
1280 virtual unsigned transactSPI(const int addr, const unsigned data, const size_t numBits);
1281
1282 /*******************************************************************
1283 * UART API
1284 ******************************************************************/
1285
1290 virtual std::vector<std::string> listUARTs(void) const;
1291
1299 virtual void writeUART(const std::string &which, const std::string &data);
1300
1309 virtual std::string readUART(const std::string &which, const long timeoutUs = 100000) const;
1310
1311 };
1312
1313 };
SOAPY_SDR_API
#define SOAPY_SDR_API
Definition: Config.h:41
SoapySDR::Range
Definition: Types.hpp:42
SoapySDR::Device
Definition: Device.hpp:31
SoapySDR::RangeList
std::vector< Range > RangeList
Definition: Types.hpp:70
SoapySDR
Definition: ConverterPrimitives.hpp:14
Constants.h
SoapySDR::ArgInfoList
std::vector< ArgInfo > ArgInfoList
Definition: Types.hpp:127
Config.hpp
SoapySDR::Kwargs
std::map< std::string, std::string > Kwargs
Typedef for a dictionary of key-value string arguments.
Definition: Types.hpp:22
Errors.h
SoapySDR::KwargsList
std::vector< Kwargs > KwargsList
Typedef for a list of key-word dictionaries.
Definition: Types.hpp:37
SoapySDR::ArgInfo
Definition: Types.hpp:75
Types.hpp