class Dread::EndpointEvent

Constants

CONTROL_DATA
CONTROL_STATUS
DEPEVT_EPCMDCMPLT
DEPEVT_RXTXFIFOEVT
DEPEVT_STREAMEVT
DEPEVT_XFERCOMPLETE
DEPEVT_XFERINPROGRESS
DEPEVT_XFERNOTREADY
STREAMEVT_FOUND
STREAMEVT_NOTFOUND
TRANSFER_ACTIVE
XFERCOMPLETE_IOC
XFERCOMPLETE_LST
XFERCOMPLETE_SHORT

Attributes

epnum[R]
parameters[R]
status[R]
type[R]

Public Class Methods

new(line) click to toggle source
Calls superclass method
# File lib/dread/endpoint_event.rb, line 30
def initialize(line)
  super

  @event_type = {
    DEPEVT_XFERCOMPLETE => "Transfer Complete",
    DEPEVT_XFERINPROGRESS => "Transfer In Progress",
    DEPEVT_XFERNOTREADY => "Transfer Not Ready",
    DEPEVT_RXTXFIFOEVT => "FIFO Event",
    DEPEVT_STREAMEVT => "Stream",
    DEPEVT_EPCMDCMPLT => "Command Complete",
  }

  decode
end

Public Instance Methods

decode() click to toggle source
Calls superclass method
# File lib/dread/endpoint_event.rb, line 45
def decode
  @event_data = super

  @epnum = field(@event_data, 5, 1)
  @type = field(@event_data, 9, 6)
  @status = field(@event_data, 15, 12)
  @parameters = field(@event_data, 31, 16)
end
endpoint() click to toggle source
# File lib/dread/endpoint_event.rb, line 72
def endpoint
  num = @epnum >> 1
  dir = (@epnum & 1) == 1 ? "in" : "out"

  "ep#{num}#{dir}"
end
to_s() click to toggle source
Calls superclass method
# File lib/dread/endpoint_event.rb, line 54
def to_s
  str = super

  str += ": #{endpoint}: "
  str += @event_type[@type]

  case @type
  when DEPEVT_XFERCOMPLETE
    str += xfer_complete_status
  when DEPEVT_XFERNOTREADY
    str += xfer_not_ready_status
  when DEPEVT_STREAMEVT
    str += stream_extras
  end

  str
end

Private Instance Methods

stream_extras() click to toggle source
# File lib/dread/endpoint_event.rb, line 127
def stream_extras
  case @status
  when STREAMEVT_FOUND
    "#{@parameters} Found"
  when STREAMEVT_NOTFOUND
    "#{@parameters} Not Found"
  end
end
xfer_complete_status() click to toggle source
# File lib/dread/endpoint_event.rb, line 81
def xfer_complete_status
  str = " ["

  if ((@status & XFERCOMPLETE_SHORT) == XFERCOMPLETE_SHORT)
    str += "S"
  else
    str += "s"
  end

  if ((@status & XFERCOMPLETE_IOC) == XFERCOMPLETE_IOC)
    str += "I"
  else
    str += 'i'
  end

  if ((@status & XFERCOMPLETE_LST) == XFERCOMPLETE_LST)
    str += "L"
  else
    str += "l"
  end

  str += "] "
  str
end
xfer_not_ready_status() click to toggle source
# File lib/dread/endpoint_event.rb, line 106
def xfer_not_ready_status
  str = ""

  if ((@status & TRANSFER_ACTIVE) == TRANSFER_ACTIVE)
    str += " (Active)"
  else
    str += " (Not Active)"
  end

  if @epnum == 0 || @epnum == 1
    case (@status & (3 << 0))
    when CONTROL_DATA
      str += " [ Data Phase ]"
    when CONTROL_STATUS
      str += " [ Status Phase ]"
    end
  end

  str
end