LoginSignup
0
0

More than 5 years have passed since last update.

全自動起動時間計測器を作ってみた

Last updated at Posted at 2017-08-16

ビットトレードワンの赤外線リモコンを制御できるmruby-remoconとmruby-pingで起動時間計測器を作ってみました。

仕組みはmruby-remoconで秋月電子のSSRをコントロールできるようにして100VのOFF/ONを行い、その後にpingが通るまでの時間を計測します。

boottime.png

mruby-pingはlibnetというライブラリを使っていてFreeBSDの場合pkgかportsからインストールが必要でした。

FreeBSD/amd64 10.3Rでmruby 1.2で実行しています。

boottime.rb
def ir(pat)
  t = Remocon.new()
  num = 0
  while num < 3 do
    t.send(pat)
    usleep 45*1000
    num = num + 1
  end
end

sig = [0x33, 0x89, 0x00]
ir(sig)
usleep 1000*1000
sig = [0x33, 0x09, 0x00]
ir(sig)

start_time = Time.now

pin = ARPPinger.new('re0')

pin.set_targets([ARGV[0]])

while pin.send_pings(1).count == 0 do
  sleep 1
end

p "#{Time.now - start_time}s"

mruby-remoconとmruby-pingともにroot権限が必要なのでsudoで実行します。

結果

microserver % sudo mruby boottime.rb 10.10.10.60
"29.830396s"
microserver % sudo mruby boottime.rb 10.10.10.65
"36.884279s"

最初がFreeBSD/MT7620で後の方がFreeBSD/RT5350です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0