Class: Extface::Driver::DaisyFx1200::RespFrame

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/models/extface/driver/daisy_fx1200.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ RespFrame

Returns a new instance of RespFrame.



427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'app/models/extface/driver/daisy_fx1200.rb', line 427

def initialize(buffer)
  # test Extface::Driver::DaisyFx1200::RespFrame.new("\x16\x16\x01\x2c\x20\x2dP\x04SSSSSS\x05\BBBB\x03")
  #                              LEN   SEQ   CMD DATA    STATUS      BCC
  if match = buffer.match(/\x01(.{1})(.{1})(.{1})(.*)\x04(.{6})\x05(.{4})\x03/nm)
    @frame = match.to_a.first
    @len, @seq, @cmd, @data, @status, @bcc = match.captures
  else
    if buffer[/^\x16+$/] # only ACKs
      @ack = true
    elsif buffer.index("\x15")
      @nak = true
    end
  end
end

Instance Attribute Details

#bccObject (readonly)

Returns the value of attribute bcc.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def bcc
  @bcc
end

#cmdObject (readonly)

Returns the value of attribute cmd.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def cmd
  @cmd
end

#dataObject (readonly)

Returns the value of attribute data.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def data
  @data
end

#frameObject (readonly)

Returns the value of attribute frame.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def frame
  @frame
end

#lenObject (readonly)

Returns the value of attribute len.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def len
  @len
end

#seqObject (readonly)

Returns the value of attribute seq.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def seq
  @seq
end

#statusObject (readonly)

Returns the value of attribute status.



421
422
423
# File 'app/models/extface/driver/daisy_fx1200.rb', line 421

def status
  @status
end

Instance Method Details

#ack?Boolean

should wait, response is yet to come

Returns:

  • (Boolean)


442
443
444
# File 'app/models/extface/driver/daisy_fx1200.rb', line 442

def ack?  #should wait, response is yet to come
  !!@ack
end

#nak?Boolean

should retry command with same seq

Returns:

  • (Boolean)


446
447
448
# File 'app/models/extface/driver/daisy_fx1200.rb', line 446

def nak?  #should retry command with same seq
  !!@nak
end