Class: Pport::WinPport
- Inherits:
-
Object
- Object
- Pport::WinPport
- Defined in:
- lib/win_pport.rb
Overview
Class for interacting with a parallel port in microsoft windows using the inpout32 DLL.
Instance Method Summary collapse
-
#initialize(address) ⇒ WinPport
constructor
Creates a reader and a write function from the inpout32 library.
-
#read ⇒ Object
Reads the value of the port at address.
-
#write(val) ⇒ Object
Writes the value val to the port at address.
Constructor Details
#initialize(address) ⇒ WinPport
Creates a reader and a write function from the inpout32 library.
28 29 30 31 32 33 |
# File 'lib/win_pport.rb', line 28 def initialize(address) @address = address @reader = Win32API.new('inpout32', 'Inp32', ['i'], 'i') @writer = Win32API.new('inpout32', 'Out32', ['i', 'i'], 'v') end |
Instance Method Details
#read ⇒ Object
Reads the value of the port at address.
36 37 38 |
# File 'lib/win_pport.rb', line 36 def read() return @reader.call(@address) end |
#write(val) ⇒ Object
Writes the value val to the port at address
val: The value to be written, on a standard parallel port it should be an integer from 0 to 255
44 45 46 |
# File 'lib/win_pport.rb', line 44 def write(val) @writer.call(@address, val) end |