lxi_rb 0.2.6 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.vscode/settings.json +0 -0
- data/CHANGELOG.md +13 -9
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/cog.toml +26 -0
- data/lib/lxi/constants.rb +21 -0
- data/lib/lxi/device.rb +2 -0
- data/lib/lxi/discovery.rb +38 -0
- data/lib/lxi/functions.rb +34 -0
- data/lib/lxi/methods.rb +10 -0
- data/lib/lxi/version.rb +1 -1
- data/lib/lxi_rb.rb +6 -2
- metadata +8 -3
- data/lib/lxi/ffi.rb +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5a2e41d04c72d5f37b67d05dcfd14355b2f58701267eb3383be70a93001029d
|
4
|
+
data.tar.gz: '0259e1a5cd12424ea7b45553f65fe8ba651e530db53411c901577dd5338e70b5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4251c145be1dd444778f4be52552892dd169cc348a7a3fc3f737f4b45c1a2aad871aa6d880280d38a274e25df16ac10f19cdc18bdce5d896bf14ae7f5a3ad67
|
7
|
+
data.tar.gz: eb41b5d33114abf02156ad77fdd3c91a3864a6f3b2e09f6f712344aede5baef9d4ac8e026577a0fd6a3cf22fd2ec99b02c07b168515d06f8fb2a5b26fb5fcc1f
|
File without changes
|
data/CHANGELOG.md
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## [v0.2.6](https://github.com/robcarruthers/lxi_rb/tree/v0.2.6) (2023-05-07)
|
4
4
|
|
5
|
-
|
5
|
+
[Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/v0.2.1...v0.2.6)
|
6
6
|
|
7
|
-
## v0.2.
|
7
|
+
## [v0.2.1](https://github.com/robcarruthers/lxi_rb/tree/v0.2.1) (2023-05-07)
|
8
8
|
|
9
|
-
|
9
|
+
[Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/v0.2.0...v0.2.1)
|
10
10
|
|
11
|
-
|
11
|
+
## [v0.2.0](https://github.com/robcarruthers/lxi_rb/tree/v0.2.0) (2023-05-07)
|
12
12
|
|
13
|
-
|
13
|
+
[Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/v0.1.0...v0.2.0)
|
14
14
|
|
15
|
-
## v0.
|
15
|
+
## [v0.1.0](https://github.com/robcarruthers/lxi_rb/tree/v0.1.0) (2023-05-06)
|
16
16
|
|
17
|
-
|
17
|
+
[Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/1c313adf0923f740888c4a54550b855f3ed3c51a...v0.1.0)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/cog.toml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
from_latest_tag = true
|
2
|
+
ignore_merge_commits = false
|
3
|
+
branch_whitelist = []
|
4
|
+
pre_bump_hooks = []
|
5
|
+
post_bump_hooks = [
|
6
|
+
"rake release"
|
7
|
+
]
|
8
|
+
pre_package_bump_hooks = []
|
9
|
+
post_package_bump_hooks = []
|
10
|
+
tag_prefix = "v"
|
11
|
+
|
12
|
+
[commit_types]
|
13
|
+
|
14
|
+
[changelog]
|
15
|
+
path = "CHANGELOG.md"
|
16
|
+
template = "remote"
|
17
|
+
remote = "github.com"
|
18
|
+
repository = "lxi_rb"
|
19
|
+
owner = "robcarruthers"
|
20
|
+
authors = [
|
21
|
+
{ signature = "Rob Carruthers", username = "robcarruthers" }
|
22
|
+
]
|
23
|
+
|
24
|
+
[bump_profiles]
|
25
|
+
|
26
|
+
[packages]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Lxi
|
2
|
+
# LXI Constants
|
3
|
+
LXI_OK = 0
|
4
|
+
LXI_ERROR = -1
|
5
|
+
|
6
|
+
# VXI11 Discovery Callbacks
|
7
|
+
BroadcastCallback =
|
8
|
+
FFI::Function.new(:void, %i[pointer pointer]) do |address, interface|
|
9
|
+
puts "Broadcast: #{address.read_string}, #{interface.read_string}"
|
10
|
+
end
|
11
|
+
|
12
|
+
DeviceCallback =
|
13
|
+
FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
|
14
|
+
puts "Device: #{address.read_string}, #{id.read_string}"
|
15
|
+
end
|
16
|
+
|
17
|
+
ServiceCallback =
|
18
|
+
FFI::Function.new(:void, %i[pointer pointer pointer int]) do |address, id, service, port|
|
19
|
+
puts "Service: #{address.read_string}, #{id.read_string}, #{service.read_string}, #{port}"
|
20
|
+
end
|
21
|
+
end
|
data/lib/lxi/device.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Lxi
|
2
|
+
module Discovery
|
3
|
+
module_function
|
4
|
+
|
5
|
+
# Search for LXI-11 devices on the specified interface and return hash of devices
|
6
|
+
def devices(timeout: 1000, type: :vxi11)
|
7
|
+
raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
|
8
|
+
|
9
|
+
devices = []
|
10
|
+
device_callback =
|
11
|
+
FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
|
12
|
+
devices << { address: address.read_string, id: id.read_string }
|
13
|
+
end
|
14
|
+
|
15
|
+
info = LxiInfo.new
|
16
|
+
info[:device] = device_callback
|
17
|
+
|
18
|
+
lxi_discover_internal(info, timeout, type)
|
19
|
+
sleep 0.1
|
20
|
+
devices
|
21
|
+
end
|
22
|
+
|
23
|
+
# Discover LXI-11 devices on the LAN
|
24
|
+
def discover_local(timeout: 1000, type: :vxi11)
|
25
|
+
Lxi.init_lxi_session
|
26
|
+
|
27
|
+
info = 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_discover_internal(info, timeout, type)
|
34
|
+
|
35
|
+
puts "Error during discovery: #{result}" if result.negative?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
module Lxi
|
5
|
+
module FFIFunctions
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
ffi_lib '/opt/homebrew/lib/liblxi.dylib'
|
9
|
+
ffi_lib_flags :now, :global
|
10
|
+
|
11
|
+
# Define liblxi structs
|
12
|
+
class LxiInfo < FFI::Struct
|
13
|
+
layout :broadcast,
|
14
|
+
callback(%i[pointer pointer], :void),
|
15
|
+
:device,
|
16
|
+
callback(%i[pointer pointer], :void),
|
17
|
+
:service,
|
18
|
+
callback(%i[pointer pointer pointer int], :void)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Define liblxi enums
|
22
|
+
enum :lxi_protocol_type, %i[vxi11 raw hyslip]
|
23
|
+
enum :lxi_discover_type, %i[vxi11 mdns]
|
24
|
+
|
25
|
+
# Expose liblxi functions
|
26
|
+
attach_function :lxi_init, [], :int
|
27
|
+
attach_function :lxi_discover_internal, :lxi_discover, [LxiInfo.ptr, :int, :lxi_discover_type], :int
|
28
|
+
attach_function :lxi_discover_if, [LxiInfo.ptr, :string, :int, :lxi_discover_type], :int
|
29
|
+
attach_function :lxi_connect, %i[string int string int lxi_protocol_type], :int
|
30
|
+
attach_function :lxi_send, %i[int string int int], :int
|
31
|
+
attach_function :lxi_receive, %i[int pointer int int], :int
|
32
|
+
attach_function :lxi_disconnect, [:int], :int
|
33
|
+
end
|
34
|
+
end
|
data/lib/lxi/methods.rb
ADDED
data/lib/lxi/version.rb
CHANGED
data/lib/lxi_rb.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'lxi/version'
|
4
|
-
require_relative 'lxi/
|
4
|
+
require_relative 'lxi/ffi_functions'
|
5
|
+
require_relative 'lxi/lxi_methods'
|
6
|
+
require_relative 'lxi/lxi_constants'
|
5
7
|
require_relative 'lxi/device'
|
6
8
|
|
7
9
|
module Lxi
|
10
|
+
extend FFIFunctions
|
11
|
+
include LxiMethods
|
12
|
+
|
8
13
|
class Error < StandardError
|
9
14
|
end
|
10
|
-
# Your code goes here...
|
11
15
|
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.2.
|
4
|
+
version: 0.2.12
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -34,14 +34,19 @@ extra_rdoc_files: []
|
|
34
34
|
files:
|
35
35
|
- ".streerc"
|
36
36
|
- ".tool-versions"
|
37
|
+
- ".vscode/settings.json"
|
37
38
|
- CHANGELOG.md
|
38
39
|
- Gemfile
|
39
40
|
- Gemfile.lock
|
40
41
|
- LICENSE.txt
|
41
42
|
- README.md
|
42
43
|
- Rakefile
|
44
|
+
- cog.toml
|
45
|
+
- lib/lxi/constants.rb
|
43
46
|
- lib/lxi/device.rb
|
44
|
-
- lib/lxi/
|
47
|
+
- lib/lxi/discovery.rb
|
48
|
+
- lib/lxi/functions.rb
|
49
|
+
- lib/lxi/methods.rb
|
45
50
|
- lib/lxi/version.rb
|
46
51
|
- lib/lxi_rb.rb
|
47
52
|
- sig/lxi_rb.rbs
|
data/lib/lxi/ffi.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'ffi'
|
3
|
-
|
4
|
-
module Lxi
|
5
|
-
extend FFI::Library
|
6
|
-
|
7
|
-
ffi_lib '/opt/homebrew/lib/liblxi.dylib'
|
8
|
-
ffi_lib_flags :now, :global
|
9
|
-
|
10
|
-
# Define liblxi structs
|
11
|
-
class LxiInfo < FFI::Struct
|
12
|
-
layout :broadcast,
|
13
|
-
callback(%i[pointer pointer], :void),
|
14
|
-
:device,
|
15
|
-
callback(%i[pointer pointer], :void),
|
16
|
-
:service,
|
17
|
-
callback(%i[pointer pointer pointer int], :void)
|
18
|
-
end
|
19
|
-
|
20
|
-
# LXI Constants
|
21
|
-
LXI_OK = 0
|
22
|
-
LXI_ERROR = -1
|
23
|
-
|
24
|
-
# Define liblxi enums
|
25
|
-
enum :lxi_protocol_type, %i[vxi11 raw hyslip]
|
26
|
-
enum :lxi_discover_type, %i[vxi11 mdns]
|
27
|
-
|
28
|
-
# Expose liblxi functions
|
29
|
-
attach_function :lxi_init, [], :int
|
30
|
-
attach_function :lxi_discover_internal, :lxi_discover, [LxiInfo.ptr, :int, :lxi_discover_type], :int
|
31
|
-
attach_function :lxi_discover_if, [LxiInfo.ptr, :string, :int, :lxi_discover_type], :int
|
32
|
-
attach_function :lxi_connect, %i[string int string int lxi_protocol_type], :int
|
33
|
-
attach_function :lxi_send, %i[int string int int], :int
|
34
|
-
attach_function :lxi_receive, %i[int pointer int int], :int
|
35
|
-
attach_function :lxi_disconnect, [:int], :int
|
36
|
-
|
37
|
-
# VXI11 Discovery Callbacks
|
38
|
-
BroadcastCallback =
|
39
|
-
FFI::Function.new(:void, %i[pointer pointer]) do |address, interface|
|
40
|
-
puts "Broadcast: #{address.read_string}, #{interface.read_string}"
|
41
|
-
end
|
42
|
-
|
43
|
-
DeviceCallback =
|
44
|
-
FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
|
45
|
-
puts "Device: #{address.read_string}, #{id.read_string}"
|
46
|
-
end
|
47
|
-
|
48
|
-
ServiceCallback =
|
49
|
-
FFI::Function.new(:void, %i[pointer pointer pointer int]) do |address, id, service, port|
|
50
|
-
puts "Service: #{address.read_string}, #{id.read_string}, #{service.read_string}, #{port}"
|
51
|
-
end
|
52
|
-
|
53
|
-
# Initialise the LXI library
|
54
|
-
def init_lxi_session
|
55
|
-
raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
|
56
|
-
end
|
57
|
-
|
58
|
-
# Search for LXI-11 devices on the specified interface and return hash of devices
|
59
|
-
def self.devices(timeout: 1000, type: :vxi11)
|
60
|
-
raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
|
61
|
-
|
62
|
-
devices = []
|
63
|
-
callback =
|
64
|
-
FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
|
65
|
-
devices << { address: address.read_string, id: id.read_string }
|
66
|
-
end
|
67
|
-
|
68
|
-
info = LxiInfo.new
|
69
|
-
info[:broadcast] = BroadcastCallback
|
70
|
-
info[:device] = callback
|
71
|
-
|
72
|
-
lxi_discover_internal(info, timeout, type)
|
73
|
-
sleep 0.1
|
74
|
-
devices
|
75
|
-
end
|
76
|
-
|
77
|
-
# Discover LXI-11 devices on the LAN
|
78
|
-
def self.discover_local(timeout: 1000, type: :vxi11)
|
79
|
-
init_lxi_session
|
80
|
-
|
81
|
-
info = LxiInfo.new
|
82
|
-
info[:broadcast] = BroadcastCallback
|
83
|
-
info[:device] = DeviceCallback
|
84
|
-
|
85
|
-
puts "Searching for LXI devices - please wait...\n\n"
|
86
|
-
|
87
|
-
result = lxi_discover_internal(info, timeout, type)
|
88
|
-
|
89
|
-
puts "Error during discovery: #{result}" if result.negative?
|
90
|
-
end
|
91
|
-
end
|