ULDI03.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:mcculw 作者: mccdaq 项目源码 文件源码
def start_scan(self):
        rate = 100
        count = 1000

        # Allocate a buffer for the scan
        self.memhandle = ul.win_buf_alloc(count)

        # Check if the buffer was successfully allocated
        if not self.memhandle:
            messagebox.showerror("Error", "Failed to allocate memory")
            self.set_ui_idle_state()
            return

        try:
            # Configure the port (if necessary)
            if self.port.is_port_configurable:
                ul.d_config_port(
                    self.board_num, self.port.type, DigitalIODirection.IN)

            # Run the scan
            ul.d_in_scan(
                self.board_num, self.port.type, count, rate, self.memhandle,
                ScanOptions.BACKGROUND)
        except ULError as e:
            self.show_ul_error(e)
            self.set_ui_idle_state()
            return

        # Convert the memhandle to a ctypes array
        # Note: the ctypes array will no longer be valid after win_buf_free is called.
        # A copy of the buffer can be created using win_buf_to_array
        # before the memory is freed. The copy can be used at any time.
        self.ctypes_array = self.memhandle_as_ctypes_array(self.memhandle)

        # Start updating the displayed values
        self.update_displayed_values()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号