require 'serialport'
debug = false
port = "/dev/ttyS3"
if (`cardctl status 0` =~ /suspend/)
system("cardctl resume 0")
end
while (`cardctl status 0` =~ /suspend/)
sleep(0.5)
end
sp = SerialPort.new(port, 1200, 8, 1, SerialPort::NONE)
sp.flow_control = (SerialPort::HARD | SerialPort::SOFT)
sp.puts "AT@LBC1\r"
while (res = sp.gets)
puts res if debug
if (res =~ /OK/)
break
end
end
while true
buf = res = ""
sp.puts "AT@LBC?\r"
timeout = 5
while (res = sp.gets)
buf = res.chomp if res =~ /^N/
puts "#{buf} #{res}" if res =~ /^E/
if (res =~ /OK/ && timeout == 0)
break
end
timeout -= 1
end
end