prologix_gpib 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -1
- data/Gemfile.lock +6 -6
- data/NetFinder_info.md +30 -0
- data/README.md +23 -9
- data/lib/prologix_gpib/cli.rb +22 -12
- data/lib/prologix_gpib/{usb/commands.rb → commands.rb} +18 -32
- data/lib/prologix_gpib/discovery.rb +14 -6
- data/lib/prologix_gpib/lan.rb +49 -4
- data/lib/prologix_gpib/usb.rb +21 -11
- data/lib/prologix_gpib/version.rb +1 -1
- data/lib/prologix_gpib.rb +7 -4
- metadata +5 -6
- data/lib/prologix_gpib/lan/commands.rb +0 -2
- data/udp_info.md +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9ad45cfaf230b41f26ec6102bb89f34b36f8a6f38439b96a578ae4f9b338a87
|
4
|
+
data.tar.gz: 336106999abd44891bc67b872fe45c8bf222356725675b90321409aee3a0e751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee481f80d7bb2e9d3e62cdeb2c86e69b5a73422f93387e133c4837329ec08b3df429c92cc6cc2035ea2d3227b82d6d5a2b4858bb5af83f12358e988f8efe4173
|
7
|
+
data.tar.gz: e21355fd8937ebfbbf368838b84fe6143bf0e08c82c05a98b035e897277bdb3ceabe7a78d075b780d70fe48dcb3c9ab16806dade3bcd14e9b597d336f3b65767
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.1.
|
1
|
+
ruby 3.1.2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
prologix_gpib (0.
|
4
|
+
prologix_gpib (0.5.0)
|
5
5
|
activesupport (~> 7.0.1)
|
6
6
|
bindata (~> 2.4.10)
|
7
7
|
rubyserial (~> 0.6.0)
|
@@ -11,19 +11,19 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
activesupport (7.0.
|
14
|
+
activesupport (7.0.3)
|
15
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
16
|
i18n (>= 1.6, < 2)
|
17
17
|
minitest (>= 5.1)
|
18
18
|
tzinfo (~> 2.0)
|
19
19
|
bindata (2.4.10)
|
20
20
|
coderay (1.1.3)
|
21
|
-
concurrent-ruby (1.1.
|
21
|
+
concurrent-ruby (1.1.10)
|
22
22
|
ffi (1.15.5)
|
23
|
-
i18n (1.
|
23
|
+
i18n (1.10.0)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
25
|
method_source (1.0.0)
|
26
|
-
minitest (5.
|
26
|
+
minitest (5.16.1)
|
27
27
|
pry (0.14.1)
|
28
28
|
coderay (~> 1.1)
|
29
29
|
method_source (~> 1.0)
|
@@ -47,4 +47,4 @@ DEPENDENCIES
|
|
47
47
|
rake (~> 10.0)
|
48
48
|
|
49
49
|
BUNDLED WITH
|
50
|
-
2.
|
50
|
+
2.3.16
|
data/NetFinder_info.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Net Finder
|
2
|
+
|
3
|
+
NetFinder, uses UDP broadcast to locate and configure GPIB-ETH controllers on a network.
|
4
|
+
You can find an implementation of the protocol in the nfcli utility
|
5
|
+
http://prologix.biz/downloads/nfcli.tar.gz
|
6
|
+
|
7
|
+
### Discovery
|
8
|
+
|
9
|
+
- Create NF_IDENTIFY packet.
|
10
|
+
- Set sequence to a random value
|
11
|
+
- Set eth_addr to all ones
|
12
|
+
- Broadcast NF_IDENTIFY datagram to port 3040/UDP.
|
13
|
+
- Listen for NF_IDENTIFY_REPLY datagrams.
|
14
|
+
- Verify sequence matches NF_IDENTIFY packet
|
15
|
+
|
16
|
+
### Configuration
|
17
|
+
|
18
|
+
- Create NF_ASSIGNMENT packet
|
19
|
+
- Set sequence to a random value
|
20
|
+
- Set eth_addr to MAC address of desired device Set ip_type to NF_IP_DYNAMIC or NF_IP_STATIC If ip_type is NF_IP_DYNAMIC specify ip, mask and gateway addresses.
|
21
|
+
- Broadcast NF\* ASSIGNMENT datagram to port 3040/UDP.
|
22
|
+
- Listen for NF_ASSIGNMENT_REPLY datagrams.
|
23
|
+
- Verify sequence matches that of NF_ASSIGNMENT packet Check result field for NF_SUCCESS
|
24
|
+
|
25
|
+
Notes:
|
26
|
+
|
27
|
+
1. You may get multiple replies. Discard duplicate replies.
|
28
|
+
2. All multi-byte values are in network order (big-endian)
|
29
|
+
3. On multi-homed hosts, make sure broadcasts go out over all interfaces.
|
30
|
+
4. NetFinder protocol only works within the same subnet as routers will not forward UDP broadcast packets.
|
data/README.md
CHANGED
@@ -28,14 +28,16 @@ The gem comes with a simple cli for finding controllers:
|
|
28
28
|
|
29
29
|
```bash
|
30
30
|
$ plx list
|
31
|
-
|
32
|
-
|
|
33
|
-
|
34
|
-
| index | Controller
|
35
|
-
|
36
|
-
| 0 | Prologix GPIB-USB Controller
|
37
|
-
| 1 | Prologix GPIB-USB Controller
|
38
|
-
|
31
|
+
+-----------------------------------------------------------------------------------------+
|
32
|
+
| Prologix Controllers |
|
33
|
+
+-------+------------------------------------+--------------+-----------------------------+
|
34
|
+
| index | Controller | Version | Location |
|
35
|
+
+-------+------------------------------------+--------------+-----------------------------+
|
36
|
+
| 0 | Prologix GPIB-USB Controller | 6.101 | /dev/tty.usbserial-PX9HPBMB |
|
37
|
+
| 1 | Prologix GPIB-USB Controller | 6.107 | /dev/tty.usbserial-PXEGWA9A |
|
38
|
+
| 2 | Prologix GPIB-LAN Controller | 01.03.00.00 | 192.168.10.161 |
|
39
|
+
| 3 | Prologix GPIB-ETHERNET Controller | 01.06.06.00 | 192.168.10.127 |
|
40
|
+
+-------+------------------------------------+--------------+-----------------------------+
|
39
41
|
|
40
42
|
$ plx info 0
|
41
43
|
|
@@ -50,6 +52,18 @@ $ plx info 0
|
|
50
52
|
EOS: Append CR+LF
|
51
53
|
EOT: Enabled
|
52
54
|
|
55
|
+
plx info 3
|
56
|
+
|
57
|
+
Prologix gpib-ethernet controller
|
58
|
+
Path: 192.168.10.127
|
59
|
+
Firmware: 01.06.06.00
|
60
|
+
Mode: Controller
|
61
|
+
Device Address: 5
|
62
|
+
Auto Read: Enabled
|
63
|
+
Read Timeout: 500
|
64
|
+
Eoi Assertion: Enabled
|
65
|
+
Eos: Append CR+LF
|
66
|
+
Eot: Disabled
|
53
67
|
```
|
54
68
|
|
55
69
|
### Finding Controllers
|
@@ -67,7 +81,7 @@ irb(main):002:0> controllers = f.avaliable_controllers
|
|
67
81
|
|
68
82
|
### Working with Controllers
|
69
83
|
|
70
|
-
I'm not enamoured by this interface, I'd like a more ruby like way of finding and connecting controllers thats less clunky. It works for now, but may change as we refine
|
84
|
+
I'm not enamoured by this interface, I'd like a more ruby like way of finding and connecting controllers thats less clunky. It works for now, but may change as we refine things.
|
71
85
|
|
72
86
|
```ruby
|
73
87
|
irb(main):003:0> device = PrologixGpib::UsbController.new(controllers[:usb][0])
|
data/lib/prologix_gpib/cli.rb
CHANGED
@@ -2,28 +2,34 @@ require 'thor'
|
|
2
2
|
require 'pp'
|
3
3
|
require 'prologix_gpib'
|
4
4
|
require 'terminal-table'
|
5
|
+
require 'resolv'
|
5
6
|
|
6
7
|
module PrologixGpib
|
7
8
|
class CLI < Thor
|
9
|
+
def initialize(*args)
|
10
|
+
super
|
11
|
+
@controllers = PrologixGpib::Finder.new.avaliable_controllers
|
12
|
+
end
|
13
|
+
|
8
14
|
desc 'list', 'List all connected controllers'
|
9
15
|
|
10
16
|
def list
|
11
|
-
puts controller_table(
|
17
|
+
puts controller_table(@controllers)
|
12
18
|
end
|
13
19
|
|
14
|
-
desc 'info', 'Display Controller information'
|
15
|
-
option :path,
|
16
|
-
def info
|
20
|
+
desc 'info [INDEX]', 'Display Controller information'
|
21
|
+
option :path, aliases: :p
|
22
|
+
def info(index)
|
17
23
|
return unless controllers_connected?
|
18
24
|
|
19
|
-
|
25
|
+
controller_paths = @controllers.map { |k, v| v }.flatten
|
20
26
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
path = controller_paths[index.to_i]
|
28
|
+
hash = ip_address?(path) ? PrologixGpib::LanController.new(path).config : PrologixGpib::UsbController.new(path).config
|
29
|
+
|
30
|
+
puts "\n #{titleise hash.delete(:device_name)}"
|
31
|
+
puts "\tPath: #{path}"
|
32
|
+
hash.each { |k, v| puts "\t#{titleise(k)}: #{v}" }
|
27
33
|
end
|
28
34
|
|
29
35
|
private
|
@@ -59,11 +65,15 @@ module PrologixGpib
|
|
59
65
|
end
|
60
66
|
|
61
67
|
def controllers_connected?
|
62
|
-
|
68
|
+
@controllers[:usb].any? || @controllers[:lan].any?
|
63
69
|
end
|
64
70
|
|
65
71
|
def titleise(string)
|
66
72
|
string.to_s.split('_').map(&:capitalize).join(' ')
|
67
73
|
end
|
74
|
+
|
75
|
+
def ip_address?(string)
|
76
|
+
string =~ Resolv::IPv4::Regex ? true : false
|
77
|
+
end
|
68
78
|
end
|
69
79
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module PrologixGpib::
|
1
|
+
module PrologixGpib::Commands
|
2
2
|
def config
|
3
3
|
error_message = 'Error'
|
4
4
|
device_version = version.split('version').map(&:strip)
|
@@ -40,7 +40,7 @@ module PrologixGpib::Usb::Commands
|
|
40
40
|
conf
|
41
41
|
end
|
42
42
|
|
43
|
-
# This command configures the Prologix GPIB-USB controller to be a :controller or :device.
|
43
|
+
# # This command configures the Prologix GPIB-USB controller to be a :controller or :device.
|
44
44
|
def mode=(op_mode)
|
45
45
|
mode =
|
46
46
|
case op_mode
|
@@ -60,8 +60,8 @@ module PrologixGpib::Usb::Commands
|
|
60
60
|
end
|
61
61
|
alias operation_mode mode
|
62
62
|
|
63
|
-
# Timeout value, in milliseconds, used in the read command and spoll command.
|
64
|
-
# Any value between 1 and 3000 milliseconds.
|
63
|
+
# # Timeout value, in milliseconds, used in the read command and spoll command.
|
64
|
+
# # Any value between 1 and 3000 milliseconds.
|
65
65
|
def timeout=(milliseconds)
|
66
66
|
return unless connected? || milliseconds.class != Integer
|
67
67
|
|
@@ -72,8 +72,8 @@ module PrologixGpib::Usb::Commands
|
|
72
72
|
device_query('++read_tmo_ms')
|
73
73
|
end
|
74
74
|
|
75
|
-
# PrologixGPIB-USB controller can be configured to automatically address instruments to 'talk' after sending a command in order to read the response.
|
76
|
-
# *** Avaliable in Controller mode. When enabled can cause the prologix controller to lockup. ***
|
75
|
+
# # PrologixGPIB-USB controller can be configured to automatically address instruments to 'talk' after sending a command in order to read the response.
|
76
|
+
# # *** Avaliable in Controller mode. When enabled can cause the prologix controller to lockup. ***
|
77
77
|
def auto=(auto_mode)
|
78
78
|
mode =
|
79
79
|
case auto_mode
|
@@ -93,8 +93,8 @@ module PrologixGpib::Usb::Commands
|
|
93
93
|
end
|
94
94
|
alias auto_read_after_write auto
|
95
95
|
|
96
|
-
# In :controller mode, address refers to the GPIB address of the instrument being controlled.
|
97
|
-
# In :device mode, it is the address of the GPIB peripheral that Prologix GPIB-USB controller is emulating.
|
96
|
+
# # In :controller mode, address refers to the GPIB address of the instrument being controlled.
|
97
|
+
# # In :device mode, it is the address of the GPIB peripheral that Prologix GPIB-USB controller is emulating.
|
98
98
|
def address=(addr)
|
99
99
|
write("++addr #{addr}")
|
100
100
|
end
|
@@ -104,8 +104,8 @@ module PrologixGpib::Usb::Commands
|
|
104
104
|
device_query('++addr')
|
105
105
|
end
|
106
106
|
|
107
|
-
# This command enables or disables the assertion of the EOI signal with the last character of any command sent over GPIB port.
|
108
|
-
# Some instruments require EOI signal to be asserted in order to properly detect the end of a command.
|
107
|
+
# # This command enables or disables the assertion of the EOI signal with the last character of any command sent over GPIB port.
|
108
|
+
# # Some instruments require EOI signal to be asserted in order to properly detect the end of a command.
|
109
109
|
def eoi=(eoi_mode)
|
110
110
|
mode =
|
111
111
|
case eoi_mode
|
@@ -123,13 +123,13 @@ module PrologixGpib::Usb::Commands
|
|
123
123
|
device_query('++eoi')
|
124
124
|
end
|
125
125
|
|
126
|
-
# This command specifies GPIB termination characters. When data from host is received over USB, all non-escaped LF, CR and ESC characters are removed and GPIB terminators, as specified by this command, are appended before sending the data to instruments.
|
127
|
-
# This command does not affect data from instruments received over GPIB port.
|
128
|
-
# EXAMPLES:
|
129
|
-
# 0 Append CR+LF
|
130
|
-
# 1 Append CR to instrument commands
|
131
|
-
# 2 Append LF to instrument commands
|
132
|
-
# 3 Do not append anything to instrument commands
|
126
|
+
# # This command specifies GPIB termination characters. When data from host is received over USB, all non-escaped LF, CR and ESC characters are removed and GPIB terminators, as specified by this command, are appended before sending the data to instruments.
|
127
|
+
# # This command does not affect data from instruments received over GPIB port.
|
128
|
+
# # EXAMPLES:
|
129
|
+
# # 0 Append CR+LF
|
130
|
+
# # 1 Append CR to instrument commands
|
131
|
+
# # 2 Append LF to instrument commands
|
132
|
+
# # 3 Do not append anything to instrument commands
|
133
133
|
def eos=(eos_mode)
|
134
134
|
error_message = "Invalid arg: '#{eos_mode}'"
|
135
135
|
raise ArgumentError, error_message unless [0, 1, 2, 3].include? eos_mode
|
@@ -141,7 +141,7 @@ module PrologixGpib::Usb::Commands
|
|
141
141
|
device_query('++eos')
|
142
142
|
end
|
143
143
|
|
144
|
-
# This command enables or disables the appending of a user specified character (see eot_char) to USB output whenever EOI is detected while reading a character from the GPIBport.
|
144
|
+
# # This command enables or disables the appending of a user specified character (see eot_char) to USB output whenever EOI is detected while reading a character from the GPIBport.
|
145
145
|
def eot=(eot_mode)
|
146
146
|
mode =
|
147
147
|
case eot_mode
|
@@ -186,18 +186,4 @@ module PrologixGpib::Usb::Commands
|
|
186
186
|
def reset
|
187
187
|
write('++rst')
|
188
188
|
end
|
189
|
-
|
190
|
-
def flush
|
191
|
-
return unless connected?
|
192
|
-
|
193
|
-
loop until serial_port.getbyte.nil?
|
194
|
-
end
|
195
|
-
|
196
|
-
private
|
197
|
-
|
198
|
-
def device_query(command)
|
199
|
-
flush
|
200
|
-
write(command)
|
201
|
-
readline
|
202
|
-
end
|
203
189
|
end
|
@@ -60,7 +60,6 @@ module PrologixGpib::Discovery
|
|
60
60
|
string :app_ver, read_length: 4
|
61
61
|
string :boot_ver, read_length: 4
|
62
62
|
string :hw_ver, read_length: 4
|
63
|
-
stringz :name
|
64
63
|
end
|
65
64
|
|
66
65
|
NF_MAGIC = 0x5a
|
@@ -69,7 +68,7 @@ module PrologixGpib::Discovery
|
|
69
68
|
NF_IDENTIFY_REPLY = 1
|
70
69
|
BROADCAST_PORT = 3040
|
71
70
|
BROADCAST_ADDRESS = '255.255.255.255'
|
72
|
-
TIMEOUT =
|
71
|
+
TIMEOUT = 0.5
|
73
72
|
|
74
73
|
private
|
75
74
|
|
@@ -90,16 +89,25 @@ module PrologixGpib::Discovery
|
|
90
89
|
|
91
90
|
sock.send(data.to_binary_s, 0, BROADCAST_ADDRESS, BROADCAST_PORT)
|
92
91
|
array = []
|
92
|
+
replies = []
|
93
93
|
begin
|
94
94
|
Timeout.timeout(TIMEOUT) do
|
95
95
|
while true
|
96
|
-
data, addr = sock.recvfrom(
|
97
|
-
|
98
|
-
next if array.include?(reply.addr)
|
99
|
-
array << reply.addr if reply.header.seq == seq && reply.header.identify == NF_IDENTIFY_REPLY
|
96
|
+
data, addr = sock.recvfrom(1000)
|
97
|
+
replies << data
|
100
98
|
end
|
101
99
|
end
|
102
100
|
rescue Timeout::Error
|
101
|
+
replies.each do |data|
|
102
|
+
begin
|
103
|
+
reply = NFIdentifyReply.read(data)
|
104
|
+
rescue EOFError
|
105
|
+
# About 1% of responses are not always as expected from the controller
|
106
|
+
next
|
107
|
+
end
|
108
|
+
next if array.include?(reply.addr)
|
109
|
+
array << reply.addr if reply.header.seq == seq && reply.header.identify == NF_IDENTIFY_REPLY
|
110
|
+
end
|
103
111
|
sock.close
|
104
112
|
array
|
105
113
|
end
|
data/lib/prologix_gpib/lan.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
1
3
|
module PrologixGpib::Lan
|
2
4
|
class Error < StandardError
|
3
5
|
end
|
4
6
|
|
5
7
|
DEVICE_PORT = 1234
|
6
|
-
EOL = "\r\n"
|
8
|
+
EOL = "\r\n".freeze
|
7
9
|
|
8
10
|
def initialize(ip, mode: :controller, address: 9)
|
9
|
-
|
11
|
+
open_socket(ip)
|
10
12
|
|
11
13
|
# open_serial_port(paths)
|
12
14
|
# flush
|
@@ -18,8 +20,51 @@ module PrologixGpib::Lan
|
|
18
20
|
yield self if block_given?
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
+
def write(command)
|
24
|
+
return unless connected?
|
25
|
+
|
26
|
+
@socket.send "#{command}#{EOL}", 0
|
27
|
+
sleep 0.1
|
28
|
+
end
|
29
|
+
|
30
|
+
def read
|
31
|
+
return unless connected?
|
32
|
+
|
23
33
|
@socket.gets.chomp
|
24
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def open_socket(ip)
|
39
|
+
@socket = TCPSocket.new ip, DEVICE_PORT
|
40
|
+
write('++ver')
|
41
|
+
return if getline.include? 'Prologix'
|
42
|
+
|
43
|
+
raise Error, 'No Prologix LAN controllers found.'
|
44
|
+
end
|
45
|
+
|
46
|
+
def connected?
|
47
|
+
raise Error, 'ConnectionError: No open Prologix device connections.' if @socket.nil?
|
48
|
+
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
def readline
|
53
|
+
return unless connected?
|
54
|
+
|
55
|
+
t = Timeout.timeout(1, Timeout::Error, "No response from device at #{@socket.peeraddr[3]}") { getline }
|
56
|
+
end
|
57
|
+
|
58
|
+
# This method will block until the EOL terminator is received
|
59
|
+
# The lower level gets method is pure ruby, so can be safely used with Timeout.
|
60
|
+
def getline
|
61
|
+
return unless connected?
|
62
|
+
|
63
|
+
@socket.gets(EOL).chomp
|
64
|
+
end
|
65
|
+
|
66
|
+
def device_query(command)
|
67
|
+
write(command)
|
68
|
+
readline
|
69
|
+
end
|
25
70
|
end
|
data/lib/prologix_gpib/usb.rb
CHANGED
@@ -9,8 +9,7 @@ module PrologixGpib::Usb
|
|
9
9
|
attr_reader :serial_port
|
10
10
|
|
11
11
|
def initialize(path, mode: :controller, address: 9)
|
12
|
-
|
13
|
-
open_serial_port(paths)
|
12
|
+
open_serial_port(path)
|
14
13
|
flush
|
15
14
|
self.mode = mode
|
16
15
|
self.address = address
|
@@ -28,10 +27,10 @@ module PrologixGpib::Usb
|
|
28
27
|
@serial_port.nil?
|
29
28
|
end
|
30
29
|
|
31
|
-
def write(
|
30
|
+
def write(string)
|
32
31
|
return unless connected?
|
33
32
|
|
34
|
-
@serial_port.write("#{
|
33
|
+
@serial_port.write("#{string}#{EOL}")
|
35
34
|
end
|
36
35
|
|
37
36
|
def read(bytes)
|
@@ -43,7 +42,7 @@ module PrologixGpib::Usb
|
|
43
42
|
def readline
|
44
43
|
return unless connected?
|
45
44
|
|
46
|
-
t = Timeout.timeout(1, Timeout::Error, 'No response from
|
45
|
+
t = Timeout.timeout(1, Timeout::Error, 'No response from device') { getline }
|
47
46
|
end
|
48
47
|
|
49
48
|
def sr(register = nil)
|
@@ -57,12 +56,11 @@ module PrologixGpib::Usb
|
|
57
56
|
|
58
57
|
private
|
59
58
|
|
60
|
-
def open_serial_port(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
59
|
+
def open_serial_port(path)
|
60
|
+
@serial_port = Serial.new(path)
|
61
|
+
write('++ver')
|
62
|
+
return if getline.include? 'Prologix'
|
63
|
+
|
66
64
|
raise Error, 'No Prologix USB controllers found.'
|
67
65
|
end
|
68
66
|
|
@@ -72,6 +70,12 @@ module PrologixGpib::Usb
|
|
72
70
|
true
|
73
71
|
end
|
74
72
|
|
73
|
+
def flush
|
74
|
+
return unless connected?
|
75
|
+
|
76
|
+
loop until serial_port.getbyte.nil?
|
77
|
+
end
|
78
|
+
|
75
79
|
# This method will block until the EOL terminator is received
|
76
80
|
# The lower level gets method is pure ruby, so can be safely used with Timeout.
|
77
81
|
def getline
|
@@ -79,4 +83,10 @@ module PrologixGpib::Usb
|
|
79
83
|
|
80
84
|
@serial_port.gets(EOL).chomp
|
81
85
|
end
|
86
|
+
|
87
|
+
def device_query(command)
|
88
|
+
flush
|
89
|
+
write(command)
|
90
|
+
readline
|
91
|
+
end
|
82
92
|
end
|
data/lib/prologix_gpib.rb
CHANGED
@@ -3,21 +3,24 @@
|
|
3
3
|
require 'rubyserial'
|
4
4
|
require 'prologix_gpib/version'
|
5
5
|
require 'prologix_gpib/lan'
|
6
|
-
require 'prologix_gpib/lan/commands'
|
7
6
|
require 'prologix_gpib/usb'
|
8
|
-
require 'prologix_gpib/
|
7
|
+
require 'prologix_gpib/commands'
|
9
8
|
require 'prologix_gpib/discovery'
|
10
9
|
require 'prologix_gpib/cli'
|
11
10
|
|
12
11
|
module PrologixGpib
|
13
12
|
class UsbController
|
13
|
+
def test
|
14
|
+
puts 'testing'
|
15
|
+
end
|
16
|
+
|
14
17
|
include PrologixGpib::Usb
|
15
|
-
include PrologixGpib::
|
18
|
+
include PrologixGpib::Commands
|
16
19
|
end
|
17
20
|
|
18
21
|
class LanController
|
19
22
|
include PrologixGpib::Lan
|
20
|
-
include PrologixGpib::
|
23
|
+
include PrologixGpib::Commands
|
21
24
|
end
|
22
25
|
|
23
26
|
class Finder
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prologix_gpib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Carruthers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- ".tool-versions"
|
122
122
|
- Gemfile
|
123
123
|
- Gemfile.lock
|
124
|
+
- NetFinder_info.md
|
124
125
|
- PrologixGpibEthernetManual.pdf
|
125
126
|
- PrologixGpibUsbManual-6.0.pdf
|
126
127
|
- README.md
|
@@ -131,18 +132,16 @@ files:
|
|
131
132
|
- lan_test.rb
|
132
133
|
- lib/prologix_gpib.rb
|
133
134
|
- lib/prologix_gpib/cli.rb
|
135
|
+
- lib/prologix_gpib/commands.rb
|
134
136
|
- lib/prologix_gpib/discovery.rb
|
135
137
|
- lib/prologix_gpib/lan.rb
|
136
|
-
- lib/prologix_gpib/lan/commands.rb
|
137
138
|
- lib/prologix_gpib/usb.rb
|
138
|
-
- lib/prologix_gpib/usb/commands.rb
|
139
139
|
- lib/prologix_gpib/version.rb
|
140
140
|
- package.json
|
141
141
|
- prologix_gpib.gemspec
|
142
142
|
- test_broadcast.rb
|
143
143
|
- test_script.rb
|
144
144
|
- test_server.rb
|
145
|
-
- udp_info.md
|
146
145
|
- yarn.lock
|
147
146
|
homepage: https://github.com/robcarruthers/prologix_gpib
|
148
147
|
licenses:
|
@@ -166,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
165
|
- !ruby/object:Gem::Version
|
167
166
|
version: '0'
|
168
167
|
requirements: []
|
169
|
-
rubygems_version: 3.3.
|
168
|
+
rubygems_version: 3.3.7
|
170
169
|
signing_key:
|
171
170
|
specification_version: 4
|
172
171
|
summary: Prologix GPIB controller ruby wrapper.
|
data/udp_info.md
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
Hello Rob,
|
2
|
-
|
3
|
-
NetFinder uses UDP broadcast to locate and configure GPIB-ETH controllers on a network.
|
4
|
-
You can find an implementation of the protocol in the nfcli utility
|
5
|
-
http://prologix.biz/downloads/nfcli.tar.gz
|
6
|
-
|
7
|
-
Discovery
|
8
|
-
|
9
|
-
Create NF_IDENTIFY packet.
|
10
|
-
Set sequence to a random value
|
11
|
-
Set eth_addr to all ones
|
12
|
-
Broadcast NF_IDENTIFY datagram to port 3040/UDP.
|
13
|
-
Listen for NF_IDENTIFY_REPLY datagrams.
|
14
|
-
Verify sequence matches NF_IDENTIFY packet
|
15
|
-
|
16
|
-
Configuration
|
17
|
-
|
18
|
-
Create NF*ASSIGNMENT packet
|
19
|
-
Set sequence to a random value
|
20
|
-
Set eth_addr to MAC address of desired device Set ip_type to NF_IP_DYNAMIC or NF_IP_STATIC If ip_type is NF_IP_DYNAMIC specify ip, mask and gateway addresses.
|
21
|
-
Broadcast NF* ASSIGNMENT datagram to port 3040/UDP.
|
22
|
-
Listen for NF_ASSIGNMENT_REPLY datagrams.
|
23
|
-
Verify sequence matches that of NF_ASSIGNMENT packet Check result field for NF_SUCCESS
|
24
|
-
|
25
|
-
Notes:
|
26
|
-
|
27
|
-
1. You may get multiple replies. Discard duplicate replies.
|
28
|
-
2. All multi-byte values are in network order (big-endian)
|
29
|
-
3. On multi-homed hosts, make sure broadcasts go out over all interfaces.
|
30
|
-
4. NetFinder protocol only works within the same subnet as routers will not forward UDP broadcast packets.
|