Exemplo n.º 1
0
 def internal_read(self, page, ecc_state = 1):            
     addr = page * self.max_page_size_info        
     txdata = pack32L(addr) + pack16L(ecc_state) + struct.pack("<" + "I"*3, self.max_block_cnt_info, self.max_block_size_info, self.max_page_size_info) 
     txdata += "\x00" * (self.header_len - len(txdata))
     
     data = self.send_command(self.Commands.CMD_NAND_IMAGE_READ_PAGE, \
                               self.Commands.CMD_NAND_IMAGE_READ_PAGE, txdata)
     page_data = data[self.header_len:]
     return page_data
Exemplo n.º 2
0
    def send(self, data, empty_header = False):


        crc = self.__crc_calculator.calc(data)
        if self.__crc_big_endian:
            data += pack16B(crc)
        else:
            data += pack16L(crc)
                
        if (self.__tx_escape):
            data = self.hdlc_escape(data)


        #add 7e at beginning & end
        if self.__special_header:
            out_data  = self.__special_header
        elif self.__empty_header or empty_header:
            out_data  = ""
        else:
            out_data  = "\x7E"
        out_data += data 
        out_data += "\x7E"
        
        self.base.send(out_data)
Exemplo n.º 3
0
 def change_mode(self, mode):
     """
     change to offline mode. gets an enum ControlModes.
     """
     return self.__send_command(self.Commands.DIAG_CONTROL_F, pack16L(mode))
Exemplo n.º 4
0
 def __peek(self, command, addr, codeword_count, codeword_size):
     return self.__send_command(
         command, tx=pack32L(addr) +
         pack16L(codeword_count))[6:6 + codeword_count * codeword_size]
Exemplo n.º 5
0
 def send(self, data):
     # 42 is always there in the tfs
     # the +2 is for the crc
     data = pack16L(len(data)+2)+ "\x42" + data + pack16B(self.crc.calc(data))
     data = "\x7f" + data + "\x7e"
     self.base.send(data)
Exemplo n.º 6
0
    def send(self, command):
        command += "\x00"
        out_data = "\x00\x05" + pack16L(len(command)) + command

        self.base.send(out_data)