Add minimum length for Modem#wait

develop
Guillaume DOTT 2013-09-10 11:18:40 +02:00
parent d1103a0772
commit ea3106cfc2
2 changed files with 5 additions and 5 deletions

View File

@ -27,10 +27,10 @@ module Biju
command_args = args.compact.to_hayes command_args = args.compact.to_hayes
full_command = [command, (command_args.empty? ? nil : command_args)] full_command = [command, (command_args.empty? ? nil : command_args)]
.compact.join('=') .compact.join('=') + "\r\n"
modem.write(full_command + "\r\n") modem.write(full_command)
answer = hayes_to_obj(modem.wait) answer = hayes_to_obj(modem.wait(length: full_command.length))
return block.call(answer) if block_given? return block.call(answer) if block_given?
answer answer

View File

@ -21,9 +21,9 @@ module Biju
def_delegators :connection, :close, :write def_delegators :connection, :close, :write
def wait def wait(length: 0)
buffer = '' buffer = ''
while IO.select([connection], [], [], 0.25) while IO.select([connection], [], [], 0.50) || buffer.length < length
buffer << connection.getc.chr buffer << connection.getc.chr
end end