Module: RS232::Win32

Extended by:
FFI::Library
Defined in:
lib/rs232.rb

Overview

wraps the native Windows API functions for file IO and COMM port found in kernel32.dll

Constant Summary collapse

FILE_SHARE_DELETE =

consts from Windows seven sdk. extract with grep -i “generic_read” *.h from the /Include directory

0x00000004
FILE_SHARE_READ =
0x00000001
FILE_SHARE_WRITE =
0x00000002
FILE_SHARE_ALL =
FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE
GENERIC_READ =
0x80000000
GENERIC_WRITE =
0x40000000
CREATE_NEW =
1
CREATE_ALWAYS =
2
OPEN_EXISTING =
3
OPEN_ALWAYS =
4
FILE_ATTRIBUTE_NORMAL =
0x00000080

Class Method Summary collapse

Class Method Details

.error_checkObject



133
134
135
# File 'lib/rs232.rb', line 133

def self.error_check
  self::GetLastError().tap{ |err| puts "error: %i | 0x%.8x" % [err,err] if err != 0 }
end

.error_codeObject



128
129
130
131
# File 'lib/rs232.rb', line 128

def self.error_code
  err = self::GetLastError()
  "error code: %i | 0x%.8x" % [err,err]
end