module PrologixGpib::Usb::Commands
Public Instance Methods
# File lib/prologix_gpib/usb/commands.rb, line 103 def address device_query('++addr') end
In :controller mode, address refers to the GPIB address of the instrument being controlled. In :device mode, it is the address of the GPIB peripheral that Prologix GPIB-USB controller is emulating.
# File lib/prologix_gpib/usb/commands.rb, line 98 def address=(addr) write("++addr #{addr}") end
# File lib/prologix_gpib/usb/commands.rb, line 91 def auto device_query('++auto') end
PrologixGPIB-USB controller can be configured to automatically address instruments to ‘talk’ after sending a command in order to read the response. *** Avaliable in Controller mode. When enabled can cause the prologix controller to lockup. ***
# File lib/prologix_gpib/usb/commands.rb, line 77 def auto=(auto_mode) mode = case auto_mode when :enable, 1, '1' 1 when :disable, 0, '0' 0 else '' end write("++auto #{mode}") end
# File lib/prologix_gpib/usb/commands.rb, line 2 def config error_message = 'Error' device_version = version.split('version').map(&:strip) return { error: error_message } unless device_version.count == 2 && device_version[0].include?('Prologix') conf = {} conf[:device_name] = device_version[0] conf[:firmware] = device_version[1] conf[:mode] = { '1' => 'Controller', '0' => 'Device' }.fetch(mode, error_message) conf[:device_address] = address[/([1-9])/].nil? ? error_message : address[/([1-9])/] conf[:auto_read] = { '1' => 'Enabled', '0' => 'Disabled', 'Unrecognized command' => 'NA' }.fetch(auto, error_message) tmo = timeout conf[:read_timeout] = case tmo when 'Unrecognized command' 'NA' when /([1-1000])/ tmo else error_message end conf[:eoi_assertion] = { '1' => 'Enabled', '0' => 'Disabled' }.fetch(eoi, error_message) conf[:eos] = case eos when '0' 'Append CR+LF' when '1' 'Append CR to instrument commands' when '2' 'Append LF to instrument commands' when '3' 'Do not append anything to instrument commands' else error_message end conf[:eot] = { '1' => 'Enabled', '0' => 'Disabled' }.fetch(eot, error_message) eot_str = eot_char # conf[:eot_char] = eot_str.to_i.chr[/([ -~])/].nil? ? error_message : "'#{eot_str.to_i.chr}', ascii #{eot_str}" conf end
# File lib/prologix_gpib/usb/commands.rb, line 122 def eoi device_query('++eoi') end
This command enables or disables the assertion of the EOI signal with the last character of any command sent over GPIB port. Some instruments require EOI signal to be asserted in order to properly detect the end of a command.
# File lib/prologix_gpib/usb/commands.rb, line 109 def eoi=(eoi_mode) mode = case eoi_mode when :disable, '0', 0 0 when :enable, '1', 1 1 else raise ArgumentError, "Invalid arg: '#{eoi_mode}'" end write("++eoi #{mode}") end
# File lib/prologix_gpib/usb/commands.rb, line 140 def eos device_query('++eos') end
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. This command does not affect data from instruments received over GPIB port. EXAMPLES: 0 Append CR+LF 1 Append CR to instrument commands 2 Append LF to instrument commands 3 Do not append anything to instrument commands
# File lib/prologix_gpib/usb/commands.rb, line 133 def eos=(eos_mode) error_message = "Invalid arg: '#{eos_mode}'" raise ArgumentError, error_message unless [0, 1, 2, 3].include? eos_mode write("++eos #{eos_mode}") end
# File lib/prologix_gpib/usb/commands.rb, line 158 def eot device_query('++eot_enable') end
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.
# File lib/prologix_gpib/usb/commands.rb, line 145 def eot=(eot_mode) mode = case eot_mode when 0, '0', false, :disable 0 when 1, '1', true, :enable 1 else raise ArgumentError, "Invalid arg: '#{eot_mode}'" end write("++eot_enable #{mode}") end
# File lib/prologix_gpib/usb/commands.rb, line 166 def eot_char device_query('++eot_char') end
# File lib/prologix_gpib/usb/commands.rb, line 162 def eot_char=(char) write("++eot_enable #{char}") end
# File lib/prologix_gpib/usb/commands.rb, line 190 def flush return unless connected? loop until serial_port.getbyte.nil? end
# File lib/prologix_gpib/usb/commands.rb, line 58 def mode device_query('++mode') end
This command configures the Prologix GPIB-USB controller to be a :controller or :device.
# File lib/prologix_gpib/usb/commands.rb, line 44 def mode=(op_mode) mode = case op_mode when :controller, 1, '1' 1 when :device, 0, '0' 0 else '' end write("++mode #{mode}") end
# File lib/prologix_gpib/usb/commands.rb, line 186 def reset write('++rst') end
# File lib/prologix_gpib/usb/commands.rb, line 174 def savecfg device_query('++savecfg') end
# File lib/prologix_gpib/usb/commands.rb, line 178 def spoll(address = nil) device_query end
# File lib/prologix_gpib/usb/commands.rb, line 71 def timeout device_query('++read_tmo_ms') end
Timeout value, in milliseconds, used in the read command and spoll command. Any value between 1 and 3000 milliseconds.
# File lib/prologix_gpib/usb/commands.rb, line 65 def timeout=(milliseconds) return unless connected? || milliseconds.class != Integer write("++read_tmo_ms #{milliseconds}") end
# File lib/prologix_gpib/usb/commands.rb, line 182 def trigger(addr_list = []) write("++trg #{addr_list.join(' ')}") end
# File lib/prologix_gpib/usb/commands.rb, line 170 def version device_query('++ver') end
Private Instance Methods
# File lib/prologix_gpib/usb/commands.rb, line 198 def device_query(command) flush write(command) readline end