5/16/2023 0 Comments Instacal runtime error![]() ![]() Print( f'Background function started with rate. Low_channel, high_channel, buffer_size, rate, Low_channel = 0 high_channel = n_channels - 1 print( 'Starting background function.') Handle, buffer_size, total_points = allocate_data_buffer( n_channels, rate)Ĭtypes_array = cast( handle, POINTER( c_double)) Raises: RuntimeError: If the status returned by ul.get_status turns to 0 during the polling. sleep_before_stop (float, optional): Sleep duration before calling ul.stop_background. count (int, optional): The iteration count. duration (float, optional): The duration of the polling. period (float, optional): The polling period. Args: board_num (int): The board number n_channels (int): The number of channels rate (int, optional): The sampling rate. """ Configure a USB2404UI board for K-type thermocouple acquisition, start a background function and poll the universal library for new data. Return handle, buffer_size, total_points def poll( board_num: int, n_channels: int, rate: int = 50, period: float = 0.1,ĭuration: float = 60.0, count: int = 0, sleep_before_stop: float = 0.0): Num_points = rate total_points = n_channels * num_points buffer_size = 2 * total_points handle = ul. set_config(ĭef allocate_data_buffer( n_channels: int, rate: int = 50): TempScale, TInOptions, ULRange, InterfaceType)ĭef config( board_num: int, n_channels: int):īoardInfo. enums import ( AdTimingMode, AiChanType, BoardInfo, ExpansionInfo,įunctionType, InfoType, ScanOptions, TcType, """ import time import random import traceback from ctypes import POINTER, c_double, cast import numpy as np from mcculw import ul from mcculw. The only way this can be achieved is by starting a new process every time we wish to start a background and continuous scan. """ Example script to demonstrate that a background continuous scan cannot be started and stopped and restarted over and over with the USB2404UI without crashing the process. ![]() I tested with Python 3.7.0 and Python 3.8.2. Only numpy and mcculw are required to run it. The only workaround I found is to start a new process each time, but this is suboptimal since I also noticed that the mcculw libraries do not like to be loaded in different processes at the same time so we must be careful to avoid this. I never had this behavior with a USB-2416 board so I suspect that this could be specific to the USB2404-UI.
0 Comments
Leave a Reply. |