Esempio n. 1
0
 def __setup_port(self, port, baud):
     """Connect to the serial port and divine some information."""
     self.__s = serial.Serial(port, baud, timeout=0)
     self.__reset()
     giveup = 20  # poll the device for about five seconds before giving in
     post = ""
     while post == "" and giveup > 0:
         # wait for the device to boot
         time.sleep(.25)
         post = "\n".join(self.__s.readlines()).strip()
         giveup -= 1
     for trigger in ("sprinter", "marlin"):
         if post.lower().count(trigger):
             self.__port = port
             self.__baud = baud
             self.post = post
             soup = self.__querie("M115")[0]
             self.reported = parse_capabilities(soup)
             temp = parse_bed_temp(self.__querie("M105")[0])
             self.reported["heated_bed"] = temp is not None
             return True
     return False
Esempio n. 2
0
 def __setup_port(self, port, baud):
     """Connect to the serial port and divine some information."""
     self.__s = serial.Serial(port, baud, timeout=0)
     self.__reset()
     giveup = 20  # poll the device for about five seconds before giving in
     post = ""
     while post == "" and giveup > 0:
         # wait for the device to boot
         time.sleep(0.25)
         post = "\n".join(self.__s.readlines()).strip()
         giveup -= 1
     for trigger in ("sprinter", "marlin"):
         if post.lower().count(trigger):
             self.__port = port
             self.__baud = baud
             self.post = post
             soup = self.__querie("M115")[0]
             self.reported = parse_capabilities(soup)
             temp = parse_bed_temp(self.__querie("M105")[0])
             self.reported["heated_bed"] = temp is not None
             return True
     return False
Esempio n. 3
0
    def __process_response(self, response):
        """Read from the socket and call events where appropriate."""

        for line in response:
            simple = line.lower().strip()

            if simple.startswith("echo:"):
                if simple.count("active extruder:"):
                    # check to see if we changed tools
                    self.tool = int(simple.split(":")[-1].strip())
                    # update the temperature readings to make space
                    # for new tools
                    while len(self.temps["t"]) < self.tool+1:
                        self.temps["t"].append(0)

            elif line.startswith("Error"):
                pass

            elif line.startswith("DEBUG_"):
                pass

            else:
                # check for a state report

                # first check to see if the line contains the tool temp
                tool_temp = parse_tool_temp(simple)
                if tool_temp:
                    self.temps["t"][self.tool] = tool_temp
                    self.on_state_changed()

                # next check to see if the line contains the bed temp
                # note that this is usually is on the same line as the
                # tool temp
                bed_temp = parse_bed_temp(simple)
                if bed_temp:
                    self.temps["b"] = bed_temp
                    self.on_state_changed()
Esempio n. 4
0
    def __process_response(self, response):
        """Read from the socket and call events where appropriate."""

        for line in response:
            simple = line.lower().strip()

            if simple.startswith("echo:"):
                if simple.count("active extruder:"):
                    # check to see if we changed tools
                    self.tool = int(simple.split(":")[-1].strip())
                    # update the temperature readings to make space
                    # for new tools
                    while len(self.temps["t"]) < self.tool + 1:
                        self.temps["t"].append(0)

            elif line.startswith("Error"):
                pass

            elif line.startswith("DEBUG_"):
                pass

            else:
                # check for a state report

                # first check to see if the line contains the tool temp
                tool_temp = parse_tool_temp(simple)
                if tool_temp:
                    self.temps["t"][self.tool] = tool_temp
                    self.on_state_changed()

                # next check to see if the line contains the bed temp
                # note that this is usually is on the same line as the
                # tool temp
                bed_temp = parse_bed_temp(simple)
                if bed_temp:
                    self.temps["b"] = bed_temp
                    self.on_state_changed()