Add minimum length for Modem#wait
parent
d1103a0772
commit
ea3106cfc2
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue