modem_check0.rb

Path: examples/modem_check0.rb
Last Update: Tue Aug 21 02:58:21 +0000 2012

Required files

fcntl   termios  

Methods

Included Modules

Termios

Constants

DEVICE = '/dev/modem'
BAUDRATE = B115200

Public Instance methods

[Source]

    # File examples/modem_check0.rb, line 8
 8: def dev_open(path)
 9:   dev = open(DEVICE, File::RDWR | File::NONBLOCK)
10:   mode = dev.fcntl(Fcntl::F_GETFL, 0)
11:   dev.fcntl(Fcntl::F_SETFL, mode & ~File::NONBLOCK)
12:   dev
13: end

[Source]

    # File examples/modem_check0.rb, line 15
15: def dump_termios(tio, banner)
16:   puts banner
17:   puts "  ispeed = #{BAUDS[tio.ispeed]}, ospeed = #{BAUDS[tio.ospeed]}"
18:   ["iflag", "oflag", "cflag", "lflag"].each do |x|
19:     flag = tio.send(x)
20:     flags = []
21:     eval("#{x.upcase}S").each do |f, sym|
22:       flags << sym.to_s if flag & f != 0
23:     end
24:     puts "   #{x} = #{flags.sort.join(' | ')}"
25:   end
26:   print "      cc ="
27:   cc = tio.cc
28:   cc.each_with_index do |x, idx|
29:     print " #{CCINDEX[idx]}=#{x}" if CCINDEX.include?(idx)
30:   end
31:   puts
32: end

[Validate]