Yellowfin tweak, improved test program.

- Changed default E-steps for Yellowfin Dual.
- Changes to test code.
master
Marcio Teixeira 7 years ago
parent 8a5fe8b1a1
commit c15aed96dc

@ -37,7 +37,7 @@
#error Must specify model and toolhead. Please see "Configuration_LulzBot.h" for directions. #error Must specify model and toolhead. Please see "Configuration_LulzBot.h" for directions.
#endif #endif
#define LULZBOT_FW_VERSION ".23" #define LULZBOT_FW_VERSION ".24"
// Select options based on printer model // Select options based on printer model
@ -544,6 +544,8 @@
#define LULZBOT_SWAP_EXTRUDERS #define LULZBOT_SWAP_EXTRUDERS
#undef LULZBOT_INVERT_E1_DIR #undef LULZBOT_INVERT_E1_DIR
#define LULZBOT_INVERT_E1_DIR false #define LULZBOT_INVERT_E1_DIR false
#undef LULZBOT_E_STEPS
#define LULZBOT_E_STEPS 760
#define LULZBOT_AO_Hexagon #define LULZBOT_AO_Hexagon
#endif /* TOOLHEAD_Yellowfin_DualExtruder */ #endif /* TOOLHEAD_Yellowfin_DualExtruder */

@ -47,7 +47,7 @@ def send_gcode_test(filename, serial):
gcode = load_gcode(filename) gcode = load_gcode(filename)
for i, line in enumerate(gcode): for i, line in enumerate(gcode):
serial.enqueueCommand(line) serial.sendCmdReliable(line)
while(not serial.clearToSend()): while(not serial.clearToSend()):
serial.readline() serial.readline()
if(i % 1000 == 0): if(i % 1000 == 0):

@ -42,4 +42,8 @@ class LoggingSerialConnection:
self._log("< Timeout") self._log("< Timeout")
else: else:
self._log("< " + data.decode(), end='') self._log("< " + data.decode(), end='')
return data return data
@property
def in_waiting(self):
return self.serial.in_waiting

