From ea3106cfc2ec0384f8d769b8f0b54c02d19b7947 Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Tue, 10 Sep 2013 11:18:40 +0200 Subject: [PATCH] Add minimum length for Modem#wait --- lib/biju/hayes.rb | 6 +++--- lib/biju/modem.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/biju/hayes.rb b/lib/biju/hayes.rb index 9eac3f8..07cbbda 100644 --- a/lib/biju/hayes.rb +++ b/lib/biju/hayes.rb @@ -27,10 +27,10 @@ module Biju command_args = args.compact.to_hayes full_command = [command, (command_args.empty? ? nil : command_args)] - .compact.join('=') + .compact.join('=') + "\r\n" - modem.write(full_command + "\r\n") - answer = hayes_to_obj(modem.wait) + modem.write(full_command) + answer = hayes_to_obj(modem.wait(length: full_command.length)) return block.call(answer) if block_given? answer diff --git a/lib/biju/modem.rb b/lib/biju/modem.rb index afb78cd..7726622 100644 --- a/lib/biju/modem.rb +++ b/lib/biju/modem.rb @@ -21,9 +21,9 @@ module Biju def_delegators :connection, :close, :write - def wait + def wait(length: 0) buffer = '' - while IO.select([connection], [], [], 0.25) + while IO.select([connection], [], [], 0.50) || buffer.length < length buffer << connection.getc.chr end