lxi_rb 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/examples/discover.rb +34 -0
- data/examples/scpi.rb +20 -0
- data/lib/lxi/discovery.rb +11 -5
- data/lib/lxi/functions.rb +13 -0
- data/lib/lxi/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b847376736132429d609f86fd63bd6193bf5ad9448d51c5df87f68c3c53b916
|
4
|
+
data.tar.gz: f9640603dce7a800d0ef0fdf107b5c0f2271daa1f978329b3650b5d87c238941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55209a7f2b3fc12db1f316f9c38ac6b1013b3d7f429f636e9bbc0707ed09e217387eb55afa9959a884b005bcd2a87c1fd23d1097fbb62246f81e8ef77c1668ee
|
7
|
+
data.tar.gz: 14f8e2a2e194e4a409292a252fa133d735b8788d8c38d9d05bdef82ccffeb834225fb1e3c8cc46a0fd49368e7746b8249f38f063b473ff017f6033cb7c2b6333
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,15 @@
|
|
4
4
|
All notable changes to this project will be documented in this file.
|
5
5
|
|
6
6
|
- - -
|
7
|
+
## [v0.8.0](https://github.com/robcarruthers/lxi_rb/compare/v0.7.3..v0.8.0) - 2023-05-19
|
8
|
+
#### Features
|
9
|
+
- **(examples)** Add scpi example - ([1d3ce45](https://github.com/robcarruthers/lxi_rb/commit/1d3ce45f199ae50fc2fded3fc2741aa132e5e4ac)) - [@robcarruthers](https://github.com/robcarruthers)
|
10
|
+
- **(examples)** Add discover example - ([9b51eff](https://github.com/robcarruthers/lxi_rb/commit/9b51eff22d13261525a68bd7e95064a7e7567f1b)) - [@robcarruthers](https://github.com/robcarruthers)
|
11
|
+
#### Refactoring
|
12
|
+
- **(discovery)** Refine output. Fix specs. - ([4a73630](https://github.com/robcarruthers/lxi_rb/commit/4a736308a2a149ce360d351a24d58d9803ad3ad1)) - [@robcarruthers](https://github.com/robcarruthers)
|
13
|
+
|
14
|
+
- - -
|
15
|
+
|
7
16
|
## [v0.7.3](https://github.com/robcarruthers/lxi_rb/compare/v0.7.2..v0.7.3) - 2023-05-15
|
8
17
|
#### Refactoring
|
9
18
|
- **(gemspec)** Update Gemfile with dev group - ([b5e5cdd](https://github.com/robcarruthers/lxi_rb/commit/b5e5cdd8d7c0517e980700b43c4080ea03bf8467)) - [@robcarruthers](https://github.com/robcarruthers)
|
data/Gemfile.lock
CHANGED
@@ -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
|
4
|
-
def self.
|
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
|
-
|
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.
|
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
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.
|
4
|
+
version: 0.8.0
|
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-
|
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
|