Module: Adept::LowLevel::Connection

Included in:
EnhancedParallel, JTAG
Defined in:
lib/adept/low_level/connection.rb

Overview

Module mix-in which adds the basic functionality for

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Hook which runs whenever a module extends AdeptConnection.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/adept/low_level/connection.rb', line 15

def self.extended(base)

  #Attach each of the relevant functions to the extending class.
  base.module_eval do
  
    #Returns the amount of connections the given port provides.
    attach_adept_function :GetPortCount, [:ulong, :pointer]

    #Enable the JTAG port with the given number. Only one JTAG device can be active at a time!
    attach_adept_function :EnableEx, [:ulong, :int32]

    #Disable the currently active JTAG port.
    attach_adept_function :Disable, [:ulong]

  end
end

Instance Method Details

#port_count(device) ⇒ Object

Returns the number of JTAG ports the given device offers.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/adept/low_level/connection.rb', line 35

def port_count(device)

  #Create a pointer to a new Int32 in memory...
  count_pointer = FFI::MemoryPointer.new(:int32)

  #... and fill it with the number of available JTAG ports.
  GetPortCount(device, count_pointer)

  #Return the acquired count as a ruby integer.
  count_pointer.get_int32(0)

end

#supported?(device) ⇒ Boolean

Returns a true-like value if the given device supports JTAG, or nil if it does not.

Returns:

  • (Boolean)


52
53
54
# File 'lib/adept/low_level/connection.rb', line 52

def supported?(device)
  port_count(device).nonzero?
end