Exemple #1
0
    def write_to_toolhead_EEPROM(self, tool_index, offset, data):
        """
        Write some data to the toolhead. The data structure is implementation specific.
        @param int tool_index: Index of tool to access
        @param byte offset: EEPROM location to begin writing to
        @param list data: Data to write to the EEPROM
        """
        # TODO: this length is bad
        if len(data) > makerbot_driver.maximum_payload_length - 6:
            raise makerbot_driver.EEPROMLengthError(len(data))

        payload = struct.pack(
            '<HB',
            offset,
            len(data),
        )

        payload += data

        response = self.tool_query(
            tool_index,
            makerbot_driver.slave_query_command_dict['WRITE_TO_EEPROM'],
            payload)

        if response[1] != len(data):
            raise makerbot_driver.EEPROMMismatchError(response[1])
Exemple #2
0
    def read_from_EEPROM(self, offset, length):
        """
        Read some data from the machine. The data structure is implementation specific.
        @param byte offset: EEPROM location to begin reading from
        @param int length: Number of bytes to read from the EEPROM (max 31)
        @return byte array of data read from EEPROM
        """
        if length > makerbot_driver.maximum_payload_length - 1:
            raise makerbot_driver.EEPROMLengthError(length)

        payload = struct.pack(
            '<BHb',
            makerbot_driver.host_query_command_dict['READ_FROM_EEPROM'],
            offset, length)

        response = self.writer.send_query_payload(payload)

        return response[1:]
Exemple #3
0
    def read_from_toolhead_EEPROM(self, tool_index, offset, length):
        """
        Read some data from the toolhead. The data structure is implementation specific.
        @param byte offset: EEPROM location to begin reading from
        @param int length: Number of bytes to read from the EEPROM (max 31)
        @return byte array: of data read from EEPROM
        """
        if length > makerbot_driver.maximum_payload_length - 1:
            raise makerbot_driver.EEPROMLengthError(length)

        payload = struct.pack('<HB', offset, length)

        response = self.tool_query(
            tool_index,
            makerbot_driver.slave_query_command_dict['READ_FROM_EEPROM'],
            payload)

        return response[1:]
Exemple #4
0
    def write_to_EEPROM(self, offset, data):
        """
        Write some data to the machine. The data structure is implementation specific.
        @param byte offset: EEPROM location to begin writing to
        @param int data: Data to write to the EEPROM
        """
        if len(data) > makerbot_driver.maximum_payload_length - 4:
            raise makerbot_driver.EEPROMLengthError(len(data))

        payload = struct.pack(
            '<BHb',
            makerbot_driver.host_query_command_dict['WRITE_TO_EEPROM'],
            offset,
            len(data),
        )

        payload += data

        response = self.writer.send_query_payload(payload)

        if response[1] != len(data):
            raise makerbot_driver.EEPROMMismatchError(response[1])
 def mock_write_to_EEPROM(*args, **kwards):
     if len(args[1]) > makerbot_driver.maximum_payload_length - 4:
         raise makerbot_driver.EEPROMLengthError(len(args[1]))