Module Expr Str ImportFrom alias Import alias Expr Call AttributeLoad AttributeLoad NameLoad attr attr Num Str Import alias Import alias Import alias Import alias TryExcept body Import alias handlers ExceptHandler type NameLoad body Import alias identifier ClassDef bases NameLoad body Pass decorator_list ClassDef bases AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore AttributeLoad NameLoad attr attr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str While AttributeLoad NameLoad attr body TryExcept body Expr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr handlers ExceptHandler body Expr Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr Str body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str Num body Expr Str With AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListLoad While NameLoad body TryExcept body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad If CompareEq NameLoad NameLoad body Return NameLoad orelse Expr Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Import alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign AttributeStore AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If BoolOpAnd Call AttributeLoad NameLoad attr Str Call AttributeLoad AttributeLoad NameLoad attr attr Str body Assign NameStore SubscriptLoad NameLoad Slice Num BinOpAdd Num Num Assign NameStore Call AttributeLoad Str attr GeneratorExp BinOpMod Str Call NameLoad NameLoad comprehension NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Slice Num Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str With AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str TupleLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Str keyword Str decorator_list FunctionDef arguments args NameParam defaults body Return Call AttributeLoad NameLoad attr Str decorator_list decorator_list Assign NameStore Call AttributeLoad NameLoad attr Str keyword Num keyword Num With Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameStore body Expr Call AttributeLoad NameLoad attr Expr Call NameLoad Str Expr Call NameLoad Str Call AttributeLoad NameLoad attr
N/A N/A 
Example of a AT command protocol.

https://en.wikipedia.org/wiki/Hayes_command_set
http://www.itu.int/rec/T-REC-V.250-200307-I/en
 __future__ print_function N/A sys N/A N/A N/A N/A sys path insert 0 .. N/A logging N/A serial N/A serial.threaded N/A threading N/A N/A N/A queue N/A N/A N/A ImportError N/A N/A Queue queue ATException N/A Exception N/A N/A N/A ATProtocol N/A N/A N/A serial threaded LineReader N/A N/A TERMINATOR __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super ATProtocol self __init__ N/A N/A self alive True N/A N/A self responses N/A N/A queue Queue N/A N/A self events N/A N/A queue Queue N/A N/A self _event_thread N/A N/A threading Thread target N/A self _run_event N/A N/A N/A self _event_thread daemon True N/A N/A N/A self _event_thread name at-event N/A N/A N/A N/A self _event_thread start N/A N/A self lock N/A N/A threading Lock N/A stop N/A N/A self N/A N/A N/A 
        Stop the event processing thread, abort pending commands, if any.
         N/A N/A self alive False N/A N/A N/A N/A self events put None N/A N/A N/A N/A self responses put <exit> N/A _run_event N/A N/A self N/A N/A N/A 
        Process events in a separate thread so that input thread is not
        blocked.
         N/A N/A self alive N/A N/A N/A N/A N/A N/A self handle_event N/A N/A N/A self events get N/A N/A N/A N/A N/A N/A logging exception _run_event N/A handle_line N/A N/A self line N/A N/A N/A 
        Handle input from serial port, check for events.
         N/A N/A N/A line startswith + N/A N/A N/A N/A N/A self events put line N/A N/A N/A N/A N/A self responses put line N/A handle_event N/A N/A self event N/A N/A N/A 
        Spontaneous message received.
         N/A N/A print event received: event N/A command N/A N/A self command response timeout N/A OK 5 N/A N/A 
        Set an AT command and wait for the response.
         N/A N/A self lock N/A N/A N/A N/A self write_line command N/A lines N/A N/A True N/A N/A N/A N/A line N/A N/A N/A self responses get timeout timeout N/A N/A line response N/A N/A lines N/A N/A N/A N/A lines append line N/A N/A N/A N/A queue Empty N/A N/A N/A ATException N/A AT command timeout (%r) N/A command N/A N/A N/A N/A __name__ __main__ N/A N/A time PAN1322 N/A ATProtocol N/A N/A 
        Example communication with PAN1322 BT module.

        Some commands do not respond with OK but with a '+...' line. This is
        implemented via command_with_event_response and handle_event, because
        '+...' lines are also used for real events.
         __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super PAN1322 self __init__ N/A N/A self event_responses N/A N/A queue Queue N/A N/A self _awaiting_response_for None N/A connection_made N/A N/A self transport N/A N/A N/A N/A N/A N/A super PAN1322 self connection_made transport N/A N/A N/A N/A self transport serial rts False N/A N/A N/A time sleep 0.3 N/A N/A N/A N/A N/A self transport serial reset_input_buffer N/A handle_event N/A N/A self event N/A N/A N/A Handle events and command responses starting with '+...' N/A N/A N/A N/A event startswith +RRBDRES N/A N/A N/A self _awaiting_response_for startswith AT+JRBD N/A N/A rev N/A event N/A 9 N/A 9 12 N/A mac N/A N/A : join N/A N/A %02X N/A ord x N/A x N/A N/A N/A rev decode hex N/A -1 N/A N/A N/A N/A self event_responses put mac N/A N/A N/A N/A logging warning N/A unhandled event: %r event N/A command_with_event_response N/A N/A self command N/A N/A N/A Send a command that responds with '+...' line N/A N/A self lock N/A N/A N/A self _awaiting_response_for command N/A N/A N/A N/A self transport write N/A %s
 N/A N/A N/A command encode N/A self ENCODING N/A self UNICODE_HANDLING N/A response N/A N/A N/A self event_responses get N/A N/A self _awaiting_response_for None N/A response N/A reset N/A N/A self N/A N/A N/A N/A N/A self command AT+JRES response ROK N/A get_mac_address N/A N/A self N/A N/A N/A N/A N/A self command_with_event_response AT+JRBD N/A N/A N/A ser N/A N/A serial serial_for_url spy://COM1 baudrate 115200 timeout 1 N/A N/A N/A N/A serial threaded ReaderThread ser PAN1322 bt_module N/A N/A N/A N/A bt_module reset N/A N/A print reset OK N/A N/A print MAC address is N/A N/A bt_module get_mac_address