lxi_rb 0.7.3 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06ae58333488267474e2ec65169d809368c88d64ada4ae52e672b25fc5168b56
4
- data.tar.gz: 2a6bd3a037bd50ae1f116f3371f4b3df42c2dfbf0dbfc74b180a90f8ab330b3a
3
+ metadata.gz: 6f801e3f63346578e5c2479fe2a6f4b895399c85fc6199b07d45ad409360b96a
4
+ data.tar.gz: 6ed11628035314d04742d2a330894fc05fc681027feb055112332fcaabb937aa
5
5
  SHA512:
6
- metadata.gz: '016579af70c463e8a41a65d51497fdc5563473fe4620190a81eb4a37ca6d23261e15d5c0d2bc522725f277e3c1aee33575db4a0616d992613aa97173d0090ed4'
7
- data.tar.gz: 28a4bc31a7e6d5c8363182c856139ed17b7978c5da390ae47dc0f944ef75219fd4aa76d8a47689994380394395c37a21a2fb715cfba601f8f267fe9c467b9fec
6
+ metadata.gz: 9688397f4e0203e27f7f4f1a3a16fbd069c5a3857ae5eba34806791539dbb5133c42e9271cd0c98fc90a23b11b270173d81684423e05d96c35c36de796fdec1f
7
+ data.tar.gz: 1190ad3fd91b459034ed94dd044579520c34b08a35fb85cffea6d33ffe797e88b7fbc37fcb5a9f4280d2de1c6561ccc70eb43433f41e9274865574a2695ab192
data/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@
4
4
  All notable changes to this project will be documented in this file.
5
5
 
6
6
  - - -
