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