Compare commits

..

2 Commits
0.0.1 ... 0.0.3

Author SHA1 Message Date
8d8005d10e 0.0.3
add modified date timestamp to file listing
2024-01-14 15:10:00 -05:00
2799c23b0b 0.0.2
only report chamber temp if printer profile has it enabled
2024-01-08 23:27:25 -05:00
2 changed files with 27 additions and 7 deletions

View File

@ -3,6 +3,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
import collections
import datetime
import os
import queue
import re
@ -14,6 +15,7 @@ from pybambu import BambuClient, commands
from serial import SerialTimeoutException
from octoprint.util import RepeatedTimer, to_bytes, to_unicode, get_dos_filename
from octoprint.util.files import unix_timestamp_to_m20_timestamp
from .ftpsclient import IoTFTPSClient
@ -49,6 +51,7 @@ class BambuPrinter:
self.targetTemp = [0.0]
self.bedTemp = self._ambient_temperature
self.bedTargetTemp = 0.0
self._hasChamber = printer_profile_manager.get_current().get("heatedChamber")
self.chamberTemp = self._ambient_temperature
self.chamberTargetTemp = 0.0
self.lastTempAt = time.monotonic()
@ -128,6 +131,7 @@ class BambuPrinter:
# )
# bufferThread.start()
# Move this into M110 command response?
connectionThread = threading.Thread(
target=self._create_connection,
name="octoprint.plugins.bambu_printer.connection_thread",
@ -463,6 +467,11 @@ class BambuPrinter:
self._pauseSdPrint()
return True
def _gcode_M524(self, data: str) -> bool:
if self._sdCardReady:
self._cancelSdPrint()
return False
def _gcode_M26(self, data: str) -> bool:
self._logger.debug("ignoring M26 command.")
self._send("M26 disabled for Bambu")
@ -598,7 +607,7 @@ class BambuPrinter:
request_resend()
def _listSd(self, incl_long=False, incl_timestamp=False):
line = "{name} {size} \"{name}\""
line = "{dosname} {size} {timestamp} \"{name}\""
self._send("Begin file list")
for item in map(lambda x: line.format(**x), self._getSdFiles()):
@ -619,20 +628,24 @@ class BambuPrinter:
else:
filename = entry
filesize = ftp.ftps_session.size(entry)
date_str = ftp.ftps_session.sendcmd(f"MDTM {entry}").replace("213 ", "")
filedate = datetime.datetime.strptime(date_str, "%Y%m%d%H%M%S").replace(tzinfo=datetime.timezone.utc).timestamp()
dosname = get_dos_filename(filename, existing_filenames=list(result.keys())).lower()
data = {
"dosname": dosname,
"name": filename,
"path": filename,
"size": filesize,
"timestamp": unix_timestamp_to_m20_timestamp(int(filedate))
}
result[filename.lower()] = data
# result[dosname.lower()] = filename.lower()
result[dosname.lower()] = filename.lower()
return result
def _getSdFileData(self, filename: str) -> Optional[Dict[str, Any]]:
files = self._mappedSdList()
# TODO: swap this out to use 8 dot 3 name to find long name/path
data = files.get(filename.lower())
if isinstance(data, str):
data = files.get(data.lower())
@ -682,6 +695,13 @@ class BambuPrinter:
else:
self._logger.info("print pause failed")
def _cancelSdPrint(self):
if self.bambu.connected:
if self.bambu.publish(commands.STOP):
self._logger.info("print cancelled")
else:
self._logger.info("print cancel failed")
def _setSdPos(self, pos):
self._newSdFilePos = pos
@ -694,9 +714,9 @@ class BambuPrinter:
def _generateTemperatureOutput(self) -> str:
template = "{heater}:{actual:.2f}/ {target:.2f}"
temps = collections.OrderedDict()
heater = "T"
temps[heater] = (self.temp[0], self.targetTemp[0])
temps["T"] = (self.temp[0], self.targetTemp[0])
temps["B"] = (self.bedTemp, self.bedTargetTemp)
if self._hasChamber:
temps["C"] = (self.chamberTemp, self.chamberTargetTemp)
output = " ".join(

View File

@ -14,7 +14,7 @@ plugin_package = "octoprint_bambu_printer"
plugin_name = "OctoPrint-BambuPrinter"
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.0.1"
plugin_version = "0.0.3"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module