当前位置: 首页>>代码示例>>Python>>正文


Python array.append方法代码示例

本文整理汇总了Python中array.array.append方法的典型用法代码示例。如果您正苦于以下问题:Python array.append方法的具体用法?Python array.append怎么用?Python array.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在array.array的用法示例。


在下文中一共展示了array.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fill_memory_with_pattern

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
    def fill_memory_with_pattern(self):
        position = 0
        #self.clear_memory()
        total_size = self.n.get_device_size(self.memory_urn)

        size = 0
        if total_size > MAX_LONG_SIZE:
            self.s.Verbose("Memory Size: 0x%08X is larger than write size" % total_size)
            self.s.Verbose("\tBreaking transaction into 0x%08X chunks" % MAX_LONG_SIZE)
            size = MAX_LONG_SIZE
        else:
            size = total_size

        #Write Data Out
        data_out = Array('B')
        for i in range (0, size):
            data_out.append((i % 0x100))


        while position < total_size:
            self.n.write_memory(position, data_out)

            #Increment the position
            prev_pos = position

            if position + size > total_size:
                size = total_size - position
            position += size
            self.s.Verbose("Wrote: 0x%08X - 0x%08X" % (prev_pos, position))
开发者ID:CospanDesign,项目名称:nysa,代码行数:31,代码来源:test_dma_sata.py

示例2: stream_read_write_bram

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def stream_read_write_bram(dut):
    """
    Description:
        Read and write data to the block ram

    Test ID: 2

    Expected Results:
        Write Data the Block RAM through Wishbone interface
        Read Same data from the block RAM through wishbone interface
    """
    dut.test_id = 2
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield(nysa.wait_clocks(10))
    driver = wb_hs_demoDriver(nysa, nysa.find_device(wb_hs_demoDriver)[0])
    data = Array('B')
    SIZE =1024
    for i in range(SIZE):
        data.append(i % 256)

    yield cocotb.external(driver.write_data)(0x00, data)
    yield (nysa.wait_clocks(100))
    v = yield cocotb.external(driver.read_data)(0x00, (SIZE / 4))

    if len(v) != len(data):
        raise cocotb.result.TestFailure("Test %d: Length of incomming data and outgoing data is equal %d = %d" % (dut.test_id, len(v), len(data)))

    for i in range(len(data)):
        if v[i] != data[i]:
            raise cocotb.result.TestFailure("Test %d: Address 0x%02X 0x%02X != 0x%02X" % (dut.test_id, i, v[i], data[i]))

    dut.log.info("Success")
开发者ID:CospanDesign,项目名称:nysa-verilog,代码行数:37,代码来源:test_dut.py

示例3: read_voltage_range

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
  def read_voltage_range(self):
#    print "Read Volage range"
#    read_data = self.send_command(CMD_READ_VOLT, COMMAND_LENGTH + 32)
#    print "Read data: %s" % str(read_data)
#    self.get_r1_response(read_data)


    
    self.spi.set_character_length(COMMAND_LENGTH + 32)
    crc = self.generate_crc(CMD_READ_VOLT)
    data = Array('B', CMD_READ_VOLT)
    data.append(crc)

    self.spi.set_write_data(data)
    self.spi.start_transaction()
    while self.spi.is_busy():
      print ".",
      time.sleep(0.01)
  
    read_data = self.spi.get_read_data(COMMAND_LENGTH + 32)
    r1 = 0xFF
    index = 0
    for i in range (0, len(read_data)):
      if read_data[i] < 0x08:
        r1 = read_data[i]
        index = i
        #print "index: %d" % i

    self.print_r1_response(r1)
    print "read data: %s" % str(read_data)
开发者ID:CospanDesign,项目名称:olympus,代码行数:32,代码来源:sdcard_sheild.py

示例4: clear_memory

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
    def clear_memory(self):
        total_size = self.n.get_device_size(self.urn)
        offset = self.n.get_device_address(self.urn)
        position = 0
        size = 0
        if self.status.is_command_line():
            self.status.Verbose( "Clearing Memory")
            self.status.Verbose( "Memory Size: 0x%08X" % size)

        if total_size > MAX_LONG_SIZE:
            self.status.Info("Memory Size: 0x%08X is larger than read/write size" % total_size)
            self.status.Info("\tBreaking transaction into 0x%08X chunks" % MAX_LONG_SIZE)
            size = MAX_LONG_SIZE
        else:
            size = total_size

        while position < total_size:
            data_out = Array('B')
            for i in range(0, ((size / 4) - 1)):
                num = 0x00
                data_out.append(num)

            self.n.write_memory(offset + position, data_out)

            #Increment the position
            prev_pos = position
            position += size

            if position + size > total_size:
                size = total_size - position

            if self.status:
                self.status.Verbose("Cleared: 0x%08X - 0x%08X" % (prev_pos, position))
