prologix_gpib 0.4.3
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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +9 -0
- data/.tool-versions +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +49 -0
- data/PrologixGpibEthernetManual.pdf +0 -0
- data/PrologixGpibUsbManual-6.0.pdf +0 -0
- data/README.md +108 -0
- data/Rakefile +2 -0
- data/bin/console +15 -0
- data/bin/plx +5 -0
- data/bin/setup +8 -0
- data/lib/prologix_gpib/cli.rb +53 -0
- data/lib/prologix_gpib/lan.rb +3 -0
- data/lib/prologix_gpib/usb/commands.rb +203 -0
- data/lib/prologix_gpib/usb.rb +83 -0
- data/lib/prologix_gpib/version.rb +3 -0
- data/lib/prologix_gpib.rb +49 -0
- data/package.json +6 -0
- data/prologix_gpib.gemspec +38 -0
- data/test_script.rb +6 -0
- data/yarn.lock +15 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3ac3063b92e458646746217cdf903ee00fd9cceddfb317e38a614e3c60ffbf7
|
4
|
+
data.tar.gz: 239cd62ff1edf58fd02bb6bfd0af1409a87db4f2581a72ea2b409a041fd4f0ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cbb511c194b98682e19ea81aed648d07f7014c2f84e255f07a7e7737be8282e123121948c00c2dea339be776f41dffbb1530a35ad519ebc948bc284fc8ed3239
|
7
|
+
data.tar.gz: 80633e148e852b0a419fbc027ddba9717f82c654ddf2d5971421ec2614d0ee612f571987e7edaa167d14592ddaace26831b387e617def81228cc09f4df228f17
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
prologix_gpib (0.4.3)
|
5
|
+
activesupport
|
6
|
+
rubyserial
|
7
|
+
terminal-table (~> 3.0.2)
|
8
|
+
thor
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (7.0.1)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
coderay (1.1.3)
|
19
|
+
concurrent-ruby (1.1.9)
|
20
|
+
ffi (1.15.5)
|
21
|
+
i18n (1.8.11)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
method_source (1.0.0)
|
24
|
+
minitest (5.15.0)
|
25
|
+
pry (0.14.1)
|
26
|
+
coderay (~> 1.1)
|
27
|
+
method_source (~> 1.0)
|
28
|
+
rake (10.5.0)
|
29
|
+
rubyserial (0.6.0)
|
30
|
+
ffi (~> 1.9, >= 1.9.3)
|
31
|
+
terminal-table (3.0.2)
|
32
|
+
unicode-display_width (>= 1.1.1, < 3)
|
33
|
+
thor (1.2.1)
|
34
|
+
tzinfo (2.0.4)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
unicode-display_width (2.1.0)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
bundler (~> 2.0)
|
43
|
+
prologix_gpib!
|
44
|
+
pry
|
45
|
+
rake (~> 10.0)
|
46
|
+
rubyserial (~> 0.6)
|
47
|
+
|
48
|
+
BUNDLED WITH
|
49
|
+
2.2.32
|
Binary file
|
Binary file
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# PrologixGpib
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/prologix_gpib)
|
4
|
+
|
5
|
+
`prologix_gpib` is a ruby gem for accessing [Prologix GPIB controllers](http://prologix.biz/). It currently only works with USB controllers on MacOS.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'prologix_gpib'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install prologix_gpib
|
22
|
+
|
23
|
+
## USB Controller
|
24
|
+
|
25
|
+
### CLI
|
26
|
+
|
27
|
+
The gem comes with a simple cli for querying controllers:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ plx list
|
31
|
+
+-------------------------------------------------------------------------------+
|
32
|
+
| Prologix Controllers |
|
33
|
+
+-------+-------------------------------+---------+-----------------------------+
|
34
|
+
| index | Controller | Version | Path |
|
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
|
+
+-------+-------------------------------+---------+-----------------------------+
|
39
|
+
|
40
|
+
$ plx info 0
|
41
|
+
|
42
|
+
Prologix gpib-usb controller
|
43
|
+
Path: /dev/tty.usbserial-PX9HPBMB
|
44
|
+
Firmware: 6.101
|
45
|
+
Mode: Controller
|
46
|
+
Device Address: 9
|
47
|
+
Auto Read: Disabled
|
48
|
+
Read Timeout: 200
|
49
|
+
EOI Assertion: Enabled
|
50
|
+
EOS: Append CR+LF
|
51
|
+
EOT: Enabled
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
### Playing in Console
|
56
|
+
|
57
|
+
I'm enamoured by this interface, I'd like a more ruby like way of finding and connecting controllers, that works with Ethernet controllers too.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
irb(main):001:0> require 'prologix_gpib'
|
61
|
+
=> true
|
62
|
+
|
63
|
+
irb(main):002:0> paths = PrologixGpib.usb_paths
|
64
|
+
=> ["/dev/tty.usbserial-PX9HPBMB", "/dev/tty.usbserial-PXEGWA9A"]
|
65
|
+
|
66
|
+
irb(main):003:0> device = PrologixGpib::UsbController.new(paths[0])
|
67
|
+
=> #<PrologixGpib::UsbController:0x00000001574c4098 @serial_port=#<Serial:0x00000001574bfef8 @config=#<RubySerial::Posix::Termios:0x00000001574bf728>, @fd=9, @open=true>>
|
68
|
+
|
69
|
+
irb(main):004:0> device.config
|
70
|
+
=> {:device_name=>"Prologix GPIB-USB Controller", :firmware=>"6.101", :mode=>"Device", :device_address=>"9", :auto_read=>"NA", :read_timeout=>"NA", :eoi_assertion=>"Enabled", :eos=>"Append CR+LF", :eot=>"Enabled"}
|
71
|
+
|
72
|
+
irb(main):005:0> device.address
|
73
|
+
=> "9"
|
74
|
+
|
75
|
+
irb(main):006:0> device.mode = :controller
|
76
|
+
=> :controller
|
77
|
+
|
78
|
+
irb(main):007:0> device.mode
|
79
|
+
=> "0"
|
80
|
+
|
81
|
+
irb(main):008:0> device.config
|
82
|
+
=> {:device_name=>"Prologix GPIB-USB Controller", :firmware=>"6.101", :mode=>"Controller", :device_address=>"9", :auto_read=>"Disabled", :read_timeout=>"200", :eoi_assertion=>"Enabled", :eos=>"Append CR+LF", :eot=>"Enabled"}
|
83
|
+
```
|
84
|
+
|
85
|
+
### Firmware update
|
86
|
+
|
87
|
+
Some of the Device commands require the latest firmware.
|
88
|
+
|
89
|
+
```irb
|
90
|
+
device.version
|
91
|
+
=> "Prologix GPIB-USB Controller version 6.107"
|
92
|
+
```
|
93
|
+
|
94
|
+
More details here:
|
95
|
+
http://prologix.biz/gpib-usb-6.0-firmware-update.html
|
96
|
+
|
97
|
+
Download FTDI drivers for Windows
|
98
|
+
https://ftdichip.com/wp-content/uploads/2021/08/CDM212364_Setup.zip
|
99
|
+
|
100
|
+
## Development
|
101
|
+
|
102
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
103
|
+
|
104
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
105
|
+
|
106
|
+
## Contributing
|
107
|
+
|
108
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/prologix_gpib.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'prologix_gpib'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
# plx = Prologix::UsbController.new
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/plx
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'pp'
|
3
|
+
require 'prologix_gpib'
|
4
|
+
require 'terminal-table'
|
5
|
+
|
6
|
+
module PrologixGpib
|
7
|
+
class CLI < Thor
|
8
|
+
desc 'list', 'List all connected controllers'
|
9
|
+
|
10
|
+
def list
|
11
|
+
if controllers_connected?
|
12
|
+
table =
|
13
|
+
Terminal::Table.new do |t|
|
14
|
+
t.title = 'Prologix Controllers'
|
15
|
+
t.headings = %w[index Controller Version Path]
|
16
|
+
PrologixGpib.usb_paths.each.with_index do |path, index|
|
17
|
+
device = PrologixGpib::UsbController.new(path)
|
18
|
+
str = device.version.split('version')
|
19
|
+
t.add_row [index.to_s, str[0], str[1], path]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
puts table
|
23
|
+
else
|
24
|
+
puts 'No Prologix Controllers available.'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'info', 'Display Controller information'
|
29
|
+
option :path, alias: :p
|
30
|
+
def info
|
31
|
+
return unless controllers_connected?
|
32
|
+
|
33
|
+
paths = options[:path].nil? ? PrologixGpib.usb_paths : [options[:path]]
|
34
|
+
|
35
|
+
paths.each do |path|
|
36
|
+
hash = PrologixGpib::UsbController.new(path).config
|
37
|
+
puts "\n #{titleise hash.delete(:device_name)}"
|
38
|
+
puts "\tPath: #{path}"
|
39
|
+
hash.each { |k, v| puts "\t#{titleise(k)}: #{v}" }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def controllers_connected?
|
46
|
+
PrologixGpib.usb_paths.count >= 1
|
47
|
+
end
|
48
|
+
|
49
|
+
def titleise(string)
|
50
|
+
string.to_s.split('_').map(&:capitalize).join(' ')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
module PrologixGpib::Usb::Commands
|
2
|
+
def config
|
3
|
+
error_message = 'Error'
|
4
|
+
device_version = version.split('version').map(&:strip)
|
5
|
+
return { error: error_message } unless device_version.count == 2 && device_version[0].include?('Prologix')
|
6
|
+
conf = {}
|
7
|
+
conf[:device_name] = device_version[0]
|
8
|
+
conf[:firmware] = device_version[1]
|
9
|
+
conf[:mode] = { '1' => 'Controller', '0' => 'Device' }.fetch(mode, error_message)
|
10
|
+
conf[:device_address] = address[/([1-9])/].nil? ? error_message : address[/([1-9])/]
|
11
|
+
conf[:auto_read] = { '1' => 'Enabled', '0' => 'Disabled', 'Unrecognized command' => 'NA' }.fetch(auto, error_message)
|
12
|
+
tmo = timeout
|
13
|
+
conf[:read_timeout] =
|
14
|
+
case tmo
|
15
|
+
when 'Unrecognized command'
|
16
|
+
'NA'
|
17
|
+
when /([1-1000])/
|
18
|
+
tmo
|
19
|
+
else
|
20
|
+
error_message
|
21
|
+
end
|
22
|
+
conf[:eoi_assertion] = { '1' => 'Enabled', '0' => 'Disabled' }.fetch(eoi, error_message)
|
23
|
+
conf[:eos] =
|
24
|
+
case eos
|
25
|
+
when '0'
|
26
|
+
'Append CR+LF'
|
27
|
+
when '1'
|
28
|
+
'Append CR to instrument commands'
|
29
|
+
when '2'
|
30
|
+
'Append LF to instrument commands'
|
31
|
+
when '3'
|
32
|
+
'Do not append anything to instrument commands'
|
33
|
+
else
|
34
|
+
error_message
|
35
|
+
end
|
36
|
+
conf[:eot] = { '1' => 'Enabled', '0' => 'Disabled' }.fetch(eot, error_message)
|
37
|
+
eot_str = eot_char
|
38
|
+
|
39
|
+
# conf[:eot_char] = eot_str.to_i.chr[/([ -~])/].nil? ? error_message : "'#{eot_str.to_i.chr}', ascii #{eot_str}"
|
40
|
+
conf
|
41
|
+
end
|
42
|
+
|
43
|
+
# This command configures the Prologix GPIB-USB controller to be a :controller or :device.
|
44
|
+
def mode=(op_mode)
|
45
|
+
mode =
|
46
|
+
case op_mode
|
47
|
+
when :controller, 1, '1'
|
48
|
+
1
|
49
|
+
when :device, 0, '0'
|
50
|
+
0
|
51
|
+
else
|
52
|
+
''
|
53
|
+
end
|
54
|
+
write("++mode #{mode}")
|
55
|
+
end
|
56
|
+
alias set_operation_mode mode=
|
57
|
+
|
58
|
+
def mode
|
59
|
+
device_query('++mode')
|
60
|
+
end
|
61
|
+
alias operation_mode mode
|
62
|
+
|
63
|
+
# Timeout value, in milliseconds, used in the read command and spoll command.
|
64
|
+
# Any value between 1 and 3000 milliseconds.
|
65
|
+
def timeout=(milliseconds)
|
66
|
+
return unless connected? || milliseconds.class != Integer
|
67
|
+
|
68
|
+
write("++read_tmo_ms #{milliseconds}")
|
69
|
+
end
|
70
|
+
|
71
|
+
def timeout
|
72
|
+
device_query('++read_tmo_ms')
|
73
|
+
end
|
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. ***
|
77
|
+
def auto=(auto_mode)
|
78
|
+
mode =
|
79
|
+
case auto_mode
|
80
|
+
when :enable, 1, '1'
|
81
|
+
1
|
82
|
+
when :disable, 0, '0'
|
83
|
+
0
|
84
|
+
else
|
85
|
+
''
|
86
|
+
end
|
87
|
+
write("++auto #{mode}")
|
88
|
+
end
|
89
|
+
alias set_auto_read_after_write auto=
|
90
|
+
|
91
|
+
def auto
|
92
|
+
device_query('++auto')
|
93
|
+
end
|
94
|
+
alias auto_read_after_write auto
|
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.
|
98
|
+
def address=(addr)
|
99
|
+
write("++addr #{addr}")
|
100
|
+
end
|
101
|
+
alias set_address address=
|
102
|
+
|
103
|
+
def address
|
104
|
+
device_query('++addr')
|
105
|
+
end
|
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.
|
109
|
+
def eoi=(eoi_mode)
|
110
|
+
mode =
|
111
|
+
case eoi_mode
|
112
|
+
when :disable, '0', 0
|
113
|
+
0
|
114
|
+
when :enable, '1', 1
|
115
|
+
1
|
116
|
+
else
|
117
|
+
raise ArgumentError, "Invalid arg: '#{eoi_mode}'"
|
118
|
+
end
|
119
|
+
write("++eoi #{mode}")
|
120
|
+
end
|
121
|
+
|
122
|
+
def eoi
|
123
|
+
device_query('++eoi')
|
124
|
+
end
|
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
|
133
|
+
def eos=(eos_mode)
|
134
|
+
error_message = "Invalid arg: '#{eos_mode}'"
|
135
|
+
raise ArgumentError, error_message unless [0, 1, 2, 3].include? eos_mode
|
136
|
+
|
137
|
+
write("++eos #{eos_mode}")
|
138
|
+
end
|
139
|
+
|
140
|
+
def eos
|
141
|
+
device_query('++eos')
|
142
|
+
end
|
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.
|
145
|
+
def eot=(eot_mode)
|
146
|
+
mode =
|
147
|
+
case eot_mode
|
148
|
+
when 0, '0', false, :disable
|
149
|
+
0
|
150
|
+
when 1, '1', true, :enable
|
151
|
+
1
|
152
|
+
else
|
153
|
+
raise ArgumentError, "Invalid arg: '#{eot_mode}'"
|
154
|
+
end
|
155
|
+
write("++eot_enable #{mode}")
|
156
|
+
end
|
157
|
+
|
158
|
+
def eot
|
159
|
+
device_query('++eot_enable')
|
160
|
+
end
|
161
|
+
|
162
|
+
def eot_char=(char)
|
163
|
+
write("++eot_enable #{char}")
|
164
|
+
end
|
165
|
+
|
166
|
+
def eot_char
|
167
|
+
device_query('++eot_char')
|
168
|
+
end
|
169
|
+
|
170
|
+
def version
|
171
|
+
device_query('++ver')
|
172
|
+
end
|
173
|
+
|
174
|
+
def savecfg
|
175
|
+
device_query('++savecfg')
|
176
|
+
end
|
177
|
+
|
178
|
+
def spoll(address = nil)
|
179
|
+
device_query
|
180
|
+
end
|
181
|
+
|
182
|
+
def trigger(addr_list = [])
|
183
|
+
write("++trg #{addr_list.join(' ')}")
|
184
|
+
end
|
185
|
+
|
186
|
+
def reset
|
187
|
+
write('++rst')
|
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
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module PrologixGpib::Usb
|
2
|
+
require 'timeout'
|
3
|
+
require 'prologix_gpib/usb/commands'
|
4
|
+
|
5
|
+
class Error < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
EOL = "\r\n".freeze
|
9
|
+
|
10
|
+
attr_reader :serial_port
|
11
|
+
|
12
|
+
def initialize(path, mode: :controller, address: 9)
|
13
|
+
paths = path.nil? ? PrologixGpib.controller_paths : [path]
|
14
|
+
open_serial_port(paths)
|
15
|
+
flush
|
16
|
+
self.mode = mode
|
17
|
+
self.address = address
|
18
|
+
self.auto = :disable
|
19
|
+
self.eos = 0
|
20
|
+
|
21
|
+
yield self if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
def close
|
25
|
+
return unless connected?
|
26
|
+
|
27
|
+
@serial_port.close
|
28
|
+
@serial_port = nil
|
29
|
+
@serial_port.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
def write(str)
|
33
|
+
return unless connected?
|
34
|
+
|
35
|
+
@serial_port.write("#{str}#{EOL}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def read(bytes)
|
39
|
+
return unless connected?
|
40
|
+
|
41
|
+
@serial_port.read(bytes)
|
42
|
+
end
|
43
|
+
|
44
|
+
def readline
|
45
|
+
return unless connected?
|
46
|
+
|
47
|
+
t = Timeout.timeout(1, Timeout::Error, 'No response from Data Acquisistion') { getline }
|
48
|
+
end
|
49
|
+
|
50
|
+
def sr(register = nil)
|
51
|
+
write 'SR'
|
52
|
+
write '++read eoi'
|
53
|
+
array = []
|
54
|
+
24.times { array << readline }
|
55
|
+
array.map! { |byte| '%08b' % byte.to_i }
|
56
|
+
register.nil? ? array : array[register - 1]
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def open_serial_port(paths)
|
62
|
+
paths.each do |path|
|
63
|
+
@serial_port = Serial.new(path)
|
64
|
+
write('++ver')
|
65
|
+
return if getline.include? 'Prologix'
|
66
|
+
end
|
67
|
+
raise Error, 'No Prologix USB controllers found.'
|
68
|
+
end
|
69
|
+
|
70
|
+
def connected?
|
71
|
+
raise Error, 'ConnectionError: No open Prologix device connections.' if @serial_port.nil?
|
72
|
+
|
73
|
+
true
|
74
|
+
end
|
75
|
+
|
76
|
+
# This method will block until the EOL terminator is received
|
77
|
+
# The lower level gets method is pure ruby, so can be safely used with Timeout.
|
78
|
+
def getline
|
79
|
+
return unless connected?
|
80
|
+
|
81
|
+
@serial_port.gets(EOL).chomp
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubyserial'
|
4
|
+
require 'prologix_gpib/version'
|
5
|
+
require 'prologix_gpib/lan'
|
6
|
+
require 'prologix_gpib/usb'
|
7
|
+
require 'prologix_gpib/cli'
|
8
|
+
|
9
|
+
module PrologixGpib
|
10
|
+
class UsbController
|
11
|
+
include PrologixGpib::Usb
|
12
|
+
include PrologixGpib::Usb::Commands
|
13
|
+
end
|
14
|
+
|
15
|
+
class LanController
|
16
|
+
include PrologixGpib::Lan
|
17
|
+
end
|
18
|
+
|
19
|
+
# Ideally this class needs to handle finding all avaliable Prologix GPIB controllers (USB and Ethernet),
|
20
|
+
# But for now it simply passes the Prologix USB device paths onto the controller class
|
21
|
+
# No windows serial support just yet.
|
22
|
+
class << self
|
23
|
+
def new
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
# Find first avaliable Prologix controller and return a valid controller object
|
28
|
+
def open; end
|
29
|
+
|
30
|
+
def usb_paths
|
31
|
+
usb_controller_paths
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def usb_controller_paths
|
37
|
+
path_str, dir =
|
38
|
+
if RubySerial::ON_LINUX
|
39
|
+
%w[ttyUSB /dev/]
|
40
|
+
elsif RubySerial::ON_WINDOWS
|
41
|
+
['TODO: Implement find device for Windows', 'You lazy bugger']
|
42
|
+
else
|
43
|
+
%w[tty.usbserial /dev/]
|
44
|
+
end
|
45
|
+
|
46
|
+
Dir.glob("#{dir}#{path_str}*")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'prologix_gpib/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'prologix_gpib'
|
9
|
+
spec.version = PrologixGpib::VERSION
|
10
|
+
spec.authors = ['Rob Carruthers']
|
11
|
+
spec.email = ['robcarruthers@mac.com']
|
12
|
+
|
13
|
+
spec.summary = 'Prologix GPIB controller ruby wrapper.'
|
14
|
+
spec.description = 'Ruby wrapper for the Prologix GPIB controllers, USB & Ethernet.'
|
15
|
+
spec.homepage = 'https://github.com/robcarruthers/prologix_gpib'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# spec.metadata['allowed_push_host'] = "http://mygemserver.com'"
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/robcarruthers/prologix_gpib'
|
22
|
+
spec.metadata['changelog_uri'] = 'https://github.com/robcarruthers/prologix_gpib'
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) { `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } }
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_dependency 'activesupport'
|
32
|
+
spec.add_dependency 'rubyserial'
|
33
|
+
spec.add_dependency 'thor'
|
34
|
+
spec.add_dependency 'terminal-table', '~> 3.0.2'
|
35
|
+
|
36
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
37
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
38
|
+
end
|
data/test_script.rb
ADDED
data/yarn.lock
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
2
|
+
# yarn lockfile v1
|
3
|
+
|
4
|
+
|
5
|
+
"@prettier/plugin-ruby@^2.0.0":
|
6
|
+
version "2.0.0"
|
7
|
+
resolved "https://registry.yarnpkg.com/@prettier/plugin-ruby/-/plugin-ruby-2.0.0.tgz#a9f2d4183b56a9db9f80bbc685832a3b78685793"
|
8
|
+
integrity sha512-pA0rjTi5J7cT86XPNhXp7CpdV2Tlyj5oqDIsnQRxMu2P7LY2KJI/pyOSM8pzTH8BgRyQfe1P1NPCcTwxUnUWtQ==
|
9
|
+
dependencies:
|
10
|
+
prettier ">=2.3.0"
|
11
|
+
|
12
|
+
prettier@>=2.3.0, prettier@^2.5.1:
|
13
|
+
version "2.5.1"
|
14
|
+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
|
15
|
+
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prologix_gpib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Carruthers
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyserial
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: terminal-table
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
description: Ruby wrapper for the Prologix GPIB controllers, USB & Ethernet.
|
98
|
+
email:
|
99
|
+
- robcarruthers@mac.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".DS_Store"
|
105
|
+
- ".gitignore"
|
106
|
+
- ".tool-versions"
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- PrologixGpibEthernetManual.pdf
|
110
|
+
- PrologixGpibUsbManual-6.0.pdf
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/plx
|
115
|
+
- bin/setup
|
116
|
+
- lib/prologix_gpib.rb
|
117
|
+
- lib/prologix_gpib/cli.rb
|
118
|
+
- lib/prologix_gpib/lan.rb
|
119
|
+
- lib/prologix_gpib/usb.rb
|
120
|
+
- lib/prologix_gpib/usb/commands.rb
|
121
|
+
- lib/prologix_gpib/version.rb
|
122
|
+
- package.json
|
123
|
+
- prologix_gpib.gemspec
|
124
|
+
- test_script.rb
|
125
|
+
- yarn.lock
|
126
|
+
homepage: https://github.com/robcarruthers/prologix_gpib
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata:
|
130
|
+
homepage_uri: https://github.com/robcarruthers/prologix_gpib
|
131
|
+
source_code_uri: https://github.com/robcarruthers/prologix_gpib
|
132
|
+
changelog_uri: https://github.com/robcarruthers/prologix_gpib
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubygems_version: 3.3.3
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: Prologix GPIB controller ruby wrapper.
|
152
|
+
test_files: []
|