mirror of https://github.com/Desuuuu/klipper.git
serialhdl: Make dump_debug() output atomic
Build a single (very large) logging message with the debug state. This prevents the output from being fragmented. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
6e5bcc69bc
commit
8f8951b4c1
|
@ -451,8 +451,8 @@ class MCU:
|
||||||
return
|
return
|
||||||
self._is_shutdown = True
|
self._is_shutdown = True
|
||||||
self._shutdown_msg = msg = params['#msg']
|
self._shutdown_msg = msg = params['#msg']
|
||||||
logging.info("%s: %s", params['#name'], self._shutdown_msg)
|
logging.info("MCU '%s' %s: %s\n%s", self._name, params['#name'],
|
||||||
self._serial.dump_debug()
|
self._shutdown_msg, self._serial.dump_debug())
|
||||||
prefix = "MCU '%s' shutdown: " % (self._name,)
|
prefix = "MCU '%s' shutdown: " % (self._name,)
|
||||||
if params['#name'] == 'is_shutdown':
|
if params['#name'] == 'is_shutdown':
|
||||||
prefix = "Previous MCU '%s' shutdown: " % (self._name,)
|
prefix = "Previous MCU '%s' shutdown: " % (self._name,)
|
||||||
|
|
|
@ -141,26 +141,28 @@ class SerialReader:
|
||||||
self.ffi_lib.serialqueue_free_commandqueue)
|
self.ffi_lib.serialqueue_free_commandqueue)
|
||||||
# Dumping debug lists
|
# Dumping debug lists
|
||||||
def dump_debug(self):
|
def dump_debug(self):
|
||||||
logging.info("Dumping serial stats: %s"
|
out = []
|
||||||
, self.stats(self.reactor.monotonic()))
|
out.append("Dumping serial stats: %s" % (
|
||||||
|
self.stats(self.reactor.monotonic()),))
|
||||||
sdata = self.ffi_main.new('struct pull_queue_message[1024]')
|
sdata = self.ffi_main.new('struct pull_queue_message[1024]')
|
||||||
rdata = self.ffi_main.new('struct pull_queue_message[1024]')
|
rdata = self.ffi_main.new('struct pull_queue_message[1024]')
|
||||||
scount = self.ffi_lib.serialqueue_extract_old(
|
scount = self.ffi_lib.serialqueue_extract_old(
|
||||||
self.serialqueue, 1, sdata, len(sdata))
|
self.serialqueue, 1, sdata, len(sdata))
|
||||||
rcount = self.ffi_lib.serialqueue_extract_old(
|
rcount = self.ffi_lib.serialqueue_extract_old(
|
||||||
self.serialqueue, 0, rdata, len(rdata))
|
self.serialqueue, 0, rdata, len(rdata))
|
||||||
logging.info("Dumping send queue %d messages" % (scount,))
|
out.append("Dumping send queue %d messages" % (scount,))
|
||||||
for i in range(scount):
|
for i in range(scount):
|
||||||
msg = sdata[i]
|
msg = sdata[i]
|
||||||
cmds = self.msgparser.dump(msg.msg[0:msg.len])
|
cmds = self.msgparser.dump(msg.msg[0:msg.len])
|
||||||
logging.info("Sent %d %f %f %d: %s" % (
|
out.append("Sent %d %f %f %d: %s" % (
|
||||||
i, msg.receive_time, msg.sent_time, msg.len, ', '.join(cmds)))
|
i, msg.receive_time, msg.sent_time, msg.len, ', '.join(cmds)))
|
||||||
logging.info("Dumping receive queue %d messages" % (rcount,))
|
out.append("Dumping receive queue %d messages" % (rcount,))
|
||||||
for i in range(rcount):
|
for i in range(rcount):
|
||||||
msg = rdata[i]
|
msg = rdata[i]
|
||||||
cmds = self.msgparser.dump(msg.msg[0:msg.len])
|
cmds = self.msgparser.dump(msg.msg[0:msg.len])
|
||||||
logging.info("Receive: %d %f %f %d: %s" % (
|
out.append("Receive: %d %f %f %d: %s" % (
|
||||||
i, msg.receive_time, msg.sent_time, msg.len, ', '.join(cmds)))
|
i, msg.receive_time, msg.sent_time, msg.len, ', '.join(cmds)))
|
||||||
|
return '\n'.join(out)
|
||||||
# Default message handlers
|
# Default message handlers
|
||||||
def handle_unknown(self, params):
|
def handle_unknown(self, params):
|
||||||
logging.warn("Unknown message type %d: %s" % (
|
logging.warn("Unknown message type %d: %s" % (
|
||||||
|
|
Loading…
Reference in New Issue