开发者ID:CospanDesign,项目名称:nysa-gui,代码行数:35,代码来源:controller.py

示例5: read_command

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
    def read_command(self, address, length):
        """
        read data or status from the MCU, the length specifies how much
        data to read from the MCU after the address is written

        Args:
            address (integer): register address to write to
            length (integer): number of bytes to read from the register

        Returns:
            (Array of bytes) 8-bit value of the register

        Raises:
            NysaCommError: Error in communication
        """
        output = Array('B')
        #Get the control register
        self.set_register_bit(CONTROL, CONTROL_COMMAND_MODE)
        #Tell the lcd command controller we are sending the command
        self.clear_register_bit(CONTROL, CONTROL_COMMAND_PARAMETER)
        #Put the data in the register
        self.write_register(COMMAND_DATA, address)
        #We are going to be writing
        self.set_register_bit(CONTROL, CONTROL_COMMAND_WRITE)
        for i in range (length):
            #Tell the lcd command controller we are sending parameters
            self.set_register_bit(CONTROL, CONTROL_COMMAND_PARAMETER)
            #We are going to be reading
            self.set_register_bit(CONTROL, CONTROL_COMMAND_READ)

            #Read the data from the data register
            output.append(self.read_register(COMMAND_DATA))

        self.clear_register_bit(CONTROL, CONTROL_COMMAND_MODE)
        return output
开发者ID:CospanDesign,项目名称:nysa,代码行数:37,代码来源:lcd_SSD1963.py

示例6: dword_to_array

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def dword_to_array(value):
    out = Array('B')
    out.append((value >> 24) & 0xFF)
    out.append((value >> 16) & 0xFF)
    out.append((value >>  8) & 0xFF)
    out.append((value >>  0) & 0xFF)
    return out
开发者ID:CospanDesign,项目名称:nysa-tx1-pcie-platform,代码行数:9,代码来源:nysa_pcie.py

示例7: get_capture_data

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
  def get_capture_data(self):
    """get_capture_data

    returns an array of the captured data

    Args:
      Nothing

    Return:
      Array of 32-bit unsigned values

    Raises:
      OlympusCommError: Error in communication
      LAError: Capture was not finished
    """
    if not self.is_capture_finished():
      raise LAError("Capture is not finished")


    #get the number of 32-bits to read
    count = self.get_data_count()
    
    print "Reading %d Vaues" % count

    data_in = self.o.read(self.dev_id, DATA, count)
    #change this to 32-bit value
    data_out = Array('L')
    print "Data in Lenght: %d" % len(data_in)
    print "Data length: %d" % len(data_out)

    for i in range(0, len(data_in), 4):
      data_out.append (data_in[i] << 24 | data_in[i + 1] << 16 | data_in[i + 2] << 8 | data_in[i + 3])

    return data_out
开发者ID:CospanDesign,项目名称:olympus,代码行数:36,代码来源:logic_analyzer.py

示例8: clear_memory

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
    def clear_memory(self):
        total_size = self.n.get_device_size(self.urn)
        position = 0
        size = 0
        print ( "Clearing Memory")
        print ( "Memory Size: 0x%08X" % size)

        if total_size > MAX_LONG_SIZE:
            print("Memory Size: 0x%08X is larger than read/write size" % total_size)
            print("\tBreaking transaction into 0x%08X chunks" % MAX_LONG_SIZE)
            size = MAX_LONG_SIZE
        else:
            size = total_size

        while position < total_size:
            data_out = Array('B')
            for i in range (0, size):
                data_out.append(0x00)

            self.n.write_memory(position, data_out)

            #Increment the position
            prev_pos = position

            if position + size > total_size:
                size = total_size - position
            position += size
开发者ID:CospanDesign,项目名称:nysa,代码行数:29,代码来源:test_memory.py

示例9: read

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
    def read(self, address, length = 1, disable_auto_inc = False):
        """read

        Generic read command used to read data from a Nysa image

        Args:
            length (int): Number of 32 bit words to read from the FPGA
            address (int):  Address of the register/memory to read
            disable_auto_inc (bool): if true, auto increment feature will be disabled

        Returns:
            (Array of unsigned bytes): A byte array containtin the raw data
                                     returned from Nysa

        Raises:
            NysaCommError: When a failure of communication is detected
        """
        read_cmd = "L%07X00000002%08X00000000"
        read_cmd = (read_cmd) % (length, address)
        self.ser.flushInput()
        self.ser.write(read_cmd)
        read_resp = self.ser.read(24 + ((length) * 8))
        response = Array('B')
        d = read_resp[24:]

        for i in range (0, len(d), 2):
            v = int(d[i], 16) << 4
            v |= int(d[i + 1], 16)
            response.append(v)

        return response
