diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-06-21 19:15:12 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-06-21 21:42:20 -0400 |
commit | cc3666aa78d76b17c2c2292d409f90acfb2b976b (patch) | |
tree | fb7e78fd309b3a6b7d861b52babf09c413e3ad85 /klippy/serialhdl.py | |
parent | d98bbc772cb2a605786443d8cf12abce963a07f6 (diff) | |
download | kutter-cc3666aa78d76b17c2c2292d409f90acfb2b976b.tar.gz kutter-cc3666aa78d76b17c2c2292d409f90acfb2b976b.tar.xz kutter-cc3666aa78d76b17c2c2292d409f90acfb2b976b.zip |
serialhdl: Introduce SerialReader.send_with_response()
Introduce a main send_with_response() helper function and use it
during identify and the setup of clocksync.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/serialhdl.py')
-rw-r--r-- | klippy/serialhdl.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/klippy/serialhdl.py b/klippy/serialhdl.py index 6284fe4d..020a3f27 100644 --- a/klippy/serialhdl.py +++ b/klippy/serialhdl.py @@ -52,10 +52,9 @@ class SerialReader: def _get_identify_data(self, timeout): # Query the "data dictionary" from the micro-controller identify_data = "" - identify_cmd = self.lookup_command("identify offset=%u count=%c") while 1: - params = identify_cmd.send_with_response([len(identify_data), 40], - 'identify_response') + msg = "identify offset=%d count=%d" % (len(identify_data), 40) + params = self.send_with_response(msg, 'identify_response') if params['offset'] == len(identify_data): msgdata = params['data'] if not msgdata: @@ -149,6 +148,10 @@ class SerialReader: def send(self, msg, minclock=0, reqclock=0): cmd = self.msgparser.create_command(msg) self.raw_send(cmd, minclock, reqclock, self.default_cmd_queue) + def send_with_response(self, msg, response): + cmd = self.msgparser.create_command(msg) + src = SerialRetryCommand(self, cmd, response) + return src.get_response() def lookup_command(self, msgformat, cq=None): if cq is None: cq = self.default_cmd_queue |