lxi_rb 0.2.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e72bc52c850f4d1904dd30130293eda4a68c004f201026f7b90f967980820db
4
- data.tar.gz: bf7cf567edc90d38f1a295ffee34b7ac1eef04a564b5ebca1003995c9381fbea
3
+ metadata.gz: e5a2e41d04c72d5f37b67d05dcfd14355b2f58701267eb3383be70a93001029d
4
+ data.tar.gz: '0259e1a5cd12424ea7b45553f65fe8ba651e530db53411c901577dd5338e70b5'
5
5
  SHA512:
6
- metadata.gz: 56dd416d6c473a111929c8b69dcf12f8c4c0a71b65f3c3b1f8d37333022ceb902f6228d691fb8dbfb4884dcf284a6f9c07c9da8892e9eb8fcd038b15e75d959c
7
- data.tar.gz: 44fea582e9a62f9f3c1c3eadc89838d471e1d9649c3627ad837d49a5e4ef5c5caf48036626f82782da307451635c0452de32f1d9eaf49820f44ea0b371baa896
6
+ metadata.gz: e4251c145be1dd444778f4be52552892dd169cc348a7a3fc3f737f4b45c1a2aad871aa6d880280d38a274e25df16ac10f19cdc18bdce5d896bf14ae7f5a3ad67
7
+ data.tar.gz: eb41b5d33114abf02156ad77fdd3c91a3864a6f3b2e09f6f712344aede5baef9d4ac8e026577a0fd6a3cf22fd2ec99b02c07b168515d06f8fb2a5b26fb5fcc1f
File without changes
data/CHANGELOG.md CHANGED
@@ -1,11 +1,21 @@
1
- ## v0.2.3 (2023-05-07)
2
- ## v0.2.2 (2023-05-07)
3
- ## v0.2.1 (2023-05-07)
1
+ # Changelog
4
2
 
5
- ### New feature:
3
+ ## [v0.2.6](https://github.com/robcarruthers/lxi_rb/tree/v0.2.6) (2023-05-07)
6
4
 
