lxi_rb 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +55 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +11 -1
- data/lib/lxi/callbacks.rb +6 -3
- data/lib/lxi/device.rb +9 -9
- data/lib/lxi/discovery.rb +4 -4
- data/lib/lxi/methods.rb +1 -1
- data/lib/lxi/version.rb +1 -1
- data/lib/lxi_rb.rb +5 -5
- metadata +65 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14332658e014f39abcd5aa4dedd87f86ed793a8ee891ae2c38abed1e96740248
|
4
|
+
data.tar.gz: d417f13bb3e8cc874b9b0d0cffb394a307c42d70ecc69410a15838b8e42171e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc179e9643858482b291f1faf50ee9c7302bfbbf4a576052136c2d7d23a7c383b5efe751fe847552246cfbcd0d76058aa1454fafdaec68b64cff8aa4d1998bf
|
7
|
+
data.tar.gz: 6536d4d6defd3abae63528f58e6982f80dc608358fed282e6e1f7eef290462108e96de205e1761af054319cb6b40b1af04b2a0e234e050fe2f2a82c2049665a1
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Rubocop config for lxi_rb rubygem
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 3.1
|
4
|
+
EnabledByDefault: true
|
5
|
+
AutoCorrect: true
|
6
|
+
|
7
|
+
require:
|
8
|
+
- rubocop-performance
|
9
|
+
- rubocop-rake
|
10
|
+
- rubocop-minitest
|
11
|
+
|
12
|
+
inherit_gem:
|
13
|
+
syntax_tree: config/rubocop.yml
|
14
|
+
|
15
|
+
Style/StringLiterals:
|
16
|
+
EnforcedStyle: single_quotes
|
17
|
+
|
18
|
+
Style/StringLiteralsInInterpolation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Layout/LineLength:
|
22
|
+
Max: 120
|
23
|
+
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 30
|
26
|
+
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Max: 30
|
29
|
+
|
30
|
+
Metrics/ClassLength:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Documentation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/Copyright:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/DocumentationMethod:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Lint/ConstantResolution:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Bundler/GemComment:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/ConstantVisibility:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/IpAddresses:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/MissingElse:
|
55
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
8
|
- - -
|
9
|
+
## [v0.7.1](https://github.com/robcarruthers/lxi_rb/compare/v0.7.0..v0.7.1) - 2023-05-11
|
10
|
+
#### Miscellaneous Chores
|
11
|
+
- **(Rubocop)** Fix offences - ([ba347f4](https://github.com/robcarruthers/lxi_rb/commit/ba347f4de9bbcafb28aa86a747f88ca725e4725e)) - [@robcarruthers](https://github.com/robcarruthers)
|
12
|
+
|
13
|
+
- - -
|
14
|
+
|
9
15
|
## [v0.7.0](https://github.com/robcarruthers/lxi_rb/compare/v0.6.4..v0.7.0) - 2023-05-11
|
10
16
|
#### Tests
|
11
17
|
- **(Lxi)** Add Lxi module tests - ([627766f](https://github.com/robcarruthers/lxi_rb/commit/627766f3953486e54fc7bb67a3cb75701e1aa537)) - [@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.
|
4
|
+
lxi_rb (0.7.0)
|
5
5
|
ffi (~> 1.15)
|
6
6
|
|
7
7
|
GEM
|
@@ -38,6 +38,13 @@ GEM
|
|
38
38
|
unicode-display_width (>= 2.4.0, < 3.0)
|
39
39
|
rubocop-ast (1.26.0)
|
40
40
|
parser (>= 3.2.1.0)
|
41
|
+
rubocop-minitest (0.31.0)
|
42
|
+
rubocop (>= 1.39, < 2.0)
|
43
|
+
rubocop-performance (1.17.1)
|
44
|
+
rubocop (>= 1.7.0, < 2.0)
|
45
|
+
rubocop-ast (>= 0.4.0)
|
46
|
+
rubocop-rake (0.6.0)
|
47
|
+
rubocop (~> 1.0)
|
41
48
|
ruby-progressbar (1.11.0)
|
42
49
|
unicode-display_width (2.4.2)
|
43
50
|
|
@@ -51,6 +58,9 @@ DEPENDENCIES
|
|
51
58
|
minitest-reporters (~> 1.4)
|
52
59
|
rake (~> 13.0)
|
53
60
|
rubocop (~> 1.21)
|
61
|
+
rubocop-minitest (~> 0.3)
|
62
|
+
rubocop-performance (~> 1.10)
|
63
|
+
rubocop-rake (~> 0.4)
|
54
64
|
|
55
65
|
BUNDLED WITH
|
56
66
|
2.4.10
|
data/lib/lxi/callbacks.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'ffi'
|
3
|
+
|
2
4
|
module Lxi
|
5
|
+
include FFI
|
3
6
|
# VXI11 Discovery Callbacks
|
4
7
|
BroadcastCallback =
|
5
8
|
FFI::Function.new(:void, %i[pointer pointer]) do |address, interface|
|
6
|
-
puts
|
9
|
+
puts("Broadcast: #{address.read_string}, #{interface.read_string}")
|
7
10
|
end
|
8
11
|
|
9
12
|
DeviceCallback =
|
10
13
|
FFI::Function.new(:void, %i[pointer pointer]) do |address, id|
|
11
|
-
puts
|
14
|
+
puts("Device: #{address.read_string}, #{id.read_string}")
|
12
15
|
end
|
13
16
|
|
14
17
|
ServiceCallback =
|
15
18
|
FFI::Function.new(:void, %i[pointer pointer pointer int]) do |address, id, service, port|
|
16
|
-
puts
|
19
|
+
puts("Service: #{address.read_string}, #{id.read_string}, #{service.read_string}, #{port}")
|
17
20
|
end
|
18
21
|
end
|
data/lib/lxi/device.rb
CHANGED
@@ -15,14 +15,14 @@ module Lxi
|
|
15
15
|
|
16
16
|
connect
|
17
17
|
|
18
|
-
yield
|
18
|
+
yield(self) if block_given?
|
19
19
|
end
|
20
20
|
|
21
21
|
def connect
|
22
22
|
Lxi.init_lxi_session
|
23
23
|
|
24
24
|
@id = Lxi.lxi_connect(@address, @port, @name, @timeout, @protocol)
|
25
|
-
raise
|
25
|
+
raise(Error, 'LXI Connection Error') if @id == LXI_ERROR
|
26
26
|
|
27
27
|
true
|
28
28
|
end
|
@@ -33,27 +33,27 @@ module Lxi
|
|
33
33
|
end
|
34
34
|
alias close disconnect
|
35
35
|
|
36
|
-
def
|
36
|
+
def write(message)
|
37
37
|
bytes_sent = Lxi.lxi_send(@id, message, message.length, @timeout)
|
38
|
-
raise
|
38
|
+
raise(Error, 'LXI communications error') unless bytes_sent.positive?
|
39
39
|
|
40
40
|
bytes_sent
|
41
41
|
end
|
42
|
-
alias scpi
|
43
|
-
alias write
|
42
|
+
alias scpi write
|
43
|
+
alias send write
|
44
44
|
|
45
45
|
def read(length)
|
46
46
|
message = FFI::MemoryPointer.new(:char, length)
|
47
47
|
bytes_received = Lxi.lxi_receive(@id, message, length, @timeout)
|
48
|
-
raise
|
48
|
+
raise(Error, 'LXI communications error') unless bytes_received.positive?
|
49
49
|
|
50
50
|
message.read_string
|
51
51
|
end
|
52
52
|
alias gets read
|
53
53
|
|
54
54
|
def query(message)
|
55
|
-
|
56
|
-
read
|
55
|
+
write(message)
|
56
|
+
read(10_000)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/lib/lxi/discovery.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Lxi
|
3
3
|
# Search for LXI-11 instruments on the network and return hash of instruments
|
4
4
|
def self.discover(timeout: 1000, type: :vxi11)
|
5
|
-
raise
|
5
|
+
raise(Error, 'LXI Library Initialisation Error') unless lxi_init == LXI_OK
|
6
6
|
|
7
7
|
devices = []
|
8
8
|
device_callback =
|
@@ -14,7 +14,7 @@ module Lxi
|
|
14
14
|
info[:device] = device_callback
|
15
15
|
|
16
16
|
lxi_discover_internal(info, timeout, type)
|
17
|
-
sleep
|
17
|
+
sleep(0.1)
|
18
18
|
devices
|
19
19
|
end
|
20
20
|
|
@@ -26,10 +26,10 @@ module Lxi
|
|
26
26
|
info[:broadcast] = BroadcastCallback
|
27
27
|
info[:device] = DeviceCallback
|
28
28
|
|
29
|
-
puts
|
29
|
+
puts("Searching for LXI devices - please wait...\n\n")
|
30
30
|
|
31
31
|
result = lxi_discover_internal(info, timeout, type)
|
32
32
|
|
33
|
-
puts
|
33
|
+
puts("Error during discovery: #{result}") if result.negative?
|
34
34
|
end
|
35
35
|
end
|
data/lib/lxi/methods.rb
CHANGED
data/lib/lxi/version.rb
CHANGED
data/lib/lxi_rb.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'lxi/version'
|
4
|
-
require_relative 'lxi/functions'
|
5
|
-
require_relative 'lxi/methods'
|
6
|
-
require_relative 'lxi/constants'
|
7
3
|
require_relative 'lxi/callbacks'
|
8
|
-
require_relative 'lxi/
|
4
|
+
require_relative 'lxi/constants'
|
9
5
|
require_relative 'lxi/device'
|
6
|
+
require_relative 'lxi/discovery'
|
7
|
+
require_relative 'lxi/functions'
|
8
|
+
require_relative 'lxi/methods'
|
9
|
+
require_relative 'lxi/version'
|
10
10
|
|
11
11
|
module Lxi
|
12
12
|
extend FFIFunctions
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lxi_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Carruthers
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-reporters
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.4'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rake
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,33 +81,61 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '13.0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rubocop
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - "~>"
|
60
88
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
89
|
+
version: '1.18'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
96
|
+
version: '1.18'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest
|
98
|
+
name: rubocop-minitest
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
103
|
+
version: '0.3'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
110
|
+
version: '0.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-performance
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.10'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.10'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.4'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.4'
|
83
139
|
description: The gem includes methods required for discovering and communicating with
|
84
140
|
LXI compliant devices
|
85
141
|
email:
|
@@ -88,6 +144,7 @@ executables: []
|
|
88
144
|
extensions: []
|
89
145
|
extra_rdoc_files: []
|
90
146
|
files:
|
147
|
+
- ".rubocop.yml"
|
91
148
|
- ".tool-versions"
|
92
149
|
- ".vscode/settings.json"
|
93
150
|
- CHANGELOG.md
|
@@ -112,6 +169,7 @@ metadata:
|
|
112
169
|
homepage_uri: https://github.com/robcarruthers/lxi_rb
|
113
170
|
source_code_uri: https://github.com/robcarruthers/lxi_rb
|
114
171
|
changelog_uri: https://github.com/robcarruthers/lxi_rb/blob/master/CHANGELOG.md
|
172
|
+
rubygems_mfa_required: 'true'
|
115
173
|
post_install_message:
|
116
174
|
rdoc_options: []
|
117
175
|
require_paths:
|