@@ -77,6 +77,7 @@ def connect(self, portstr=None):
7777
7878 def close (self ):
7979 if self .is_connected ():
80+ debug ("Closing connection" )
8081 self .port .close ()
8182 self .port = None
8283
@@ -108,7 +109,7 @@ def load_commands(self):
108109 if not self .has_command (get ):
109110 continue
110111
111- response = self .query (get ) # ask nicely
112+ response = self .send (get ) # ask nicely
112113
113114 if response .is_null ():
114115 continue
@@ -137,26 +138,34 @@ def print_commands(self):
137138 for c in self .supported_commands :
138139 print str (c )
139140
141+
140142 def has_command (self , c ):
141143 return commands .has (c .get_mode_int (), c .get_pid_int ()) and c .supported
142144
143- def query (self , command , force = False ):
144- """ send the given command, retrieve response, and parse response """
145+
146+ def send (self , c ):
147+ """ send the given command, retrieve and parse response """
145148
146149 # check for a connection
147150 if not self .is_connected ():
148151 debug ("Query failed, no connection available" , True )
149152 return Response () # return empty response
150153
154+ # send the query
155+ debug ("Sending command: %s" % str (c ))
156+ self .port .send (c .get_command ()) # send command to the port
157+ return c .compute (self .port .get ()) # get the data, and compute a response object
158+
159+
160+ def query (self , c , force = False ):
161+
151162 # check that the command is supported
152- if not (self .has_command (command ) or force ):
153- debug ("'%s' is not supported" % str (command ), True )
163+ if not (self .has_command (c ) or force ):
164+ debug ("'%s' is not supported" % str (c ), True )
154165 return Response () # return empty response
166+ else :
167+ return self .send (c )
155168
156- # send the query
157- debug ("Sending command: %s" % str (command ))
158- self .port .send (command .get_command ()) # send command to the port
159- return command .compute (self .port .get ()) # get the data, and compute a response object
160169
161170 '''
162171 def query_DTC(self):
0 commit comments