开发者ID:CospanDesign,项目名称:nysa-uart-platform,代码行数:33,代码来源:uart.py

示例10: write_local_buffer

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
    def write_local_buffer(self, addr, data):
        #Make sure data is 32-bit Aligned
        data = Array('B', data)
        while len(data) % 4 > 0:
            data.append(0x00)

        self.write(BUFFER_OFFSET + addr, data)
开发者ID:CospanDesign,项目名称:nysa,代码行数:9,代码来源:sdio_device_driver.py

示例11: memory_read_write_test

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def memory_read_write_test(dut):

    dut.test_id <= 1

    print "module path: %s" % MODULE_PATH
    nysa = NysaSim(dut, SIM_CONFIG, CLK_PERIOD, user_paths = [MODULE_PATH])
    setup_dut(dut)
    yield(nysa.reset())
    nysa.read_sdb()
    yield (nysa.wait_clocks(10))
    nysa.pretty_print_sdb()
    driver = wb_master_testDriver(nysa, nysa.find_device(wb_master_testDriver)[0])
    yield (nysa.wait_clocks(10))
    dut.log.info("Ready")
    LENGTH = 100
    DATA = Array('B')
    for i in range (LENGTH):
        DATA.append(i % 256)

    while len(DATA) % 4 != 0:
        DATA.append(0)

    yield cocotb.external(nysa.write_memory)(0x00000, DATA)
    data = yield cocotb.external(nysa.read_memory)(0x00000, (len(DATA) / 4))
    for i in range (len(DATA)):
        if DATA[i] != data[i]:
            log.error("Failed at Address: %04d: 0x%02X != 0x%02X" % (i, DATA[i], data[i]))
开发者ID:CospanDesign,项目名称:nysa-verilog,代码行数:29,代码来源:test_dut.py

示例12: Arrays2Graph

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def Arrays2Graph(X,Y):
    x=MyArray('f')
    y=MyArray('f')
    for i,j in zip(X,Y):
        x.append(i)
        y.append(j)
    return TGraph(len(x),x,y)
开发者ID:nborggren,项目名称:Aleph,代码行数:9,代码来源:Analysis.py

示例13: create_byte_array_from_dword

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def create_byte_array_from_dword(dword):
    d = Array('B')
    d.append((dword >> 24) & 0xFF)
    d.append((dword >> 16) & 0xFF)
    d.append((dword >>  8) & 0xFF)
    d.append((dword >>  0) & 0xFF)
    return d
开发者ID:CospanDesign,项目名称:nysa-verilog,代码行数:9,代码来源:ppfifo_bus.py

示例14: FindZeroes

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def FindZeroes(mesh,func,Z=0,tol=0.001):

    try:
        MyRange = mesh.coordinates()[:]

    except AttributeError:
        MyRange=mesh
        pass
    
    x,y=MyArray('f'),MyArray('f') 

    for i in MyRange:

        if Z==1:
            tmp=func(i[0],i[1])
            if tmp < tol:
                x.append(i[0])
                y.append(i[1])

        else:
            tmp=func(i)
            print func(i),tmp
            if abs(tmp) < tol:
                x.append(i[0])
                y.append(i[1])

    return TGraph(len(x),x,y)
开发者ID:nborggren,项目名称:Aleph,代码行数:29,代码来源:Analysis.py

示例15: OrderParam

# 需要导入模块: from array import array [as 别名]
# 或者: from array.array import append [as 别名]
def OrderParam(mesh,velocity):

    try:
        MyRange = mesh.coordinates()[:]

    except AttributeError:
        MyRange=mesh
        pass
    
    n,d=len(MyRange),len(MyRange[0])
  
    if d==2:
        x,y,z=MyArray('f'),MyArray('f'),MyArray('f') 
        for i in MyRange:
            x.append(i[0])
            y.append(i[1])
            tmp = [j(i) for j in velocity]
            
            if tmp[0]>=0 and tmp[1]>=0:
                z.append(1)
            elif tmp[0]>=0 and tmp[1]<0:
                z.append(0.33)
            elif tmp[0]<0 and tmp[1]>=0:
                z.append(-0.33)
            else:
                z.append(-1)

        return TGraph2D(n,x,y,z)

    else:
        x,y=MyArray('f'),MyArray('f') 
        for i,e in enumerate(MyRange):
            x.append(i)
            y.append(func(e))
        return TGraph(n,x,y)
开发者ID:nborggren,项目名称:Aleph,代码行数:37,代码来源:Analysis.py


注:本文中的array.array.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。