7
+ ## [v0.8.1](https://github.com/robcarruthers/lxi_rb/compare/v0.8.0..v0.8.1) - 2023-05-19
8
+ #### Miscellaneous Tasks
9
+ - **(bundle)** Update - ([eb95319](https://github.com/robcarruthers/lxi_rb/commit/eb95319bb48eb5f6c131f3e658ba1df6c3a0f4fb)) - [@robcarruthers](https://github.com/robcarruthers)
10
+
11
+ - - -
12
+
13
+ ## [v0.8.0](https://github.com/robcarruthers/lxi_rb/compare/v0.7.3..v0.8.0) - 2023-05-19
14
+ #### Features
15
+ - **(examples)** Add scpi example - ([1d3ce45](https://github.com/robcarruthers/lxi_rb/commit/1d3ce45f199ae50fc2fded3fc2741aa132e5e4ac)) - [@robcarruthers](https://github.com/robcarruthers)
16
+ - **(examples)** Add discover example - ([9b51eff](https://github.com/robcarruthers/lxi_rb/commit/9b51eff22d13261525a68bd7e95064a7e7567f1b)) - [@robcarruthers](https://github.com/robcarruthers)
17
+ #### Refactoring
18
+ - **(discovery)** Refine output. Fix specs. - ([4a73630](https://github.com/robcarruthers/lxi_rb/commit/4a736308a2a149ce360d351a24d58d9803ad3ad1)) - [@robcarruthers](https://github.com/robcarruthers)
19
+
20
+ - - -
21
+
7
22
  ## [v0.7.3](https://github.com/robcarruthers/lxi_rb/compare/v0.7.2..v0.7.3) - 2023-05-15
8
23
  #### Refactoring
9
24
  - **(gemspec)** Update Gemfile with dev group - ([b5e5cdd](https://github.com/robcarruthers/lxi_rb/commit/b5e5cdd8d7c0517e980700b43c4080ea03bf8467)) - [@robcarruthers](https://github.com/robcarruthers)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lxi_rb (0.7.2)
4
+ lxi_rb (0.8.1)
5
5
  ffi (~> 1.15)
6
6
 
7
7
  GEM
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+ require 'ffi'
3
+ require_relative '../lib/lxi_rb'
4
+
5
+ # Discovery Callbacks
6
+ BroadcastCallback =
7
+ FFI::Function.new(:void, %i[pointer pointer]) do |address, interface|
8
+ puts("Broadcast: #{address.read_string}, #{interface.read_string}\n")
9
+ end
10
+
11
+ DeviceCallback =
12
+ FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
13
+ puts("\n Found #{id.read_string} on address #{address.read_string}\n lxi service on port 80")
14
+ end
15
+
16
+ ServiceCallback =
17
+ FFI::Function.new(:void, %i[pointer pointer pointer int]) do |address, id, service, port|
18
+ puts("Service: #{address.read_string}, #{id.read_string}, #{service.read_string}, #{port}")
19
+ end
20
+
21
+ # Discover LXI-11 devices on the LAN
22
+ timeout_ms = 1000
23
+ # Search types, Bonjour :mdns or VXI-11 :vxi11 (default)
24
+ search_type = :vxi11
25
+
26
+ Lxi.init_lxi_session
27
+ info = Lxi::FFIFunctions::LxiInfo.new
28
+ info[:broadcast] = BroadcastCallback
29
+ info[:device] = DeviceCallback
30
+
31
+ puts("Searching for LXI devices - please wait...\n\n")
32
+
33
+ result = Lxi.lxi_discover_internal(info, timeout_ms, search_type)
34
+ puts("Error during discovery: #{result}") if result.negative?
data/examples/scpi.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../lib/lxi_rb'
3
+
4
+ # Initialize LXI library
5
+ Lxi.init_lxi_session
6
+
7
+ # Lxi.search will return an Array of device identifiers and IP addresses
8
+ devices = Lxi.search
9
+ abort 'No devices found' if devices.nil? || devices.empty?
10
+
11
+ # Create a new LXI device
12
+ device_ip_address = devices[0][:address]
13
+ device_type = :vxi11
14
+ command = '*IDN?'
15
+
16
+ Lxi::Device.new(device_ip_address, device_type) do |device|
17
+ device.send command
18
+ sleep 0.05
19
+ puts device.read 512
20
+ end
data/lib/lxi/discovery.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Lxi
3
- # Search for LXI-11 instruments on the network and return hash of instruments
4
- def self.discover(timeout: 1000, type: :vxi11)
3
+ # Search for LXI-11 instruments on the network and return array of instruments
4
+ def self.search(timeout: 1000, type: :vxi11)
5
5
  raise(Error, 'LXI Library Initialisation Error') unless lxi_init == LXI_OK
6
6
 
7
7
  devices = []
@@ -13,13 +13,19 @@ module Lxi
13
13
  info = FFIFunctions::LxiInfo.new
14
14
  info[:device] = device_callback
15
15
 
16
- lxi_discover_internal(info, timeout, type)
17
- sleep(0.1)
16
+ result = lxi_discover_internal(info, timeout, type)
17
+ raise(Error, "Discovery error: #{result}") unless result == LXI_OK
18
+
19
+ sleep(0.5)
18
20
  devices
19
21
  end
20
22
 
23
+ def self.asdf
24
+ puts 'asdf'
25
+ end
26
+
21
27
  # Discover LXI-11 devices on the LAN
22
- def self.search(timeout: 1000, type: :vxi11)
28
+ def self.discover(timeout: 1000, type: :vxi11)
23
29
  Lxi.init_lxi_session
24
30
 
25
31
  info = FFIFunctions::LxiInfo.new
data/lib/lxi/functions.rb CHANGED
@@ -18,6 +18,19 @@ module Lxi
18
18
  callback(%i[pointer pointer pointer int], :void)
19
19
  end
20
20
 
21
+ class LxiBrowseInfo < FFI::Struct
22
+ layout :broadcast,
23
+ callback(%i[pointer pointer], :void),
24
+ :device,
25
+ callback(%i[pointer pointer], :void),
26
+ :service,
27
+ callback(%i[pointer pointer pointer int], :void),
28
+ :servicename,
29
+ :string,
30
+ :regtype,
31
+ :string
32
+ end
33
+
21
34
  # Define liblxi enums
22
35
  enum :lxi_protocol_type, %i[vxi11 raw hyslip]
23
36
  enum :lxi_discover_type, %i[vxi11 mdns]
data/lib/lxi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lxi
4
- VERSION = '0.7.3'
4
+ VERSION = '0.8.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lxi_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Carruthers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-15 00:00:00.000000000 Z
11
+ date: 2023-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -41,6 +41,8 @@ files:
41
41
  - LICENSE.txt
42
42
  - README.md
43
43
  - Rakefile
44
+ - examples/discover.rb
45
+ - examples/scpi.rb
44
46
  - lib/lxi/callbacks.rb
45
47
  - lib/lxi/constants.rb
46
48
  - lib/lxi/device.rb