lib/lxi/device.rb in lxi_rb-0.7.0 vs lib/lxi/device.rb in lxi_rb-0.7.1

- old
+ new

@@ -13,47 +13,47 @@ @protocol = protocol @id = -1 connect - yield self if block_given? + yield(self) if block_given? end def connect Lxi.init_lxi_session @id = Lxi.lxi_connect(@address, @port, @name, @timeout, @protocol) - raise Error, 'LXI Connection Error' if @id == LXI_ERROR + raise(Error, 'LXI Connection Error') if @id == LXI_ERROR true end alias open connect def disconnect Lxi.lxi_disconnect(@id) end alias close disconnect - def send(message) + def write(message) bytes_sent = Lxi.lxi_send(@id, message, message.length, @timeout) - raise Error, 'LXI communications error' unless bytes_sent.positive? + raise(Error, 'LXI communications error') unless bytes_sent.positive? bytes_sent end - alias scpi send - alias write send + alias scpi write + alias send write def read(length) message = FFI::MemoryPointer.new(:char, length) bytes_received = Lxi.lxi_receive(@id, message, length, @timeout) - raise Error, 'LXI communications error' unless bytes_received.positive? + raise(Error, 'LXI communications error') unless bytes_received.positive? message.read_string end alias gets read def query(message) - send message - read 10_000 + write(message) + read(10_000) end end end