Roger Binns
2004-10-15 05:36:17 UTC
Next pass at modem mode commands.
Have you considered a slightly different approach. The consumer code wouldlook like this:
try:
for line in foo.sendatcommand("AT+GMM"):
print line # or do whatever
for line in foo.sendatcommand("ATsomethingelse"):
print line # or do whatever
except common.ATError:
# deal with error
Whether the ERROR string should be an exception or a function return value
depends on how often it happens. I believe it won't happen that often in
production code since we know what the phone is and what we except it to
do. Obviously it will happen a lot more during development. You can
include the command in the exception attributes. (Doing it the above
way also makes it a lot more efficient over bitfling as only a single
function is called with a single response).
I also have the feeling we will need some sort of format string that
will need to be passed to the line parsing code. The existing packet
description stuff could be used, or something new.
Roger