Class: HackRF::Device::Radio
- Inherits:
-
Object
- Object
- HackRF::Device::Radio
- Defined in:
- lib/hackrf/device.rb
Instance Attribute Summary collapse
-
#max2837 ⇒ Object
readonly
Returns the value of attribute max2837.
-
#ptr ⇒ Object
readonly
Returns the value of attribute ptr.
-
#rffc5071 ⇒ Object
readonly
Returns the value of attribute rffc5071.
-
#si5351c ⇒ Object
readonly
Returns the value of attribute si5351c.
-
#spiflash ⇒ Object
readonly
Returns the value of attribute spiflash.
Class Method Summary collapse
Instance Method Summary collapse
- #amp=(value) ⇒ Object
- #antenna=(value) ⇒ Object
- #baseband_filter_bandwidth=(bandwidth) ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #frequency=(freq) ⇒ Object (also: #freq=)
-
#initialize(ptr) ⇒ Radio
constructor
A new instance of Radio.
- #lna_gain=(gain) ⇒ Object
- #rx(&block) ⇒ Object
- #sample_rate=(rate) ⇒ Object
- #stop ⇒ Object
- #streaming? ⇒ Boolean
- #to_ptr ⇒ Object
- #tx(&block) ⇒ Object
- #txvga_gain=(gain) ⇒ Object
- #vga_gain=(gain) ⇒ Object
Constructor Details
#initialize(ptr) ⇒ Radio
Returns a new instance of Radio.
11 12 13 14 15 16 17 18 19 |
# File 'lib/hackrf/device.rb', line 11 def initialize(ptr) @ptr = ptr @mode = nil @spiflash = HackRF::Internals::SPIFlash.new(self) @max2837 = HackRF::Internals::MAX2837.new(self) @si5351c = HackRF::Internals::Si5351C.new(self) @rffc5071 = HackRF::Internals::RFFC5071.new(self) end |
Instance Attribute Details
#max2837 ⇒ Object (readonly)
Returns the value of attribute max2837.
9 10 11 |
# File 'lib/hackrf/device.rb', line 9 def max2837 @max2837 end |
#ptr ⇒ Object (readonly)
Returns the value of attribute ptr.
9 10 11 |
# File 'lib/hackrf/device.rb', line 9 def ptr @ptr end |
#rffc5071 ⇒ Object (readonly)
Returns the value of attribute rffc5071.
9 10 11 |
# File 'lib/hackrf/device.rb', line 9 def rffc5071 @rffc5071 end |
#si5351c ⇒ Object (readonly)
Returns the value of attribute si5351c.
9 10 11 |
# File 'lib/hackrf/device.rb', line 9 def si5351c @si5351c end |
#spiflash ⇒ Object (readonly)
Returns the value of attribute spiflash.
9 10 11 |
# File 'lib/hackrf/device.rb', line 9 def spiflash @spiflash end |
Class Method Details
.finalize(device) ⇒ Object
36 37 38 |
# File 'lib/hackrf/device.rb', line 36 def self.finalize(device) HackRF end |
.open ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hackrf/device.rb', line 21 def self.open ptr = FFI::MemoryPointer.new(:pointer) HackRF.hackrf_open(ptr) device = new(ptr.read_pointer) if block_given? yield device device.close else return device end end |
Instance Method Details
#amp=(value) ⇒ Object
54 55 56 |
# File 'lib/hackrf/device.rb', line 54 def amp=(value) HackRF.hackrf_set_amp_enable(self,value) end |
#antenna=(value) ⇒ Object
70 71 72 |
# File 'lib/hackrf/device.rb', line 70 def antenna=(value) HackRF.hackrf_set_antenna_enable(self,value) end |
#baseband_filter_bandwidth=(bandwidth) ⇒ Object
40 41 42 |
# File 'lib/hackrf/device.rb', line 40 def baseband_filter_bandwidth=(bandwidth) HackRF.hackrf_set_baseband_filter_bandwidth(self,bandwidth) end |
#close ⇒ Object
109 110 111 112 113 114 |
# File 'lib/hackrf/device.rb', line 109 def close ret = HackRF.hackrf_close(self) @ptr = nil return ret end |
#closed? ⇒ Boolean
105 106 107 |
# File 'lib/hackrf/device.rb', line 105 def closed? @ptr.nil? end |
#frequency=(freq) ⇒ Object Also known as: freq=
44 45 46 |
# File 'lib/hackrf/device.rb', line 44 def frequency=(freq) HackRF.hackrf_set_freq(self,freq) end |
#lna_gain=(gain) ⇒ Object
58 59 60 |
# File 'lib/hackrf/device.rb', line 58 def lna_gain=(gain) HackRF.hackrf_set_lna_gain(self,gain) end |
#rx(&block) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/hackrf/device.rb', line 78 def rx(&block) @mode = :rx @rx_callback = callback(&block) HackRF.hackrf_start_rx(self,@rx_callback,nil) @rx_callback = nil @mode = nil end |
#sample_rate=(rate) ⇒ Object
50 51 52 |
# File 'lib/hackrf/device.rb', line 50 def sample_rate=(rate) HackRF.hackrf_set_sample_rate(self,rate) end |
#stop ⇒ Object
98 99 100 101 102 103 |
# File 'lib/hackrf/device.rb', line 98 def stop case @mode when :rx then HackRF.hackrf_stop_rx(self) when :tx then HackRF.hackrf_stop_tx(self) end end |
#streaming? ⇒ Boolean
74 75 76 |
# File 'lib/hackrf/device.rb', line 74 def streaming? HackRF.hackrf_is_streaming(self) == :true end |
#to_ptr ⇒ Object
116 117 118 |
# File 'lib/hackrf/device.rb', line 116 def to_ptr @ptr end |
#tx(&block) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/hackrf/device.rb', line 88 def tx(&block) @mode = :tx @tx_callback = callback(&block) HackRF.hackrf_start_tx(self,@tx_callback,nil) @tx_callback = nil @mode = nil end |
#txvga_gain=(gain) ⇒ Object
66 67 68 |
# File 'lib/hackrf/device.rb', line 66 def txvga_gain=(gain) HackRF.hackrf_set_txvga_gain(self,gain) end |
#vga_gain=(gain) ⇒ Object
62 63 64 |
# File 'lib/hackrf/device.rb', line 62 def vga_gain=(gain) HackRF.hackrf_set_vga_gain(self,gain) end |