lib/lxi/ffi.rb in lxi_rb-0.2.3 vs lib/lxi/ffi.rb in lxi_rb-0.2.6
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
require 'ffi'
module Lxi
extend FFI::Library
@@ -53,11 +54,11 @@
def init_lxi_session
raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
end
# Search for LXI-11 devices on the specified interface and return hash of devices
- def self.devices(interface: 'en0', timeout: 1000, type: :vxi11)
+ def self.devices(timeout: 1000, type: :vxi11)
raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
devices = []
callback =
FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
@@ -66,14 +67,12 @@
info = LxiInfo.new
info[:broadcast] = BroadcastCallback
info[:device] = callback
- result = lxi_discover_internal(info, timeout, type)
+ lxi_discover_internal(info, timeout, type)
sleep 0.1
- puts "result: #{result}"
- puts "info: #{info[:device].read_string}"
devices
end
# Discover LXI-11 devices on the LAN
def self.discover_local(timeout: 1000, type: :vxi11)
@@ -85,8 +84,8 @@
puts "Searching for LXI devices - please wait...\n\n"
result = lxi_discover_internal(info, timeout, type)
- puts "Error during discovery: #{result}" if result < 0
+ puts "Error during discovery: #{result}" if result.negative?
end
end