Module: HDHomeRun
- Defined in:
- lib/ffi-hdhomerun.rb
Overview
Documentation can be found under HDHomeRun::Tuner
Defined Under Namespace
Classes: ConnectionError, Device, InvalidDeviceIdError, InvalidTunerError, LockExpiredError, Tuner, TunerLockedError, UnknownVariableError, UnsupportedVersion
Constant Summary collapse
- VERSION =
"0.6"
- ERROR_STRING_UNKNOWN_VARIABLE =
"ERROR: unknown getset variable"
- ERROR_REGEX_TUNER_LOCKED =
/^ERROR: resource locked by /
- ERROR_STRING_TUNER_LOCK_EXPIRED =
"ERROR: lock no longer held"
- MAX_TUNERS =
8
Class Method Summary collapse
-
.discover ⇒ Object
Discover tuners on the network.
-
.tuners ⇒ Object
Return an array of all discoverable Tuners.
Class Method Details
.discover ⇒ Object
Discover tuners on the network.
Warning: This function will return invalid data
Returns an array of hashes with the following fields:
:id -- device id (string)
:type -- device type (int)
:ip_addr -- ip address (IPAddr)
:tuner_count -- number of tuners on the device (int)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ffi-hdhomerun.rb', line 33 def self.discover results_ptr = FFI::MemoryPointer.new( FFI::HDHomeRun::DiscoverDevice, 64) count = FFI::HDHomeRun::discover_find_devices_custom( FFI::HDHomeRun::DEVICE_ID_WILDCARD, FFI::HDHomeRun::DEVICE_TYPE_TUNER, FFI::HDHomeRun::DEVICE_ID_WILDCARD, results_ptr, 64) raise "error sending discover request" if count < 0 # Loop through the results and construct an array of hashes # as our output. (0..count-1).map do |i| # construct our hash p = FFI::HDHomeRun::DiscoverDevice.new(results_ptr[i]) out = { :id => "%08X" % p.device_id, :type => p.device_type, :ip_addr => p.ip_addr } # Some versions of the library don't support tuner_count out.merge!({ :tuner_count => p.tuner_count }) if p.respond_to? :tuner_count out end end |
.tuners ⇒ Object
Return an array of all discoverable Tuners.
63 64 65 66 67 68 69 70 71 |
# File 'lib/ffi-hdhomerun.rb', line 63 def self.tuners raise UnsupportedVersion if ENV['FFI_HDHOMERUN_OLD_DEVICE_STRUCT'] discover.map do |data| data[:tuner_count].times.map do |tuner| Tuner.new(data.merge(:tuner => tuner)) end end.flatten end |