def write_flash(self,method): block_len = 64 filename = 'akp_v0_53e.chx' if method == 'GET': QUERY = self.query_GET() elif method == 'POST': QUERY = self.query_POST() try: addr = int(QUERY['addr'],16) flash_addr = int(QUERY['flash_addr']) except KeyError as err: self.bad_request() print err return data = open(filename).read() self.ok('text/plain') self.wfile.write(str(len(data))+'\n') dump_packets(self.wfile, can.perform_action( can.set_flash_addr_action(addr,flash_addr) ) ) packet_former = can.set_flash_data_packet_former(addr,data[0:64]) for i in range(10): for packet in packet_former(): dump_packets(self.wfile, can.perform_action( lambda sock: packet.send(sock) ))
def set_flash_addr_response(addr,flash_addr): return can.perform_action( can.set_flash_addr_action(addr,flash_addr) )