Module: Serial::Posix
- Defined in:
- lib/ffi-serial/bsd.rb,
lib/ffi-serial/linux.rb,
lib/ffi-serial/posix.rb,
lib/ffi-serial/darwin.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#baud ⇒ Object
:nodoc:.
-
#data_bits ⇒ Object
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
-
#parity ⇒ Object
:nodoc:.
-
#read_timeout ⇒ Object
:nodoc:.
-
#read_timeout=(val) ⇒ Object
:nodoc:.
-
#stop_bits ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
:nodoc:.
Instance Method Details
#baud ⇒ Object
:nodoc:
93 94 95 |
# File 'lib/ffi-serial/posix.rb', line 93 def baud #:nodoc: LIBC::CONSTANTS['BAUD_'].fetch(LIBC.cfgetispeed(LIBC.tcgetattr(self))) end |
#data_bits ⇒ Object
:nodoc:
97 98 99 |
# File 'lib/ffi-serial/posix.rb', line 97 def data_bits #:nodoc: LIBC.tcgetattr(self).data_bits end |
#inspect ⇒ Object
:nodoc:
113 114 115 |
# File 'lib/ffi-serial/posix.rb', line 113 def inspect #:nodoc: self.to_s end |
#parity ⇒ Object
:nodoc:
105 106 107 |
# File 'lib/ffi-serial/posix.rb', line 105 def parity #:nodoc: LIBC.tcgetattr(self).parity end |
#read_timeout ⇒ Object
:nodoc:
65 66 67 68 69 70 71 |
# File 'lib/ffi-serial/posix.rb', line 65 def read_timeout #:nodoc: termios = LIBC.tcgetattr(self) return 0 unless (0 == termios[:cc_c][LIBC::CONSTANTS['VMIN']]) vtime = termios[:cc_c][LIBC::CONSTANTS['VTIME']] return -1 if (0 == vtime) (vtime.to_f / 10.0) end |
#read_timeout=(val) ⇒ Object
:nodoc:
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ffi-serial/posix.rb', line 73 def read_timeout=(val) #:nodoc: val = Float(val) termios = LIBC.tcgetattr(self) if (0 > val) termios[:cc_c][LIBC::CONSTANTS['VMIN']] = 0 termios[:cc_c][LIBC::CONSTANTS['VTIME']] = 0 val = -1 elsif (0 == val) termios[:cc_c][LIBC::CONSTANTS['VMIN']] = 1 termios[:cc_c][LIBC::CONSTANTS['VTIME']] = 0 val = 0 else val = (val * 10.0).to_i termios[:cc_c][LIBC::CONSTANTS['VMIN']] = 0 termios[:cc_c][LIBC::CONSTANTS['VTIME']] = val val = (val.to_f / 10.0) end LIBC.tcsetattr(self, termios); val end |
#stop_bits ⇒ Object
:nodoc:
101 102 103 |
# File 'lib/ffi-serial/posix.rb', line 101 def stop_bits #:nodoc: LIBC.tcgetattr(self).stop_bits end |
#to_s ⇒ Object
:nodoc:
109 110 111 |
# File 'lib/ffi-serial/posix.rb', line 109 def to_s #:nodoc: ['#<Serial:', @__serial__dev__, '>'].join.to_s end |