@ -33,9 +33,9 @@
# The prototypical use case for this class is as follows: # The prototypical use case for this class is as follows:
# #
# for line in enumerate(gcode): # for line in enumerate(gcode):
# serial.enqueueCommand(line) # serial.sendCmdLine(line)
# while(not serial.clearToSend()): # while(not serial.clearToSend()):
# serial.readLine() # serial.readline()
# #
import functools import functools
@ -87,7 +87,10 @@ class MarlinSerialProtocol:
self.marlinBufSize = 4 self.marlinBufSize = 4
self.marlinReserve = 1 self.marlinReserve = 1
self.history = GCodeHistory() self.history = GCodeHistory()
self.asap = []
self.slow_commands = re.compile(b"M109|M190|G28|G29") self.slow_commands = re.compile(b"M109|M190|G28|G29")
self.slow_timeout = 400
self.fast_timeout = 15
self.restart() self.restart()
def _stripCommentsAndWhitespace(self, str): def _stripCommentsAndWhitespace(self, str):
@ -113,9 +116,13 @@ class MarlinSerialProtocol:
def _sendToMarlin(self): def _sendToMarlin(self):
"""Sends as many commands as are available and to fill the Marlin buffer. """Sends as many commands as are available and to fill the Marlin buffer.
Commands are read from the history. Generally only the most recently Commands are first read from the asap queue, then read from the
appended command is sent; but after a resend request, we may be history. Generally only the most recently history command is sent;
further back in the history than that""" but after a resend request, we may be further back in the history
than that"""
while(len(self.asap) and self.marlinBufferCapacity() > 0):
cmd = self.asap.pop(0);
self._sendImmediate(cmd)
while(not self.history.atEnd() and self.marlinBufferCapacity() > 0): while(not self.history.atEnd() and self.marlinBufferCapacity() > 0):
pos, cmd = self.history.getNextCommand(); pos, cmd = self.history.getNextCommand();
self._sendImmediate(cmd) self._sendImmediate(cmd)
@ -158,9 +165,9 @@ class MarlinSerialProtocol:
self.stallCountdown -= 1 self.stallCountdown -= 1
else: else:
self.stallCountdown = 2 self.stallCountdown = 2
self._sendImmediate("\nM105*\n") self._sendImmediate(b"\nM105*\n")
else: else:
estimated_duration = 15 if self.slow_commands.search(line) else 2 estimated_duration = self.slow_timeout if self.slow_commands.search(line) else self.fast_timeout
self.stallCountdown = max(estimated_duration, self.stallCountdown-1) self.stallCountdown = max(estimated_duration, self.stallCountdown-1)
def _resendFrom(self, position): def _resendFrom(self, position):
@ -173,15 +180,27 @@ class MarlinSerialProtocol:
while self.serial.readline() != b"": while self.serial.readline() != b"":
pass pass
def enqueueCommand(self, cmd): def sendCmdReliable(self, line):
"""Adds a command to the sending queue. Queued commands will only be processed during calls to readLine()""" """Adds command line (can contain comments or blanks) to the queue for reliable
if isinstance(cmd, str): transmission. Queued commands will be processed during calls to readLine() or
cmd = cmd.encode() clearToSend()"""
cmd = self._stripCommentsAndWhitespace(cmd) if isinstance(line, str):
cmd = self._replaceEmptyLineWithM105(cmd) line = line.encode()
line = self._stripCommentsAndWhitespace(line)
cmd = self._replaceEmptyLineWithM105(line)
cmd = self._addPositionAndChecksum(self.history.getAppendPosition(), cmd) cmd = self._addPositionAndChecksum(self.history.getAppendPosition(), cmd)
self.history.append(cmd) self.history.append(cmd)
def sendCmdUnreliable(self, line):
"""Sends a command (can contain comments or blanks) prior to any other
history commands. Commands will be processed during calls to
readLine() or clearToSend()"""
if isinstance(line, str):
line = line.encode()
cmd = self._stripCommentsAndWhitespace(line)
if cmd:
self.asap.append(cmd)
def _gotOkay(self): def _gotOkay(self):
if self.pendingOk > 0: if self.pendingOk > 0:
self.pendingOk -= 1 self.pendingOk -= 1
@ -217,9 +236,10 @@ class MarlinSerialProtocol:
# detects a command with a checksum or line number error. # detects a command with a checksum or line number error.
resendPos = self._isResendRequest(line) or self._isNoLineNumberErr(line) resendPos = self._isResendRequest(line) or self._isNoLineNumberErr(line)
if resendPos: if resendPos:
# If we got a resend requests, purge lines until timeout, but watch # If we got a resend requests, purge lines until input buffer is empty
# for any subsequent resend requests (we must only act on the last). # or timeout, but watch for any subsequent resend requests (we must
while line != b"": # only act on the last).
while self.serial.in_waiting and line != b"":
line = self.serial.readline() line = self.serial.readline()
resendPos = self._isResendRequest(line) or self._isNoLineNumberErr(line) or resendPos resendPos = self._isResendRequest(line) or self._isNoLineNumberErr(line) or resendPos
# Process the last received resend request: # Process the last received resend request:
@ -247,7 +267,7 @@ class MarlinSerialProtocol:
"""Clears all buffers and issues a M110 to Marlin. Call this at the start of every print.""" """Clears all buffers and issues a M110 to Marlin. Call this at the start of every print."""
self.history.clear() self.history.clear()
self.pendingOk = 0 self.pendingOk = 0
self.stallCountdown = 5 self.stallCountdown = self.fast_timeout
self.gotError = False self.gotError = False
self._flushReadBuffer() self._flushReadBuffer()
self._resetMarlinLineCounter() self._resetMarlinLineCounter()

@ -43,6 +43,10 @@ class NoisySerialConnection:
data = self._corruptData(data) data = self._corruptData(data)
return data return data
@property
def in_waiting(self):
return self.serial.in_waiting
def flush(self): def flush(self):
self.serial.flush() self.serial.flush()

Loading…
Cancel
Save