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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcaec19626a4b6942d800536e353368368ea5a6c751949fbdceb96fcebee1d42
4
- data.tar.gz: f523b9fa114c1173a66893db837174707e048f154486094f438f7bde4527aeae
3
+ metadata.gz: a93864f70d7ea209966823d01dfd44fa4502b2f319ece123359f5910a1c59b94
4
+ data.tar.gz: 2ccee720ae359a979439bd85edb2fc95d190b38e3e9258ba2aa1c2750316a801
5
5
  SHA512:
6
- metadata.gz: aa25b113a5ee19095bf01cbc5270852f08875afa3dd0a4fc50d939d3e6121070c705a02828155e3ffee409e786ca0a45b68ada391bc1e4620ba4421408ced6c8
7
- data.tar.gz: 5e0fc1be5a31cb3e7f6b1d428de176112164790437272fdf73ac2247cf0df8dc367a2a139bf102f87022ddcf66a104fc5c09634bf91ebbfcdb676b6c191e8730
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lxi_rb (0.10.0)
4
+ lxi_rb (0.10.2)
5
5
  ffi (~> 1.15)
6
6
 
7
7
  GEM
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.1.2) ![Ruby](https://img.shields.io/gitlab/license/robcarruthers/rfbeam?color=orange)
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.search
31
- Searching for LXI devices - please wait...
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 = meter.read 512
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
- read(10_000)
57
+ sleep :resp_delay
58
+ read(bytes)
58
59
  end
59
60
  end
60
61
  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.10.1'
4
+ VERSION = '0.10.3'
5
5
  end
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.10.1
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Carruthers