lxi_rb 0.10.1 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/README.md +56 -15
- data/lib/lxi/device.rb +4 -3
- data/lib/lxi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93864f70d7ea209966823d01dfd44fa4502b2f319ece123359f5910a1c59b94
|
4
|
+
data.tar.gz: 2ccee720ae359a979439bd85edb2fc95d190b38e3e9258ba2aa1c2750316a801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adcd8a2727d38843256fa849f034b61280e5ba2d983f3fb6fbc4eb0f204aa2e5c66ab2a6253a3d61f8f5abbada3af7839346e7299f7789427172a521f4d953b
|
7
|
+
data.tar.gz: 44fdb91fe50c5a490e6fb87b925b44daf5bc330791543b0f90a6e3abccd4b061d0a230204fd9c009c42af23c2d5964a21af362fac8003b85bdce4030e265f8f0
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,20 @@
|
|
4
4
|
All notable changes to this project will be documented in this file.
|
5
5
|
|
6
6
|
- - -
|
7
|
+
## [v0.10.3](https://github.com/robcarruthers/lxi_rb/compare/v0.10.2..v0.10.3) - 2023-05-24
|
8
|
+
#### Refactoring
|
9
|
+
- **(device)** Refine query method. Update readme - ([e837565](https://github.com/robcarruthers/lxi_rb/commit/e837565b92b362dedda8dc3908f757dedf00c418)) - [@robcarruthers](https://github.com/robcarruthers)
|
10
|
+
|
11
|
+
- - -
|
12
|
+
|
13
|
+
## [v0.10.2](https://github.com/robcarruthers/lxi_rb/compare/v0.10.1..v0.10.2) - 2023-05-24
|
14
|
+
#### Refactoring
|
15
|
+
- **(readme)** Update. Add default protocol to device - ([267a522](https://github.com/robcarruthers/lxi_rb/commit/267a52250bf78214b343dc7c2384c10be8b4ff32)) - [@robcarruthers](https://github.com/robcarruthers)
|
16
|
+
#### Tests
|
17
|
+
- Add Lxi::init test - ([1ff4907](https://github.com/robcarruthers/lxi_rb/commit/1ff490711a572b02fbd25f40499dea18248de956)) - [@robcarruthers](https://github.com/robcarruthers)
|
18
|
+
|
19
|
+
- - -
|
20
|
+
|
7
21
|
## [v0.10.1](https://github.com/robcarruthers/lxi_rb/compare/v0.10.0..v0.10.1) - 2023-05-24
|
8
22
|
#### Tests
|
9
23
|
- Update tests. Fix rubocop offfences. - ([88f7284](https://github.com/robcarruthers/lxi_rb/commit/88f7284625a182b19143cc2cf159e32a3d83270d)) - [@robcarruthers](https://github.com/robcarruthers)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# lxi_rb
|
2
2
|
|
3
|
-
[![Gem Version](https://img.shields.io/gem/v/lxi_rb?color=green)](https://badge.fury.io/rb/lxi_rb) ![Ruby](https://img.shields.io/static/v1?message=Ruby&color=red&logo=Ruby&logoColor=FFFFFF&label=v3.
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/lxi_rb?color=green)](https://badge.fury.io/rb/lxi_rb) ![Ruby](https://img.shields.io/static/v1?message=Ruby&color=red&logo=Ruby&logoColor=FFFFFF&label=v3.2.2+yjit) ![Ruby](https://img.shields.io/gitlab/license/robcarruthers/rfbeam?color=orange)
|
4
4
|
|
5
5
|
Ruby wrapper for the [liblxi](https://github.com/lxi-tools/liblxi) library, which offers a simple API for communicating with LXI compatible instruments.
|
6
6
|
|
@@ -27,26 +27,67 @@ gem install lxi_rb
|
|
27
27
|
## Usage
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
Lxi.
|
31
|
-
|
32
|
-
|
33
|
-
Broadcast: 127.0.0.1, lo0
|
34
|
-
Broadcast: 192.168.10.255, en0
|
35
|
-
Device: 192.168.10.21, Siglent Technologies,SDS1104X-E,SDSMMGKC6R0011,8.2.6.1.37R8
|
36
|
-
Device: 192.168.10.107, Siglent Technologies,SDM3055-SC,SDM35GBQ6R1882,1.01.01.25
|
37
|
-
|
38
|
-
Lxi.discover
|
39
|
-
=> [{:address=>"192.168.10.107", :id=>"Siglent Technologies,SDM3055-SC,SDM35GBQ6R1882,1.01.01.25"}]
|
40
|
-
|
41
|
-
Lxi::Device.new('192.168.10.107', :vxi11) do |meter|
|
42
|
-
meter.send 'MEAS:VOLT:DC?'
|
30
|
+
Lxi::Device.new('192.168.10.107') do |multimeter|
|
31
|
+
multimeter.send 'MEAS:VOLT:DC?'
|
43
32
|
sleep 0.05
|
44
|
-
result =
|
33
|
+
result = multimeter.read 512
|
45
34
|
puts Float(result)
|
46
35
|
end
|
47
36
|
=> -0.000478767775E-04
|
48
37
|
```
|
49
38
|
|
39
|
+
### NetFinder
|
40
|
+
|
41
|
+
The Lxi module provides a NetFinder class for searching for LXI devices on the network and a Device class for communicating with LXI devices.
|
42
|
+
|
43
|
+
NetFinder will broadcast a UDP packet to the network and wait for responses from LXI devices. The search method will return an array of hashes containing the IP address and identification string of each device found. By default, the search method will use the VXI-11 UDP broadcast method, but can be configured to use mDNS with the :mdns option.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
net = Lxi::NetFinder.new
|
47
|
+
=> <Lxi::NetFinder:0x00000001047fc538>
|
48
|
+
|
49
|
+
net.search
|
50
|
+
=> [{:address=>"192.168.10.197", :id=>"RIGOL TECHNOLOGIES,M300,MM3A250200001,04.02.00.08.00"}]
|
51
|
+
|
52
|
+
irb(main):003:0> net.search :mdns
|
53
|
+
=> [{:address=>"192.168.10.109", :id=>"dummy-scope LXI", :service=>"lxi", :port=>12345}]
|
54
|
+
```
|
55
|
+
|
56
|
+
### Device API
|
57
|
+
|
58
|
+
The Lxi module provides a Device class for communicating with LXI devices. The Device class can be initialized with an IP address. The Device class will attempt to connect to the device when initialized and will raise an exception if the connection fails. The Device class can also be initialized with a block, which will yield the Device object to the block and close the connection when the block exits.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
device = Lxi::Device.new('192.168.10.197')
|
62
|
+
```
|
63
|
+
|
64
|
+
#### write(message) -> int
|
65
|
+
|
66
|
+
The write method will send a string to the device and return the number of bytes written.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
device.write 'MEAS:VOLT:DC?'
|
70
|
+
=> 13
|
71
|
+
```
|
72
|
+
|
73
|
+
#### read(512) -> String
|
74
|
+
|
75
|
+
The read method will read the specified number of bytes from the device and return a string.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
device.read 512
|
79
|
+
=> "-4.90147020E-04\n"
|
80
|
+
```
|
81
|
+
|
82
|
+
#### query(message, bytes = 512, resp_delay: 0.02) -> String
|
83
|
+
|
84
|
+
The query method will send a string to the device, read the optional number of bytes from the device and return a string. It also accepts an optional :resp_delay parameter, which will delay the read operation by the specified number of seconds.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
device.query 'MEAS:VOLT:DC?', 512, resp_delay: 0.05
|
88
|
+
=> "-4.97235730E-04\n"
|
89
|
+
```
|
90
|
+
|
50
91
|
## Development
|
51
92
|
|
52
93
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/lxi/device.rb
CHANGED
@@ -6,7 +6,7 @@ module Lxi
|
|
6
6
|
|
7
7
|
attr_accessor :id, :address, :port, :name, :timeout, :protocol
|
8
8
|
|
9
|
-
def initialize(address, protocol)
|
9
|
+
def initialize(address, protocol = :vxi11)
|
10
10
|
@address = address
|
11
11
|
@port = 0
|
12
12
|
@name = nil
|
@@ -52,9 +52,10 @@ module Lxi
|
|
52
52
|
end
|
53
53
|
alias gets read
|
54
54
|
|
55
|
-
def query(message)
|
55
|
+
def query(message, bytes = 512, resp_delay: 0.02)
|
56
56
|
write(message)
|
57
|
-
|
57
|
+
sleep :resp_delay
|
58
|
+
read(bytes)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
data/lib/lxi/version.rb
CHANGED