class ENZI::Serial

Serialクラス

シリアルIOを提供するクラス
D0ポートがTX(送信)、D1ポートがRX(受信)となる

SAMPLE

ser = Serial.new(9600)
ser.puts "Hello"
p ser.read

Public Class Methods

new(baud) click to toggle source
シリアルオープン
シリアルオブジェクトを生成し、シリアルポートをオープンする。

Args

baud 転送ボーレート (300/600/1200/2400/4800/9600/19200/38400/57600/115200)

Return

シリアルオブジェクト

Exception

# File enzi-lib.rb, line 275
def initialize(baud)
  self
end

Public Instance Methods

available() click to toggle source
シリアル受信データ長取得
シリアル受信しているデータ長を返す。

Args

Return

受信済みデータ長(Fixnum)

Exception

# File enzi-lib.rb, line 338
def available
  0
end
close() click to toggle source
シリアルクローズ
シリアルポートをクローズする。

Args

Return

nil

Exception

# File enzi-lib.rb, line 285
def close
  nil
end
flush() click to toggle source
シリアルフラッシュ
シリアル未送信データをフラッシュする。

Args

Return

nil

Exception

# File enzi-lib.rb, line 328
def flush
  nil
end
puts(str) click to toggle source
シリアル文字列出力
シリアルポートへ文字列データを出力する。

Args

str 出力文字列

Return

nil

Exception

# File enzi-lib.rb, line 318
def puts(str)
  nil
end
read() click to toggle source
シリアル入力
シリアルポートより1バイトデータを入力する。
受信データがない場合は -1 を返す。

Args

Return

受信データ(Fixnum)

Exception

# File enzi-lib.rb, line 296
def read
  -1
end
write(v) click to toggle source
シリアル出力
シリアルポートへ1バイトデータを出力する。

Args

v 出力データ(Fixnum)

Return

nil

Exception

# File enzi-lib.rb, line 307
def write(v)
  nil
end