Accept prompt in parser

develop
Guillaume DOTT 2013-09-09 15:47:15 +02:00
parent 3c677b7d29
commit 885ac26cd1
2 changed files with 9 additions and 1 deletions

View File

@ -12,7 +12,8 @@ module Biju
rule(:prefix) { str('AT') | str('at') }
# RESPONSE
rule(:response) { cr >> crlf >> (status | command) >> crlf }
rule(:response) { cr >> crlf >> (((status | command) >> crlf) | prompt) }
rule(:prompt) { str('> ') }
rule(:command) { mgl | pms | mgf | mserror }
rule(:mserror) { str('+CMS ERROR').as(:cmd) >> str(': ') >> message }

View File

@ -15,6 +15,13 @@ describe Biju::ATParser do
end
context "response" do
it "parses cmgs prompt" do
mgs = "AT+CMGS=18\r\r\n> "
expect { Biju::ATTransform.new.apply(
Biju::ATParser.new.parse(mgs)) }.not_to raise_error
end
it "parses messages list" do
messages = "AT+CMGL=1\r\r\n" <<
"+CMGL: 0,1,,23\r\n" <<