Class: SerialPort
- Inherits:
-
IO
show all
- Defined in:
- lib/serialport.rb,
ext/serialport.c
Overview
SerialPort Class
The SerialPort class is a loose wrapper around C functions for interfacing with RS232 serial ports.
Constant Summary
collapse
- NONE =
INT2FIX(NONE)
- HARD =
INT2FIX(HARD)
- SOFT =
INT2FIX(SOFT)
- SPACE =
INT2FIX(SPACE)
- MARK =
INT2FIX(MARK)
- EVEN =
INT2FIX(EVEN)
- ODD =
INT2FIX(ODD)
- VERSION =
rb_str_new2(RUBY_SERIAL_PORT_VERSION)
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.create ⇒ Object
.new(port, *params) ⇒ Object
Create a new instance of SerialPort referencing a particular system RS232 port. On *nix systems this is usually found under /dev as a tty device. In windows this is a COM* port such as COM1.
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/serialport.rb', line 32
def SerialPort::new(port, *params)
sp = create(port)
begin
sp.set_modem_params(*params)
rescue
sp.close
raise
end
return sp
end
|
.open(port, *params) ⇒ Object
Like new, this opens a port on the system. Open has been designed for block usage/short temporary access to a serial port.
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/serialport.rb', line 45
def SerialPort::open(port, *params)
sp = create(port)
begin
sp.set_modem_params(*params)
if (block_given?)
yield sp
sp.close
return nil
end
rescue
sp.close
raise
end
return sp
end
|
Instance Method Details
#baud ⇒ Object
72
73
|
# File 'ext/serialport.c', line 72
static VALUE sp_get_data_rate(self)
VALUE self;
|
#baud= ⇒ Object
24
25
|
# File 'ext/serialport.c', line 24
static VALUE sp_set_data_rate(self, data_rate)
VALUE self, data_rate;
|
#break ⇒ Object
#cts ⇒ Object
130
131
|
# File 'ext/serialport.c', line 130
static VALUE sp_get_cts(self)
VALUE self;
|
#data_bits ⇒ Object
82
83
|
# File 'ext/serialport.c', line 82
static VALUE sp_get_data_bits(self)
VALUE self;
|
#data_bits= ⇒ Object
36
37
|
# File 'ext/serialport.c', line 36
static VALUE sp_set_data_bits(self, data_bits)
VALUE self, data_bits;
|
#dcd ⇒ Object
150
151
|
# File 'ext/serialport.c', line 150
static VALUE sp_get_dcd(self)
VALUE self;
|
#dsr ⇒ Object
140
141
|
# File 'ext/serialport.c', line 140
static VALUE sp_get_dsr(self)
VALUE self;
|
#dtr ⇒ Object
#dtr= ⇒ Object
#flow_control ⇒ Object
#flow_control= ⇒ Object
#get_modem_params ⇒ Object
112
113
|
# File 'ext/serialport.c', line 112
static VALUE sp_get_modem_params(self)
VALUE self;
|
#get_signals ⇒ Object
170
171
|
# File 'ext/serialport.c', line 170
static VALUE sp_signals(self)
VALUE self;
|
#modem_params ⇒ Object
112
113
|
# File 'ext/serialport.c', line 112
static VALUE sp_get_modem_params(self)
VALUE self;
|
#modem_params= ⇒ Object
#parity ⇒ Object
102
103
|
# File 'ext/serialport.c', line 102
static VALUE sp_get_parity(self)
VALUE self;
|
#parity= ⇒ Object
60
61
|
# File 'ext/serialport.c', line 60
static VALUE sp_set_parity(self, parity)
VALUE self, parity;
|
#read_timeout ⇒ Object
#read_timeout= ⇒ Object
#ri ⇒ Object
160
161
|
# File 'ext/serialport.c', line 160
static VALUE sp_get_ri(self)
VALUE self;
|
#rts ⇒ Object
#rts= ⇒ Object
#set_modem_params ⇒ Object
#signals ⇒ Object
170
171
|
# File 'ext/serialport.c', line 170
static VALUE sp_signals(self)
VALUE self;
|
#stop_bits ⇒ Object
92
93
|
# File 'ext/serialport.c', line 92
static VALUE sp_get_stop_bits(self)
VALUE self;
|
#stop_bits= ⇒ Object
48
49
|
# File 'ext/serialport.c', line 48
static VALUE sp_set_stop_bits(self, stop_bits)
VALUE self, stop_bits;
|
#write_timeout ⇒ Object
#write_timeout= ⇒ Object