7
- - **ffi**: Add search class method([`8f7351f`](https://github.com/robcarruthers/lxi_rb/commit/8f7351f9b541614a717a83d291d169b1fd8db356)) (by Rob Carruthers)
5
+ [Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/v0.2.1...v0.2.6)
8
6
 
9
- ## v0.2.0 (2023-05-07)
7
+ ## [v0.2.1](https://github.com/robcarruthers/lxi_rb/tree/v0.2.1) (2023-05-07)
10
8
 
11
- ## v0.1.0 (2023-05-07)
9
+ [Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/v0.2.0...v0.2.1)
10
+
11
+ ## [v0.2.0](https://github.com/robcarruthers/lxi_rb/tree/v0.2.0) (2023-05-07)
12
+
13
+ [Full Changelog](https://github.com/robcarruthers/lxi_rb/compare/v0.1.0...v0.2.0)
14
+
15
+ ## [v0.1.0](https://github.com/robcarruthers/lxi_rb/tree/v0.1.0) (2023-05-06)
16
+
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 CHANGED
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in lxi_rb.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "minitest", "~> 5.0"
11
-
12
- gem "rubocop", "~> 1.21"
7
+ gem 'minitest', '~> 5.0'
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rubocop', '~> 1.21'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lxi_rb (0.2.3)
4
+ lxi_rb (0.2.12)
5
5
  ffi (~> 1.15)
6
6
 
7
7
  GEM
data/Rakefile CHANGED
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+ require 'structured_changelog/tasks'
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
8
- t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
8
+ t.libs << 'test'
9
+ t.libs << 'lib'
10
+ t.test_files = FileList['test/**/test_*.rb']
10
11
  end
11
12
 
12
- require "rubocop/rake_task"
13
+ require 'rubocop/rake_task'
13
14
 
14
15
  RuboCop::RakeTask.new
15
16
 
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
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module Lxi
2
3
  class Device
3
4
  include FFI
5
+ include LxiMethods
6
+
4
7
  attr_accessor :id, :address, :port, :name, :timeout, :protocol
5
8
 
6
9
  def initialize(address, protocol)
@@ -17,7 +20,7 @@ module Lxi
17
20
  end
18
21
 
19
22
  def connect
20
- raise Error, 'LXI Library Initialisation Error' unless Lxi.lxi_init == LXI_OK
23
+ init_lxi_session
21
24
 
22
25
  @id = Lxi.lxi_connect(@address, @port, @name, @timeout, @protocol)
23
26
  raise Error, 'LXI Connection Error' if @id == LXI_ERROR
@@ -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
@@ -0,0 +1,10 @@
1
+ module Lxi
2
+ module LxiMethods
3
+ private
4
+
5
+ # Initialise the LXI library
6
+ def init_lxi_session
7
+ raise Error, 'LXI Library Initialisation Error' unless Lxi.lxi_init == LXI_OK
8
+ end
9
+ end
10
+ end
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.2.3'
4
+ VERSION = '0.2.12'
5
5
  end
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/ffi'
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.3
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-07 00:00:00.000000000 Z
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/ffi.rb
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,92 +0,0 @@
1
- require 'ffi'
2
-
3
- module Lxi
4
- extend FFI::Library
5
-
6
- ffi_lib '/opt/homebrew/lib/liblxi.dylib'
7
- ffi_lib_flags :now, :global
8
-
9
- # Define liblxi structs
10
- class LxiInfo < FFI::Struct
11
- layout :broadcast,
12
- callback(%i[pointer pointer], :void),
13
- :device,
14
- callback(%i[pointer pointer], :void),
15
- :service,
16
- callback(%i[pointer pointer pointer int], :void)
17
- end
18
-
19
- # LXI Constants
20
- LXI_OK = 0
21
- LXI_ERROR = -1
22
-
23
- # Define liblxi enums
24
- enum :lxi_protocol_type, %i[vxi11 raw hyslip]
25
- enum :lxi_discover_type, %i[vxi11 mdns]
26
-
27
- # Expose liblxi functions
28
- attach_function :lxi_init, [], :int
29
- attach_function :lxi_discover_internal, :lxi_discover, [LxiInfo.ptr, :int, :lxi_discover_type], :int
30
- attach_function :lxi_discover_if, [LxiInfo.ptr, :string, :int, :lxi_discover_type], :int
31
- attach_function :lxi_connect, %i[string int string int lxi_protocol_type], :int
32
- attach_function :lxi_send, %i[int string int int], :int
33
- attach_function :lxi_receive, %i[int pointer int int], :int
34
- attach_function :lxi_disconnect, [:int], :int
35
-
36
- # VXI11 Discovery Callbacks
37
- BroadcastCallback =
38
- FFI::Function.new(:void, %i[pointer pointer]) do |address, interface|
39
- puts "Broadcast: #{address.read_string}, #{interface.read_string}"
40
- end
41
-
42
- DeviceCallback =
43
- FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
44
- puts "Device: #{address.read_string}, #{id.read_string}"
45
- end
46
-
47
- ServiceCallback =
48
- FFI::Function.new(:void, %i[pointer pointer pointer int]) do |address, id, service, port|
49
- puts "Service: #{address.read_string}, #{id.read_string}, #{service.read_string}, #{port}"
50
- end
51
-
52
- # Initialise the LXI library
53
- def init_lxi_session
54
- raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
55
- end
56
-
57
- # Search for LXI-11 devices on the specified interface and return hash of devices
58
- def self.devices(interface: 'en0', timeout: 1000, type: :vxi11)
59
- raise Error, 'LXI Library Initialisation Error' unless lxi_init == LXI_OK
60
-
61
- devices = []
62
- callback =
63
- FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
64
- devices << { address: address.read_string, id: id.read_string }
65
- end
66
-
67
- info = LxiInfo.new
68
- info[:broadcast] = BroadcastCallback
69
- info[:device] = callback
70
-
71
- result = lxi_discover_internal(info, timeout, type)
72
- sleep 0.1
73
- puts "result: #{result}"
74
- puts "info: #{info[:device].read_string}"
75
- devices
76
- end
77
-
78
- # Discover LXI-11 devices on the LAN
79
- def self.discover_local(timeout: 1000, type: :vxi11)
80
- init_lxi_session
81
-
82
- info = LxiInfo.new
83
- info[:broadcast] = BroadcastCallback
84
- info[:device] = DeviceCallback
85
-
86
- puts "Searching for LXI devices - please wait...\n\n"
87
-
88
- result = lxi_discover_internal(info, timeout, type)
89
-
90
- puts "Error during discovery: #{result}" if result < 0
91
- end
92
- end