def write_block(self, block, data, skip_audit=False): """ Writes a block. block is an integer data is a bytearray, filename, or FLP.Packets object """ if isinstance(data, FLP.Packets): assert skip_audit == False return self.write_block_flp(block, data) if not isinstance(data, bytearray): data = bytearray(open(data, "rb").read()) # Check to see that laser power is always acceptable, # raising an exception if the power is too high if self.AUDIT_LASER_POWER and not skip_audit: flp = FLP.fromstring(data) self.audit_laser_power_flp(flp) header = bytearray(struct.pack("<III", block, len(data), self._fletcher32(data))) self._command(Command.CMD_LOAD_PRINT_DATA_BLOCK, header + data, expect_success=True)
def write_block(self, block, data, skip_audit=False): """ Writes a block. block is an integer data is a bytearray, filename, or FLP.Packets object """ if isinstance(data, FLP.Packets): assert skip_audit == False return self.write_block_flp(block, data) if not isinstance(data, bytearray): data = bytearray(open(data, 'rb').read()) # Check to see that laser power is always acceptable, # raising an exception if the power is too high if self.AUDIT_LASER_POWER and not skip_audit: flp = FLP.fromstring(data) self.audit_laser_power_flp(flp) header = bytearray( struct.pack('<III', block, len(data), self._fletcher32(data))) self._command(Command.CMD_LOAD_PRINT_DATA_BLOCK, header + data, expect_success=True)
def read_block_flp(self, block): return FLP.fromstring(self.read_block(block))
def read_block_flp(self, block): return FLP.fromstring(self.read_block(block))