def read(self, addr, length):
     response = self.send_command(self.Commands.CMD_MEM_READ_REQ, \
                                    self.Commands.CMD_MEM_READ_RESP, \
                                    pack32B(addr) + pack16B(length))
     read_addr   = unpack32B(response[:4])
     read_length = unpack16B(response[4:6])
     data = response[6:6+length]
     return data
Example #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)
 def write(self, addr, data):
     response = self.send_command(self.Commands.CMD_WRITE_32BIT, \
                                    tx = pack32B(addr) + pack16B(len(data)) + data )
     return response
 def write_addr24bit(self, addr,data):
     response = self.send_command(self.Commands.CMD_WRITE, \
                                    tx = pack32B(addr)[1:] + pack16B(len(data)) + data )
     return response
Example #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)