Parent

Class/Module Index [+]

Quicksearch

Termios::Termios

Encupsalates termios parameters.

See also: termios(3)

Attributes

c_cc[R]

control characters

c_cflag[R]

control modes

c_iflag[R]

input modes

c_ispeed[R]

input baud rate

c_lflag[R]

local modes

c_oflag[R]

output modes

c_ospeed[R]

output baud rate

cc[R]

control characters

cflag[R]

control modes

iflag[R]

input modes

ispeed[R]

input baud rate

lflag[R]

local modes

oflag[R]

output modes

ospeed[R]

output baud rate

Public Class Methods

new click to toggle source

Returns new Termios::Termios object.

static VALUE
termios_initialize(argc, argv, self)
    int argc;
    VALUE *argv;
    VALUE self;
{
    VALUE c_iflag, c_oflag, c_cflag, c_lflag, c_cc, c_ispeed, c_ospeed;
    VALUE cc_ary;
    int i;

    cc_ary = rb_ary_new2(NCCS);
    for (i = 0; i < NCCS; i++) {
        rb_ary_store(cc_ary, i, INT2FIX(0));
    }

    rb_ivar_set(self, id_iflag,  INT2FIX(0));
    rb_ivar_set(self, id_oflag,  INT2FIX(0));
    rb_ivar_set(self, id_cflag,  INT2FIX(0));
    rb_ivar_set(self, id_lflag,  INT2FIX(0));
    rb_ivar_set(self, id_cc,     cc_ary);
    rb_ivar_set(self, id_ispeed, INT2FIX(0));
    rb_ivar_set(self, id_ospeed, INT2FIX(0));

    rb_scan_args(argc, argv, "07", 
                 &c_iflag, &c_oflag, &c_cflag, &c_lflag, 
                 &c_cc, &c_ispeed, &c_ospeed);

    if (!NIL_P(c_iflag))
        termios_set_iflag(self, c_iflag);

    if (!NIL_P(c_oflag))
        termios_set_oflag(self, c_oflag);

    if (!NIL_P(c_cflag))
        termios_set_cflag(self, c_cflag);

    if (!NIL_P(c_lflag))
        termios_set_lflag(self, c_lflag);

    if (!NIL_P(c_cc))
        termios_set_cc(self, c_cc);

    if (!NIL_P(c_ispeed))
        termios_set_ispeed(self, c_ispeed);

    if (!NIL_P(c_ospeed))
        termios_set_ispeed(self, c_ospeed);

    return self;
}

Public Instance Methods

c_cc=(p1) click to toggle source
Alias for: cc=
c_cflag=(p1) click to toggle source
Alias for: cflag=
c_iflag=(p1) click to toggle source
Alias for: iflag=
c_ispeed=(p1) click to toggle source
Alias for: ispeed=
c_lflag=(p1) click to toggle source
Alias for: lflag=
c_oflag=(p1) click to toggle source
Alias for: oflag=
c_ospeed=(p1) click to toggle source
Alias for: ospeed=
cc = value click to toggle source

Updates control characters of the object.

static VALUE
termios_set_cc(self, value)
    VALUE self, value;
{
    Check_Type(value, T_ARRAY);
    rb_ivar_set(self, id_cc, value);

    return value;
}
Also aliased as: c_cc=
cflag = flag click to toggle source

Updates control modes of the object.

static VALUE
termios_set_cflag(self, value)
    VALUE self, value;
{
    rb_ivar_set(self, id_cflag, validate_ulong(value));

    return value;
}
Also aliased as: c_cflag=
dup click to toggle source

Produces a shallow copy of the object.

static VALUE
termios_dup(self)
    VALUE self;
{
    VALUE result;
    VALUE cc_ary;

    result = rb_call_super(0, 0);
    cc_ary = rb_ivar_get(self, id_cc);
    rb_ivar_set(result, id_cc, rb_ary_dup(cc_ary));

    return result;
}
dup click to toggle source

Produces a shallow copy of the object.

static VALUE
termios_dup(self)
    VALUE self;
{
    VALUE result;
    VALUE cc_ary;

    result = rb_call_super(0, 0);
    cc_ary = rb_ivar_get(self, id_cc);
    rb_ivar_set(result, id_cc, rb_ary_dup(cc_ary));

    return result;
}
iflag = flag click to toggle source

Updates input modes of the object.

static VALUE
termios_set_iflag(self, value)
    VALUE self, value;
{
    rb_ivar_set(self, id_iflag, validate_ulong(value));

    return value;
}
Also aliased as: c_iflag=
inspect() click to toggle source
# File lib/termios.rb, line 46
def inspect
  str = "\#<#{self.class}"
  if self.ispeed == self.ospeed
    speed = (BAUDS[self.ispeed] || "B???").to_s[1..-1]
    str << " speed #{speed} baud;"
  else
    ispeed = (BAUDS[self.ispeed] || "B???").to_s[1..-1]
    ospeed = (BAUDS[self.ospeed] || "B???").to_s[1..-1]
    str << " ispeed #{ispeed} baud; ospeed #{ospeed} baud;"
  end

  CCINDEX_NAMES.each {|ccindex|
    next if ccindex == :VMIN || ccindex == :VTIME
    str << " #{ccindex.to_s[1..-1].downcase}"
    str << "=#{VISIBLE_CHAR[self.cc[::Termios.const_get(ccindex)]]}"
  }
  str << " min=#{self.cc[VMIN]}"
  str << " time=#{self.cc[VTIME]}"

  [
    [:cflag,
     CFLAG_NAMES-[:CBAUD, :CBAUDEX, :CIBAUD, :EXTA, :EXTB],
     CFLAG_CHOICES],
    [:iflag, IFLAG_NAMES, nil],
    [:oflag, OFLAG_NAMES, OFLAG_CHOICES],
    [:lflag, LFLAG_NAMES, nil]
  ].each {|l|
    str << ";"
    flag_type, flag_names, choices = l
    flags = self.send(flag_type)
    choice_names = choices ? choices.values.flatten : []
    (flag_names-choice_names).each {|name|
      str << " "
      if choices and ns = choices[name]
        mask = ::Termios.const_get(name)
        ns.each {|n|
          if (flags & mask) == ::Termios.const_get(n)
            str << n.to_s.downcase
            break
          end
        }
      else
        str << "-" if (flags & ::Termios.const_get(name)) == 0
        str << name.to_s.downcase
      end
    }
  }

  str << ">"
  str
end
ispeed = speed click to toggle source

Updates input baud rate of the object.

static VALUE
termios_set_ispeed(self, value)
    VALUE self, value;
{
    rb_ivar_set(self, id_ispeed, validate_ulong(value));

    return value;
}
Also aliased as: c_ispeed=
lflag = flag click to toggle source

Updates local modes of the object.

static VALUE
termios_set_lflag(self, value)
    VALUE self, value;
{
    rb_ivar_set(self, id_lflag, validate_ulong(value));

    return value;
}
Also aliased as: c_lflag=
oflag = flag click to toggle source

Updates output modes of the object.

static VALUE
termios_set_oflag(self, value)
    VALUE self, value;
{
    rb_ivar_set(self, id_oflag, validate_ulong(value));

    return value;
}
Also aliased as: c_oflag=
ospeed = speed click to toggle source

Updates output baud rate of the object.

static VALUE
termios_set_ospeed(self, value)
    VALUE self, value;
{
    rb_ivar_set(self, id_ospeed, validate_ulong(value));

    return value;
}
Also aliased as: c_ospeed=

[Validate]

Generated with the Darkfish Rdoc Generator 2.